Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     //get/set the courseId and newAcademicYear arguments
     $courseId = $input->getArgument('courseId');
     $newAcademicYear = $input->getArgument('newAcademicYear');
     //roll it over to build the newCourse object
     $newCourse = $this->service->rolloverCourse($courseId, $newAcademicYear, $input->getOptions());
     //output message with the new courseId on success
     $output->writeln("This course has been rolled over. The new course id is {$newCourse->getId()}.");
 }
Exemplo n.º 2
0
 public function testRolloverFailsOnStartDateOnDifferentDay()
 {
     $course = $this->createTestCourse();
     $course->setSchool(new School());
     $newCourse = m::mock('Ilios\\CoreBundle\\Entity\\CourseInterface');
     $newCourse->shouldIgnoreMissing();
     $newYear = $course->getYear() + 1;
     $this->courseManager->shouldReceive('findOneBy')->withArgs([['id' => $course->getId()]])->andReturn($course)->once();
     $this->courseManager->shouldReceive('findBy')->withArgs([['title' => $course->getTitle(), 'year' => $newYear]])->andReturn(false)->once();
     $newStartDate = clone $course->getStartDate();
     $newStartDate->add(new \DateInterval('P1Y2D'));
     $this->setExpectedException(\Exception::class, "The new start date must take place on the same day of the week as the original course start date");
     $this->service->rolloverCourse($course->getId(), $newYear, ['new-start-date' => $newStartDate->format('c')]);
 }