Eek
Ook eek, ook?
appendChild($d->createElement('html')); $d->documentElement->appendChild($d->createElement('body')); $div = $d->body->appendChild($d->createElement('div')); $ook = $d->body->insertBefore($d->createTextNode('ook'), $div); $this->assertSame('
ook', (string)$d->body); $t = $d->body->insertBefore($d->createElement('template'), $ook); $this->assertSame('ook', (string)$d->body); $this->assertTrue(ElementMap::has($t)); } public function providePreInsertionValidationFailures(): iterable { return [ [ function() { $d = new Document(); $d->appendChild($d->createElement('html')); $b = $d->documentElement->appendChild($d->createElement('body')); $b->appendChild($d->documentElement); } ], [ function() { $d = new Document(); $d->appendChild($d->createElement('html')); $b = $d->documentElement->appendChild($d->createElement('body')); $t = $b->appendChild($d->createElement('template')); $t->content->appendChild($b); } ], [ function() { $d = new Document(); $d->appendChild($d->createElement('html')); $b = $d->documentElement->appendChild($d->createElement('body')); $d->insertBefore($d->createElement('fail'), $b); }, DOMException::NOT_FOUND ], [ function() { $d = new Document(); $df = $d->createDocumentFragment(); $df->appendChild($d->createElement('html')); $df->appendChild($d->createTextNode(' ')); $d->appendChild($df); } ], [ function() { $d = new Document(); $d->appendChild($d); } ], [ function() { $d = new Document(); $d->appendChild($d->implementation->createDocumentType('html')); $d->appendChild($d->implementation->createDocumentType('html')); } ], [ function() { $d = new Document(); $d->appendChild($d->createElement('html')); $d->appendChild($d->implementation->createDocumentType('html')); } ], [ function() { $d = new Document(); $d->appendChild($d->createElement('html')); $c = $d->appendChild($d->createComment('ook')); $d->insertBefore($d->implementation->createDocumentType('html'), $c); } ], [ function() { $d = new Document(); $d->appendChild($d->createElement('html')); $d->documentElement->insertBefore($d->implementation->createDocumentType('html')); } ], [ function() { $d = new Document(); $d->appendChild($d->createElement('html')); $d->documentElement->insertBefore($d->implementation->createDocumentType('html')); } ], [ function() { $d = new Document(); $dt = $d->appendChild($d->implementation->createDocumentType('html')); $df = $d->createDocumentFragment(); $df->appendChild($d->createElement('html')); $d->insertBefore($df, $dt); } ], [ function() { $d = new Document(); $c = $d->appendChild($d->createComment('OOK')); $d->appendChild($d->implementation->createDocumentType('html')); $df = $d->createDocumentFragment(); $df->appendChild($d->createElement('html')); $d->insertBefore($df, $c); } ], [ function() { $d = new Document(); $dt = $d->appendChild($d->implementation->createDocumentType('html')); $d->insertBefore($d->createElement('html'), $dt); } ], [ function() { $d = new Document(); $c = $d->appendChild($d->createComment('OOK')); $d->appendChild($d->implementation->createDocumentType('html')); $d->insertBefore($d->createElement('html'), $c); } ], [ function() { $d = new Document(); $d->appendChild($d->createElement('html')); $d->appendChild($d->createElement('body')); } ] ]; } /** * @dataProvider providePreInsertionValidationFailures * @covers \MensBeam\HTML\DOM\DOMException::__construct * @covers \MensBeam\HTML\DOM\NodeTrait::getRootNode * @covers \MensBeam\HTML\DOM\ParentNode::preInsertionValidity */ public function testPreInsertionValidationFailures(\Closure $closure, int $errorCode = DOMException::HIERARCHY_REQUEST_ERROR): void { $this->expectException(DOMException::class); $this->expectExceptionCode($errorCode); $closure(); } /** @covers \MensBeam\HTML\DOM\ParentNode::__get_children */ public function testPropertyGetChildren(): void { $d = new Document(); $d->appendChild($d->createElement('html')); $d->documentElement->appendChild($d->createElement('body')); $this->assertSame(1, $d->documentElement->children->length); } /** * @covers \MensBeam\HTML\DOM\ParentNode::querySelector * @covers \MensBeam\HTML\DOM\ParentNode::querySelectorAll * @covers \MensBeam\HTML\DOM\ParentNode::scopeMatchSelector * @covers \MensBeam\HTML\DOM\NodeList::__construct * @covers \MensBeam\HTML\DOM\NodeList::item */ public function testQuerySelector(): void { $d = new Document('Ook eek, ook?