/** * @param NodeInterface $rootNode */ public function __construct(NodeInterface $rootNode = null) { if (!$rootNode) { $rootNode = new Node('root'); } $rootNode->setId(0); $this->nodes[0] = $rootNode; }
public function testRootSettings() { $tree = new Tree(); $this->assertInstanceOf(Node::class, $tree->getTreeRoot()); $root = new Node(); $tree2 = new Tree($root); $this->assertEquals($root, $tree2->getTreeRoot()); $this->assertEquals(0, $tree2->getTreeRoot()->getId()); $root2 = new Node(); $root2->setId(5); $tree3 = new Tree($root2); $this->assertEquals($root2, $tree3->getTreeRoot()); $this->assertEquals(0, $tree3->getTreeRoot()->getId()); }