File tree 2 files changed +11
-1
lines changed
src/Symfony/Component/DomCrawler
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -430,7 +430,9 @@ public function children()
430
430
throw new \InvalidArgumentException ('The current node list is empty. ' );
431
431
}
432
432
433
- return new static ($ this ->sibling ($ this ->getNode (0 )->firstChild ), $ this ->uri );
433
+ $ node = $ this ->getNode (0 )->firstChild ;
434
+
435
+ return new static ($ node ? $ this ->sibling ($ node ) : array (), $ this ->uri );
434
436
}
435
437
436
438
/**
Original file line number Diff line number Diff line change @@ -536,6 +536,14 @@ public function testChildren()
536
536
} catch (\InvalidArgumentException $ e ) {
537
537
$ this ->assertTrue (true , '->children() throws an \InvalidArgumentException if the node list is empty ' );
538
538
}
539
+
540
+ try {
541
+ $ crawler = new Crawler ('<p></p> ' );
542
+ $ crawler ->filter ('p ' )->children ();
543
+ $ this ->assertTrue (true , '->children() does not trigger a notice if the node has no children ' );
544
+ } catch (\PHPUnit_Framework_Error_Notice $ e ) {
545
+ $ this ->fail ('->children() does not trigger a notice if the node has no children ' );
546
+ }
539
547
}
540
548
541
549
public function testParents ()
You can’t perform that action at this time.
0 commit comments