public function testPreviousSibling() { $html = '<ul><li>One</li><li>Two</li><li>Three</li></ul>'; $document = new Document($html, false); $list = $document->first('ul'); $item = $list->getNode()->childNodes->item(1); $item = new Element($item); $previousSibling = $list->getNode()->childNodes->item(0); $this->assertEquals($previousSibling, $item->previousSibling()->getNode()); $item = $list->getNode()->childNodes->item(0); $item = new Element($item); $this->assertNull($item->previousSibling()); // with text nodes $html = '<p>Foo <span>Bar</span> Baz</p>'; $document = new Document($html, false); $paragraph = $document->first('p'); $span = $paragraph->first('span'); $previousSibling = $span->getNode()->previousSibling; $this->assertEquals($previousSibling, $span->previousSibling()->getNode()); }