public function edit() { $possible_children = $this->factory->getPossibleChildren($this->tracker); $hierarchy = $this->factory->getHierarchy($this->tracker->getUnhierarchizedTracker()); $presenter = new Tracker_Hierarchy_Presenter($this->tracker, $possible_children, $hierarchy); $this->render('admin-hierarchy', $presenter); }
private function getHierarchy(array $trackers_not_in_hierarchy) { $hierarchy = $this->factory->getHierarchy($this->tracker->getUnhierarchizedTracker()); $root_elements = $hierarchy->getChildren(); foreach ($root_elements as $key => $child) { foreach ($trackers_not_in_hierarchy as $tracker) { if ($child->getId() == $tracker->getId()) { $hierarchy->removeChild(0, $child); } } } return $hierarchy; }
public function edit() { $trackers_not_in_hierarchy = $this->getTrackersNotInHierachy(); $presenter = new Tracker_Hierarchy_Presenter($this->tracker, $this->getPossibleChildren($trackers_not_in_hierarchy), $this->factory->getHierarchy($this->tracker->getUnhierarchizedTracker()), $trackers_not_in_hierarchy); $this->render('admin-hierarchy', $presenter); }
public function itCanMoveATrackerAndSonsToAnothersTrackerNotInTheSameBranchAtTheSameTime() { $project_id = 110; $project = new MockProject(); $project->setReturnValue('getID', $project_id); $project_trackers = array('117' => aTracker()->withId(117)->withName('Project')->build(), '118' => aTracker()->withId(118)->withName('Releases')->build(), '120' => aTracker()->withId(120)->withName('Stories')->withProject($project)->build(), '121' => aTracker()->withId(121)->withName('Tasks')->build(), '122' => aTracker()->withId(122)->withName('Bugs')->build(), '119' => aTracker()->withId(119)->withName('Epics')->build()); $tracker = $project_trackers['120']; $hierarchy_dar = new ArrayIterator(array(array('parent_id' => 120, 'child_id' => 118), array('parent_id' => 120, 'child_id' => 117), array('parent_id' => 119, 'child_id' => 120), array('parent_id' => 120, 'child_id' => 122))); $expected_hierarchy = $this->getHierarchyAsTreeNode(array(array('name' => 'Epics', 'id' => 119, 'children' => array(array('name' => 'Stories', 'id' => 120, 'children' => array(array('name' => 'Releases', 'id' => 118, 'children' => array()), array('name' => 'Projects', 'id' => 117, 'children' => array()), array('name' => 'Bugs', 'id' => 122, 'children' => array()))))), array('name' => 'Tasks', 'id' => 121, 'children' => array()))); $dao = $this->aMockDaoWith($project_id, $hierarchy_dar); $tracker_factory = $this->aMockTrackerFactoryWith($project_id, $project_trackers); $factory = new Tracker_Hierarchy_HierarchicalTrackerFactory($tracker_factory, $dao); $this->assertEqual($expected_hierarchy->__toString(), $factory->getHierarchy($tracker)->__toString()); }