/** * @param ExerciseRunnerEvent $event */ public function __invoke(ExerciseRunnerEvent $event) { if (!$event->getInput()->hasArgument('program')) { return; } $program = $event->getInput()->getArgument('program'); if (file_exists($program)) { $event->getInput()->setArgument('program', realpath($program)); } }
/** * @param ExerciseRunnerEvent $event */ public function revert(ExerciseRunnerEvent $event) { if (null === $this->originalCode) { throw new RuntimeException('Can only revert previously patched code'); } file_put_contents($event->getInput()->getArgument('program'), $this->originalCode); }
public function testGetters() { $exercise = new CliExerciseImpl(); $input = new Input('app'); $event = new ExerciseRunnerEvent('Some Event', $exercise, $input, ['number' => 1]); self::assertSame($exercise, $event->getExercise()); self::assertSame($input, $event->getInput()); self::assertEquals(['exercise' => $exercise, 'input' => $input, 'number' => 1], $event->getParameters()); }