Fix the DomCrawler tests

This commit is contained in:
Christophe Coevoet 2015-10-02 14:05:56 +02:00
parent 584cfc24a1
commit e6feed285a

View File

@ -313,14 +313,6 @@ class Crawler extends \SplObjectStorage
*/ */
public function addNode(\DOMNode $node) public function addNode(\DOMNode $node)
{ {
if (null !== $this->document && $this->document !== $node->ownerDocument) {
@trigger_error('Attaching DOM nodes from multiple documents in a Crawler is deprecated as of 2.8 and will be forbidden in 3.0.', E_USER_DEPRECATED);
}
if (null === $this->document) {
$this->document = $node->ownerDocument;
}
if ($node instanceof \DOMDocument) { if ($node instanceof \DOMDocument) {
$node = $node->documentElement; $node = $node->documentElement;
} }
@ -329,6 +321,14 @@ class Crawler extends \SplObjectStorage
throw new \InvalidArgumentException(sprintf('Nodes set in a Crawler must be DOMElement or DOMDocument instances, "%s" given.', get_class($node))); throw new \InvalidArgumentException(sprintf('Nodes set in a Crawler must be DOMElement or DOMDocument instances, "%s" given.', get_class($node)));
} }
if (null !== $this->document && $this->document !== $node->ownerDocument) {
@trigger_error('Attaching DOM nodes from multiple documents in a Crawler is deprecated as of 2.8 and will be forbidden in 3.0.', E_USER_DEPRECATED);
}
if (null === $this->document) {
$this->document = $node->ownerDocument;
}
parent::attach($node); parent::attach($node);
} }