public function testIteration() { $document = new HTMLDocument(test\Helper::HTML_MORE); foreach ($document->querySelectorAll("p") as $i => $p) { $paragraphItem = $document->getElementsByTagName("p")[$i]; $this->assertSame($paragraphItem, $p); } }
public function testQuerySelectorAll() { $document = new HTMLDocument(test\Helper::HTML_MORE); $pListTagName = $document->getElementsByTagName("p"); $pListQuerySelector = $document->querySelectorAll("p"); $this->assertEquals($pListTagName->length, $pListQuerySelector->length); for ($i = 0, $len = $pListQuerySelector->length; $i < $len; $i++) { $this->assertSame($pListQuerySelector->item($i), $pListTagName->item($i)); } }