ILIAS  release_8 Revision v8.24
ilHtmlDomNodeIteratorTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
22
27class ilHtmlDomNodeIteratorTest extends TestCase
28{
29 public function testDomNodeIteratorIteratesOverXhtmlDocumentNodes(): void
30 {
31 $dom = new DOMDocument();
32 $dom->loadHTML('<body><div><p><b>phpunit</b> <i>test</i></p></div></body>');
33
34 $expectedElements = [
35 'body',
36 'div',
37 'p',
38 'b',
39 '#text',
40 '#text',
41 'i',
42 '#text',
43 ];
44 $actualElements = [];
45
46 $iter = new RecursiveIteratorIterator(
47 new ilHtmlDomNodeIterator($dom),
48 RecursiveIteratorIterator::SELF_FIRST
49 );
50 foreach ($iter as $element) {
52 $actualElements[] = $element->nodeName;
53 }
54
55 $this->assertSame($expectedElements, $actualElements);
56 }
57}
Class ilHtmlDomNodeIteratorTest.
Class ilHtmlDomNodeIterator.