public function setUp() { parent::setUp(); $this->dao = mock('AgileDashboard_BacklogItemDao'); $this->artifact_factory = mock('Tracker_ArtifactFactory'); $this->form_element_factory = mock('Tracker_FormElementFactory'); $this->milestone_factory = mock('Planning_MilestoneFactory'); $this->planning_factory = mock('PlanningFactory'); $this->backlog_item_builder = new AgileDashboard_Milestone_Backlog_BacklogItemBuilder(); $this->user = mock('PFUser'); $planning = mock('Planning'); stub($planning)->getBacklogTrackers()->returns(array(mock('Tracker'))); stub($planning)->getPlanningTracker()->returns(mock('Tracker')); $artifact = aMockArtifact()->build(); $this->milestone = aMilestone()->withArtifact($artifact)->withPlanning($planning)->build(); $this->factory = partial_mock('AgileDashboard_Milestone_Backlog_BacklogItemCollectionFactory', array('userCanReadBacklogTitleField', 'userCanReadBacklogStatusField', 'getInitialEffortField'), array($this->dao, $this->artifact_factory, $this->form_element_factory, $this->milestone_factory, $this->planning_factory, $this->backlog_item_builder)); stub($this->factory)->userCanReadBacklogTitleField()->returns(true); stub($this->factory)->userCanReadBacklogStatusField()->returns(true); $this->tracker1 = mock('Tracker'); $this->tracker2 = mock('Tracker'); $this->tracker3 = mock('Tracker'); $this->story1 = anArtifact()->userCanView($this->user)->withTitle('story 1')->withId($this->open_story_id)->withTracker($this->tracker1)->build(); $this->story2 = anArtifact()->userCanView($this->user)->withTitle('story 2')->withId($this->open_unplanned_story_id)->withTracker($this->tracker2)->build(); $this->story3 = anArtifact()->userCanView($this->user)->withTitle('story 3')->withId($this->closed_story_id)->withTracker($this->tracker3)->build(); $backlog_items = new AgileDashboard_Milestone_Backlog_DescendantItemsCollection(); $backlog_items->push($this->story1); $backlog_items->push($this->story2); $backlog_items->push($this->story3); $this->backlog_strategy = stub('AgileDashboard_Milestone_Backlog_BacklogStrategy')->getArtifacts($this->user)->returns($backlog_items); stub($this->backlog_strategy)->getMilestoneBacklogArtifactsTracker()->returns(mock('Tracker')); $this->redirect_to_self = 'whatever'; stub($this->dao)->getArtifactsSemantics()->returnsDar(array('id' => $this->open_story_id, Tracker_Semantic_Title::NAME => 'Story is open', Tracker_Semantic_Status::NAME => AgileDashboard_BacklogItemDao::STATUS_OPEN), array('id' => $this->open_unplanned_story_id, Tracker_Semantic_Title::NAME => 'Story is open and unplanned', Tracker_Semantic_Status::NAME => AgileDashboard_BacklogItemDao::STATUS_OPEN), array('id' => $this->closed_story_id, Tracker_Semantic_Title::NAME => 'Story is closed', Tracker_Semantic_Status::NAME => AgileDashboard_BacklogItemDao::STATUS_CLOSED)); $sub_milestone1 = stub('Planning_Milestone')->getArtifactId()->returns(121); $sub_milestone2 = stub('Planning_Milestone')->getArtifactId()->returns(436); stub($this->milestone_factory)->getSubMilestones()->returns(array($sub_milestone1, $sub_milestone2)); stub($this->artifact_factory)->getParents()->returns(array()); }
/** * @return AgileDashboard_Milestone_Backlog_DescendantItemsCollection */ private function getItemsForUser(PFUser $user, DataAccessResult $result, $found_rows) { $items = new AgileDashboard_Milestone_Backlog_DescendantItemsCollection(); foreach ($result as $row) { $item = $this->artifact_factory->getInstanceFromRow($row); if ($item->userCanView($user)) { $items->push($item); } } $items->setTotalAvaialableSize($found_rows); return $items; }
public function itCanDealWithMultipleCallWithDifferentMilestones() { $backlog_items = new AgileDashboard_Milestone_Backlog_DescendantItemsCollection(); $backlog_items->push($this->artifact_2); $backlog_items->push($this->artifact_1); $backlog_items->push($this->artifact_3); stub($this->strategy_1)->getArtifacts($this->user)->returns($backlog_items); $backlog_items = new AgileDashboard_Milestone_Backlog_DescendantItemsCollection(); $backlog_items->push($this->artifact_4); $backlog_items->push($this->artifact_5); $backlog_items->push($this->artifact_6); stub($this->strategy_2)->getArtifacts($this->user)->returns($backlog_items); stub($this->strategy_2)->getArtifacts($this->user)->returns($backlog_items); expect($this->strategy_factory)->getBacklogStrategy()->count(2); $this->assertEqual($this->sequence_id_manager->getSequenceId($this->user, $this->milestone_1, $this->artifact_id_1), 2); $this->assertEqual($this->sequence_id_manager->getSequenceId($this->user, $this->milestone_2, $this->artifact_id_6), 3); $this->assertEqual($this->sequence_id_manager->getSequenceId($this->user, $this->milestone_1, $this->artifact_id_2), 1); }