/**
  * @return Tx_PtExtbase_Tree_Tree
  */
 protected function createTestTree()
 {
     $tree = Tx_PtExtbase_Tree_Tree::getEmptyTree('root');
     $rootNode = $tree->getRoot();
     $firstNode = new Tx_PtExtbase_Tree_Node('firstNode');
     $secondNode = new Tx_PtExtbase_Tree_Node('secondNode');
     $firstChildOfSecondNode = new Tx_PtExtbase_Tree_Node('firstChildOfSecondNode');
     $secondNode->addChild($firstChildOfSecondNode);
     $rootNode->addChild($firstNode);
     $rootNode->addChild($secondNode);
     return $tree;
 }
 /**
  * @param Tx_PtExtbase_Tree_Node $node
  * @param array $nodeArray
  * @return array
  */
 public function alterNodeArrayOnFirstVisit($node, $nodeArray)
 {
     $nodeArray['rowCount'] = $this->options[$node->getUid()]['rowCount'];
     return $nodeArray;
 }
Beispiel #3
0
 public function __construct($uid = null, $label = null, $namespace = null)
 {
     parent::__construct($label);
     $this->uid = $uid;
     $this->setNamespace($namespace);
 }
 /**
  * @param Tx_PtExtbase_Tree_Node $originalNode
  * @param Tx_PtExtbase_Tree_Node $clonedNode
  */
 protected function buildAccessRestrictedTreeRecursively($originalNode, $clonedNode)
 {
     foreach ($originalNode->getChildren() as $child) {
         if ($child->isAccessible()) {
             $clonedChild = $this->getClonedNode($child);
             $clonedChild->setParent($clonedNode);
             $this->buildAccessRestrictedTreeRecursively($child, $clonedChild);
         }
     }
 }
 /**
  * @return PHPUnit_Framework_MockObject_MockObject
  */
 protected function getTreeMock()
 {
     $root = new Tx_PtExtbase_Tree_Node('root');
     $subNode = new Tx_PtExtbase_Tree_Node('firstSubNode');
     $root->addChild($subNode);
     $treeMock = $this->getMockBuilder('Tx_PtExtbase_Tree_Tree')->setMethods(array('getNodeByUid', 'getRoot'))->getMock();
     $treeMock->expects($this->once())->method('getNodeByUid')->with(2)->will($this->returnValue($subNode));
     $treeMock->expects($this->any())->method('getRoot')->will($this->returnValue($root));
     return $treeMock;
 }
 /**
  * Hard-deletes a node and its child nodes from database.
  *
  * Warning: No deleted=1 is set in node record, nodes are really deleted!
  *
  * @param Tx_PtExtbase_Tree_Node $node
  */
 protected function deleteNode(Tx_PtExtbase_Tree_Node $node)
 {
     $left = $node->getLft();
     $right = $node->getRgt();
     $query = "DELETE FROM tx_ptextbase_tree_node WHERE lft >= " . $left . " AND rgt <= " . $right;
     $extQuery = $this->createQuery();
     $extQuery->statement($query)->execute(true);
 }
Beispiel #7
0
 /**
  * Returns level of node (0 if node is root).
  *
  * Level is equal to depth
  * of node in tree where root has depth 0.
  *
  * @return integer
  */
 public function getLevel()
 {
     if ($this->parent == null) {
         return 0;
     } else {
         return 1 + $this->parent->getLevel();
     }
 }
Beispiel #8
0
 /** @test */
 public function setAndGetNamespaceReturnsSetNamespace()
 {
     $node = new Tx_PtExtbase_Tree_Node();
     $node->setNamespace('testingNamespace');
     $this->assertEquals($node->getNamespace(), 'testingNamespace');
 }