/** @test */ public function visitorCorrectlyCreatesLeftRightEnumerationOnTree() { $node1 = Tx_PtExtbase_Tests_Unit_Tree_NodeMock::createNode('1', 0, 0, 1, '1'); $node2 = Tx_PtExtbase_Tests_Unit_Tree_NodeMock::createNode('2', 0, 0, 1, '2'); $node3 = Tx_PtExtbase_Tests_Unit_Tree_NodeMock::createNode('3', 0, 0, 1, '3'); $node4 = Tx_PtExtbase_Tests_Unit_Tree_NodeMock::createNode('4', 0, 0, 1, '4'); $node5 = Tx_PtExtbase_Tests_Unit_Tree_NodeMock::createNode('5', 0, 0, 1, '5'); $node6 = Tx_PtExtbase_Tests_Unit_Tree_NodeMock::createNode('6', 0, 0, 1, '6'); $node1->addChild($node2); $node2->setParent($node1); $node1->addChild($node5); $node5->setParent($node1); $node2->addChild($node3); $node3->setParent($node2); $node2->addChild($node4); $node4->setParent($node2); $node5->addChild($node6); $node6->setParent($node5); $tree = Tx_PtExtbase_Tree_Tree::getInstanceByRootNode($node1); $visitor = new Tx_PtExtbase_Tree_NestedSetVisitor(); $treeWalker = new Tx_PtExtbase_Tree_TreeWalker(array($visitor)); $treeWalker->traverseTreeDfs($tree); $this->assertEquals($node1->getLft(), 1); $this->assertEquals($node1->getRgt(), 12); $this->assertEquals($node2->getLft(), 2); $this->assertEquals($node2->getRgt(), 7); $this->assertEquals($node3->getLft(), 3); $this->assertEquals($node3->getRgt(), 4); $this->assertEquals($node4->getLft(), 5); $this->assertEquals($node4->getRgt(), 6); $this->assertEquals($node5->getLft(), 8); $this->assertEquals($node5->getRgt(), 11); $this->assertEquals($node6->getLft(), 9); $this->assertEquals($node6->getRgt(), 10); }
/** @test */ public function treeWalkerDoesNotRespectDepthIfRespectRestrictedDepthIsNotSetOnTree() { $tree = $this->createDemoTree(); $tree->setRestrictedDepth(1); $tree->setRespectRestrictedDepth(false); $visitorMock = $this->createVisitorMock(); $visitorMock->expects($this->exactly(6))->method('doFirstVisit'); $visitorMock->expects($this->exactly(6))->method('doLastVisit'); $treeWalker = new Tx_PtExtbase_Tree_TreeWalker(array($visitorMock)); $treeWalker->traverseTreeDfs($tree); }