public function testCliAndCgiRunnerCanBeCreated()
 {
     $cliType = new ExerciseType(ExerciseType::CLI);
     $cgiType = new ExerciseType(ExerciseType::CGI);
     $cliExercise = $this->createMock(CliExerciseInterface::class);
     $cliExercise->expects($this->once())->method('getType')->will($this->returnValue($cliType));
     $cgiExercise = $this->createMock(CgiExerciseInterface::class);
     $cgiExercise->expects($this->once())->method('getType')->will($this->returnValue($cgiType));
     $runnerFactory = new RunnerFactory($this->container);
     $eventDispatcher = new EventDispatcher(new ResultAggregator());
     $this->assertInstanceOf(CliRunner::class, $runnerFactory->create($cliExercise, $eventDispatcher));
     $this->assertInstanceOf(CgiRunner::class, $runnerFactory->create($cgiExercise, $eventDispatcher));
 }
 /**
  * @param ExerciseInterface $exercise
  * @param string $fileName
  * @param OutputInterface $output
  * @return bool
  */
 public function run(ExerciseInterface $exercise, $fileName, OutputInterface $output)
 {
     $exercise->configure($this);
     $this->eventDispatcher->dispatch(new Event('run.start', compact('exercise', 'fileName')));
     try {
         $exitStatus = $this->runnerFactory->create($exercise, $this->eventDispatcher)->run($fileName, $output);
     } finally {
         $this->eventDispatcher->dispatch(new Event('run.finish', compact('exercise', 'fileName')));
     }
     return $exitStatus;
 }
 private function mockRunner(ExerciseInterface $exercise = null)
 {
     $this->runnerFactory->expects($this->once())->method('create')->with($exercise ? $exercise : $this->exercise, $this->eventDispatcher)->will($this->returnValue($this->runner));
 }