Example #1
0
 public function testExeceptionIsThrownIfParameterDoesNotExist()
 {
     $this->expectException(InvalidArgumentException::class);
     $this->expectExceptionMessage('Parameter: "cool" does not exist');
     $e = new Event('super-sweet-event-with-cool-params');
     $e->getParameter('cool');
 }
 /**
  * @param Event $event
  */
 public function __invoke(Event $event)
 {
     $exercise = $event->getParameter('exercise');
     if ($exercise instanceof SelfCheck) {
         $this->results->add($exercise->check($event->getParameter('fileName')));
     }
 }
 /**
  * @param Event $event
  */
 public function revert(Event $event)
 {
     if (null === $this->originalCode) {
         throw new RuntimeException('Can only revert previously patched code');
     }
     file_put_contents($event->getParameter('fileName'), $this->originalCode);
 }
 /**
  * @param Event $event
  */
 public function __invoke(Event $event)
 {
     /** @var CommandDefinition $command */
     $command = $event->getParameter('command');
     if (!in_array($command->getName(), ['verify', 'run'])) {
         return;
     }
     $currentExercise = $this->exerciseRepository->findByName($this->userState->getCurrentExercise());
     $this->runnerManager->configureInput($currentExercise, $command);
 }
 /**
  * @param Event $event
  */
 public function __invoke(Event $event)
 {
     /** @var CommandDefinition $command */
     $command = $event->getParameter('command');
     if (!in_array($command->getName(), ['verify', 'run', 'print'])) {
         return;
     }
     if (!$this->userState->isAssignedExercise()) {
         throw new \RuntimeException('No active exercise. Select one from the menu');
     }
 }
 /**
  * @param Event $event
  */
 public function __invoke(Event $event)
 {
     $solution = $event->getParameter('exercise')->getSolution();
     if ($solution->hasComposerFile()) {
         //prepare composer deps
         //only install if composer.lock file not available
         if (!file_exists(sprintf('%s/vendor', $solution->getBaseDirectory()))) {
             $process = new Process(sprintf('%s install --no-interaction', $this->locateComposer()), $solution->getBaseDirectory());
             $process->run();
         }
     }
 }
 /**
  * @param string $name
  * @param ExerciseInterface $exercise
  * @param Input $input
  * @param array $parameters
  */
 public function __construct($name, ExerciseInterface $exercise, Input $input, array $parameters = [])
 {
     $parameters['input'] = $input;
     $parameters['exercise'] = $exercise;
     parent::__construct($name, $parameters);
     $this->exercise = $exercise;
     $this->input = $input;
 }
 /**
  * @param string $name
  * @param ArrayObject $args
  * @param array $parameters
  */
 public function __construct($name, ArrayObject $args, array $parameters = [])
 {
     $parameters['args'] = $args;
     parent::__construct($name, $parameters);
     $this->args = $args;
 }
Example #9
0
 /**
  * @param string $name
  * @param RequestInterface $request
  * @param array $parameters
  */
 public function __construct($name, RequestInterface $request, array $parameters = [])
 {
     $parameters['request'] = $request;
     parent::__construct($name, $parameters);
     $this->request = $request;
 }