private function loadMilestone() { if (!isset($this->additional_criteria[self::FIELD_NAME])) { return; } if ($this->additional_criteria[self::FIELD_NAME]->getValue() == self::TOP_BACKLOG_IDENTIFIER) { $this->milestone = $this->milestone_factory->getVirtualTopMilestone($this->user, $this->project); return; } $this->milestone = $this->milestone_factory->getBareMilestoneByArtifactId($this->user, $this->additional_criteria[self::FIELD_NAME]->getValue()); $this->milestone_has_been_loaded = true; }
private function checkSubMilestoneById(Planning_Milestone $milestone, PFUser $user, $sub_milesone_id) { $sub_milestone = $this->milestone_factory->getBareMilestoneByArtifactId($user, $sub_milesone_id); if (!$sub_milestone) { throw new SubMilestoneDoesNotExistException($sub_milesone_id); } if (!$milestone->milestoneCanBeSubmilestone($sub_milestone)) { throw new ElementCannotBeSubmilestoneException($milestone->getArtifactId(), $sub_milestone->getArtifactId()); } if (!$sub_milestone->getArtifact()->userCanView()) { throw new UserCannotReadSubMilestoneException($sub_milesone_id); } if ($sub_milestone->getParent() && $sub_milestone->getParent()->getArtifactId() != $milestone->getArtifactId()) { throw new SubMilestoneAlreadyHasAParentException($sub_milesone_id); } }
public function __only__itReturnsNullWhenUserCannotSeeArtifacts() { $planning_tracker = aTracker()->withId(12)->withProject(mock('Project'))->build(); stub($this->planning_factory)->getPlanningByPlanningTracker()->returns(aPlanning()->withId(4)->build()); $artifact = aMockArtifact()->build(); stub($artifact)->userCanView($this->user)->returns(false); stub($this->artifact_factory)->getArtifactById($this->artifact_id)->returns($artifact); $this->assertNull($this->milestone_factory->getBareMilestoneByArtifactId($this->user, $this->artifact_id)); }