/** * Put content in a given milestone * * Put the new content of a given milestone. * * @url PUT {id}/content * * @param int $id Id of the milestone * @param array $ids Ids of backlog items {@from body} * * @throws 400 * @throws 403 * @throws 404 */ protected function putContent($id, array $ids) { $current_user = $this->getCurrentUser(); $milestone = $this->getMilestoneById($current_user, $id); $this->checkIfUserCanChangePrioritiesInMilestone($milestone, $current_user); try { $this->milestone_validator->validateArtifactsFromBodyContent($ids, $milestone, $current_user); $this->milestone_content_updater->updateMilestoneContent($ids, $current_user, $milestone); } catch (ArtifactDoesNotExistException $exception) { throw new RestException(404, $exception->getMessage()); } catch (ArtifactIsNotInBacklogTrackerException $exception) { throw new RestException(404, $exception->getMessage()); } catch (ArtifactIsClosedOrAlreadyPlannedInAnotherMilestone $exception) { throw new RestException(400, $exception->getMessage()); } catch (IdsFromBodyAreNotUniqueException $exception) { throw new RestException(400, $exception->getMessage()); } catch (Tracker_NoChangeException $exception) { //Do nothing } try { $this->artifactlink_updater->setOrderWithHistoryChangeLogging($ids, $id, $milestone->getProject()->getId()); } catch (ItemListedTwiceException $exception) { throw new RestException(400, $exception->getMessage()); } $this->sendAllowHeaderForContent(); }
public function itThrowsAnExceptionIfArtifactIsClosedOrAlreadyPlannedInAnotherMilestone() { $this->expectException('Tuleap\\AgileDashboard\\REST\\v1\\ArtifactIsClosedOrAlreadyPlannedInAnotherMilestone'); $this->unplanned_collection->push($this->unplanned_item); stub($this->planning_factory)->getBacklogTrackersIds($this->milestone->getPlanning()->getId())->returns(array(555, 666)); stub($this->tracker_artifact_factory)->getArtifactById(102)->returns($this->artifact1); stub($this->tracker_artifact_factory)->getArtifactById(174)->returns($this->artifact2); $this->milestone_resource_validator->validateArtifactsFromBodyContent($this->ids, $this->milestone, $this->user); }