Inheritance: extends Doctrine\Common\Collections\ArrayCollection
Exemple #1
0
 /**
  * @param ContextInterface $context
  *
  * @throws FailureException if any of the tasks fail
  */
 public function run(ContextInterface $context)
 {
     $failures = false;
     $messages = array();
     $tasks = $this->tasks->filterByContext($context)->sortByPriority($this->grumPHP);
     $this->eventDispatcher->dispatch(RunnerEvents::RUNNER_RUN, new RunnerEvent($tasks));
     foreach ($tasks as $task) {
         try {
             $this->eventDispatcher->dispatch(TaskEvents::TASK_RUN, new TaskEvent($task));
             $task->run($context);
             $this->eventDispatcher->dispatch(TaskEvents::TASK_COMPLETE, new TaskEvent($task));
         } catch (RuntimeException $e) {
             $this->eventDispatcher->dispatch(TaskEvents::TASK_FAILED, new TaskFailedEvent($task, $e));
             $messages[] = $e->getMessage();
             $failures = true;
             if ($this->grumPHP->stopOnFailure()) {
                 break;
             }
         }
     }
     if ($failures) {
         $this->eventDispatcher->dispatch(RunnerEvents::RUNNER_FAILED, new RunnerFailedEvent($tasks, $messages));
         throw new FailureException(implode(PHP_EOL, $messages));
     }
     $this->eventDispatcher->dispatch(RunnerEvents::RUNNER_COMPLETE, new RunnerEvent($tasks));
 }
 function it_starts_progress(ProgressBar $progressBar, RunnerEvent $event, TasksCollection $tasks)
 {
     $tasks->count()->willReturn(2);
     $event->getTasks()->willReturn($tasks);
     $progressBar->setFormat(Argument::type('string'))->shouldBeCalled();
     $progressBar->setOverwrite(false)->shouldBeCalled();
     $progressBar->setMessage(Argument::type('string'))->shouldBeCalled();
     $progressBar->start(2)->shouldBeCalled();
     $this->startProgress($event);
 }
Exemple #3
0
 /**
  * @param ContextInterface $context
  *
  * @throws FailureException if any of the tasks fail
  */
 public function run(ContextInterface $context)
 {
     $failures = false;
     $messages = array();
     $tasks = $this->tasks->filterByContext($context);
     foreach ($tasks as $task) {
         try {
             $task->run($context);
         } catch (RuntimeException $e) {
             $failures = true;
             $messages[] = $e->getMessage();
         }
     }
     if ($failures) {
         throw new FailureException(implode(PHP_EOL, $messages));
     }
 }
Exemple #4
0
 /**
  * @param ContextInterface $context
  *
  * @return TaskResultCollection
  */
 public function run(ContextInterface $context)
 {
     $tasks = $this->tasks->filterByContext($context)->sortByPriority($this->grumPHP);
     $taskResults = new TaskResultCollection();
     $this->eventDispatcher->dispatch(RunnerEvents::RUNNER_RUN, new RunnerEvent($tasks, $context, $taskResults));
     foreach ($tasks as $task) {
         try {
             $taskResult = $this->runTask($task, $context);
         } catch (RuntimeException $e) {
             $taskResult = TaskResult::createFailed($task, $context, $e->getMessage());
         }
         $taskResults->add($taskResult);
         if (!$taskResult->isPassed() && $taskResult->isBlocking() && $this->grumPHP->stopOnFailure()) {
             break;
         }
     }
     if ($taskResults->isFailed()) {
         $this->eventDispatcher->dispatch(RunnerEvents::RUNNER_FAILED, new RunnerFailedEvent($tasks, $context, $taskResults));
         return $taskResults;
     }
     $this->eventDispatcher->dispatch(RunnerEvents::RUNNER_COMPLETE, new RunnerEvent($tasks, $context, $taskResults));
     return $taskResults;
 }