/** * @param Plan $plan */ private function checkTrainingType(Plan $plan) { $trainingTypes = $this->trainingTypeManager->findAll(); if (!in_array($plan->getTrainingType(), $trainingTypes)) { throw new \Exception(sprintf('%s is not a valide training type, choosing which %s', $plan->getTrainingType(), implode(', ', $trainingTypes))); } }
function it_build_a_plan(Plan $plan, TrainingTypeManager $trainingTypeManager, WeekBuilder $weekBuilder, Week $week, AbstractSession $session) { $plan->getTrainingType()->willReturn(10); $plan->getNbWeek()->willReturn(1); $plan->getWeekType()->willReturn('week_3'); $week->getSessions()->willReturn(array($session)); $weekBuilder->build('week_3', 10)->willReturn($week); $plan->addWeek($week)->shouldBeCalled(); $trainingTypeManager->findAll()->willReturn(array(10, 21, 42)); $this->build($plan); }