public function testIsChild() { $parent = new Node(); $child1 = new Node(); $child2 = new Node(); $child1->setParent($parent); $child2->setParent($child1); $this->assertTrue($parent->isChild($child1->id())); $this->assertTrue($parent->isDescendant($child2->id())); $this->assertFalse($parent->isChild($child2->id())); }
public function testPreviousSibling() { $parent = new Node(); $child = new Node(); $child2 = new Node(); $child->setParent($parent); $child2->setParent($parent); $this->assertEquals($child->id(), $child2->previousSibling()->id()); }
public function testGetChildren() { $parent = new Node(); $child = new Node(); $child2 = new Node(); $child->setParent($parent); $child2->setParent($parent); $this->assertEquals($child->id(), $parent->getChildren()[0]->id()); }
public function testGetGreatAncestor() { $parent = new Node(); $child = new Node(); $child2 = new Node(); $parent->addChild($child); $child->addChild($child2); $ancestor = $child2->getAncestor($parent->id()); $this->assertEquals($parent->id(), $ancestor->id()); }