コード例 #1
0
 /**
  * Loads tree for a given namespace
  *
  * @param string $namespace Namespace to build tree for
  * @return Tx_PtExtbase_Tree_Tree Tree build for given namespace
  */
 public function loadTreeByNamespace($namespace)
 {
     if ($this->treeContext->respectEnableFields()) {
         return $this->treeBuilder->buildTreeForNamespaceWithoutInaccessibleSubtrees($namespace);
     } else {
         return $this->treeBuilder->buildTreeForNamespace($namespace);
     }
 }
コード例 #2
0
 /** @test */
 public function buildTreeWithExcludedInaccessibleSubTreesReturnsExpectedTree()
 {
     $nodesObjectStorage = self::buildSetOfNodesWithInaccessibleNodes();
     $nodesArray = $nodesObjectStorage->toArray();
     $repositoryMock = $this->buildRepositoryMock();
     $repositoryMock->expects($this->once())->method('findByNamespace')->will($this->returnValue($nodesObjectStorage));
     $treeBuilder = new Tx_PtExtbase_Tree_TreeBuilder($repositoryMock);
     $tree = $treeBuilder->buildTreeForNamespaceWithoutInaccessibleSubtrees('no_matter_what_namespace');
     $this->assertTrue(is_a($tree, Tx_PtExtbase_Tree_Tree));
     // Assertions, that build tree is correct
     $this->assertEquals($nodesArray[5]->getUid(), $tree->getRoot()->getUid(), 'Root node of tree is not root of given set of nodes');
     $this->assertFalse($nodesArray[5] === $tree->getRoot());
     $this->assertEquals(1, count($tree->getRoot()->getChildren()));
     $children = $tree->getRoot()->getChildren()->toArray();
     $this->assertEquals($nodesArray[1]->getUid(), $children[0]->getUid());
     $child = $children[0];
     $this->assertEquals($tree->getRoot(), $child->getParent());
     $this->assertEquals(0, $child->getChildren()->count());
 }