public function findFirstSubmilestoneTracker(Planning_Milestone $milestone)
 {
     $children = $this->hierarchy_factory->getChildren($milestone->getTrackerId());
     if (!$children) {
         return null;
     }
     $milestone_backlog_trackers = $milestone->getPlanning()->getBacklogTrackers();
     foreach ($milestone_backlog_trackers as $milestone_backlog_tracker) {
         foreach ($children as $tracker) {
             $planning = $this->planning_factory->getPlanningByPlanningTracker($tracker);
             if (!$planning) {
                 continue;
             }
             $planning_backlog_trackers = $planning->getBacklogTrackers();
             foreach ($planning_backlog_trackers as $planning_backlog_tracker) {
                 if ($milestone_backlog_tracker == $planning_backlog_tracker) {
                     return $tracker;
                 }
                 $backlog_tracker_ancestors = $this->hierarchy_factory->getAllParents($planning_backlog_tracker);
                 if (in_array($milestone_backlog_tracker, $backlog_tracker_ancestors)) {
                     return $tracker;
                 }
             }
         }
     }
 }
Beispiel #2
0
 public function itRetrievesTheChildrenOfAGivenTracker()
 {
     $hierarchy_dao = mock('Tracker_Hierarchy_Dao');
     $tracker_factory = mock('TrackerFactory');
     $hierarchy_factory = new Tracker_HierarchyFactory($hierarchy_dao, $tracker_factory, mock('Tracker_ArtifactFactory'));
     $tracker_id = 1;
     $child_ids = array(array('id' => 11), array('id' => 12));
     $child_1 = mock('Tracker');
     $child_2 = mock('Tracker');
     stub($hierarchy_dao)->searchChildTrackerIds($tracker_id)->returns($child_ids);
     stub($tracker_factory)->getTrackerById(11)->returns($child_1);
     stub($tracker_factory)->getTrackerById(12)->returns($child_2);
     $expected_children = array($child_1, $child_2);
     $actual_children = $hierarchy_factory->getChildren($tracker_id);
     $this->assertEqual($actual_children, $expected_children);
 }