root = pQuery::parseStr('
italicprevious textnext textbolded
italicprevious text
' . 'next textbolded
' ); } public function testItFindsTopAncestor() { $img = $this->root->query('img'); $this->assertInstanceOf(pQuery::class, $img); $image = $img->offsetGet(0); $this->assertInstanceOf(DomNode::class, $image); $p = $this->root->query('p'); $this->assertInstanceOf(pQuery::class, $p); $paragraph = $p->offsetGet(0); verify(DOMUtil::findTopAncestor($image))->equals($paragraph); } }