/** * @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); }
public function execute(InputInterface $input, OutputInterface $output) { $name = $input->getArgument('name'); $trainingType = $input->getArgument('training_type'); $type = $input->getArgument('type'); $nbWeek = $input->getArgument('nb_week'); $plan = new Plan(); $plan->setName($name); $plan->setTrainingType($trainingType); $plan->setNbWeek($nbWeek); $plan->setWeekType($type); $planBuilt = $this->getContainer()->get('nb_run_training.builder.plan')->build($plan); dump($planBuilt); }