public function testGetChildNodeIfExists() { $doc = new TemplateTag(); $doc->setContent('<html:template name="foo">bar</html:template>'); $doc->onParseTime(); $template = $doc->getChildNodeIfExists('name', 'foo', TemplateTag::class); $this->assertNotNull($template); $this->assertEquals('bar', $template->getContent()); // ensure that a reference is returned instead of a clone or copy $children = $doc->getChildren(); $this->assertEquals(spl_object_hash($template), spl_object_hash($children[array_keys($children)[0]])); }