/** * @Given a sprint :sprint exists for the :project project */ public function aSprintExistsForTheProject($sprintTitle, $projectTitle) { Auth::login(User::where('username', $this->params['phabricator_username'])->first()); // this is a bit ugly. $project = Project::firstOrCreate(['title' => $projectTitle]); $phabricatorProject = $this->getOrCreatePhabricatorProjectFromTitle($sprintTitle); $existingSprint = Sprint::where('phid', $phabricatorProject['phid'])->first(); if ($existingSprint !== null && !$existingSprint->delete()) { throw new Exception('Could not delete the existing sprint.'); } $newSprint = new Sprint(['title' => $sprintTitle, 'project_id' => $project->id, 'sprint_start' => '2014-12-01', 'sprint_end' => '2014-12-14', 'phabricator_id' => $phabricatorProject['id'], 'phid' => $phabricatorProject['phid']]); if (!$phabricatorProject || !$newSprint->save()) { throw new Exception('There was a problem creating the sprint.' . $newSprint->getPhabricatorError()); } $this->phabricatorProjectID = $existingSprint ? $existingSprint->phabricator_id : $newSprint->phabricator_id; }
/** * @Given a sprint :sprint exists for the :project project */ public function aSprintExistsForTheProject($sprintTitle, $projectTitle) { Auth::login(User::where('username', $this->params['phabricator_username'])->first()); // this is a bit ugly. $project = Project::firstOrCreate(['title' => $projectTitle]); $existingSprint = Sprint::where('title', $sprintTitle)->first(); if (!$existingSprint) { $newSprint = new Sprint(['title' => $sprintTitle, 'project_id' => $project->id, 'sprint_start' => '2014-12-01', 'sprint_end' => '2014-12-14']); if (!$newSprint->save()) { throw new Exception('There was a problem creating the sprint.' . $newSprint->getPhabricatorError()); } } }