Example #1
0
 public function itMayWrapAnObject()
 {
     $object = mock('stdClass');
     $node = new TreeNode();
     $node->setObject($object);
     $this->assertEqual($object, $node->getObject());
 }
 private function getParentNode(Tracker_Artifact $parent, array &$cache_alreaydy_built_parents)
 {
     if (!isset($cache_alreaydy_built_parents[$parent->getId()])) {
         $parent_node = new TreeNode();
         $parent_node->setId($parent->getId());
         $parent_node->setObject($parent);
         $cache_alreaydy_built_parents[$parent->getId()] = $parent_node;
     }
     return $cache_alreaydy_built_parents[$parent->getId()];
 }
 private function buildTreeNode()
 {
     $root = new TreeNode();
     $root->setId(0);
     foreach (func_get_args() as $arg) {
         $node = new TreeNode();
         $node->setObject($arg);
         $node->setId($arg->getId());
         $root->addChild($node);
     }
     return $root;
 }
Example #4
0
 /**
  *
  * @param PFUser     $user                  the user who build the tree
  * @param TreeNode $root                  the artifacts tree
  * @param array    $artifacts             list of artifacts
  * @param array    $artifacts_info        list of the artifacts informations : id, last_changeset_id, title, tracker_id, artifactlinks
  * @param array    $excluded_artifact_ids list of excluded artifact ids
  * @param array    $artifacts_done        list of artifacts already processed
  */
 private function buildArtifactsTree(PFUser $user, TreeNode $root, array $artifacts, array $artifacts_info, array $excluded_artifact_ids, array &$artifacts_done)
 {
     foreach ($artifacts as $artifact) {
         $artifact_id = $artifact->getId();
         if (!isset($excluded_artifact_ids[$artifact_id]) && !isset($artifacts_done[$artifact_id])) {
             $node = new TreeNode($this->getArtifactInfo($artifact, $artifacts_info));
             $node->setObject($artifact);
             $artifacts_done[$artifact_id] = true;
             $this->buildArtifactsTree($user, $node, $artifact->getHierarchyLinkedArtifacts($user), $artifacts_info, $excluded_artifact_ids, $artifacts_done);
             $root->addChild($node);
         }
     }
 }
 public function itWrapsAnArtifactInATreeNode()
 {
     $tracker = aMockTracker()->withId(23452345)->build();
     $children_trackers = array(mock('Tracker'), mock('Tracker'));
     $artifact = mock('Tracker_Artifact');
     stub($artifact)->getId()->returns(123);
     stub($artifact)->getTitle()->returns('Foo');
     stub($artifact)->getUri()->returns('/bar');
     stub($artifact)->getXRef()->returns('art #123');
     stub($artifact)->getTracker()->returns($tracker);
     stub($artifact)->getAllowedChildrenTypes()->returns($children_trackers);
     $planning = mock('Planning');
     $node = new TreeNode(array('id' => 123));
     $node->setObject($artifact);
     $card_mapper = new TreeNodeMapper(new Planning_ItemCardPresenterCallback($planning, mock('Tracker_CardFields'), mock('User'), 'baz'));
     $visited_node = $card_mapper->map($node);
     $presenter = $visited_node->getCardPresenter();
     $this->assertEqual(123, $presenter->getId());
     $this->assertEqual('Foo', $presenter->getTitle());
     $this->assertEqual('/bar', $presenter->getUrl());
     $this->assertEqual('art #123', $presenter->getXRef());
     $this->assertEqual('baz', $presenter->getCssClasses());
     $this->assertEqual($children_trackers, $presenter->allowedChildrenTypes());
 }
 protected function newTreeNode($id, $tracker_id)
 {
     $node = new TreeNode();
     $node->setData(array('id' => $id, 'tracker_id' => $tracker_id));
     $artifact = mock('Tracker_Artifact');
     stub($artifact)->getId()->returns($id);
     stub($artifact)->getTrackerId()->returns($tracker_id);
     $node->setObject($artifact);
     return $node;
 }
Example #7
0
 private function buildArtifactsTree(User $user, TreeNode $root, array $artifacts, array $artifacts_info)
 {
     foreach ($artifacts as $artifact) {
         $node = new TreeNode($this->getArtifactInfo($artifact, $artifacts_info));
         $node->setObject($artifact);
         $this->buildArtifactsTree($user, $node, $artifact->getHierarchyLinkedArtifacts($user), $artifacts_info);
         $root->addChild($node);
     }
 }
Example #8
0
 /**
  * @return \TreeNode 
  */
 public function build()
 {
     $node = new TreeNode($this->data, $this->id);
     $node->setChildren($this->children);
     $node->setObject($this->object);
     return $node;
 }