当前位置: 首页>>代码示例>>PHP>>正文


PHP GrumPHP::stopOnFailure方法代码示例

本文整理汇总了PHP中GrumPHP\Configuration\GrumPHP::stopOnFailure方法的典型用法代码示例。如果您正苦于以下问题:PHP GrumPHP::stopOnFailure方法的具体用法?PHP GrumPHP::stopOnFailure怎么用?PHP GrumPHP::stopOnFailure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GrumPHP\Configuration\GrumPHP的用法示例。


在下文中一共展示了GrumPHP::stopOnFailure方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * @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));
 }
开发者ID:eltonoliveira,项目名称:grumphp,代码行数:31,代码来源:TaskRunner.php

示例2: run

 /**
  * @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;
 }
开发者ID:Big-Shark,项目名称:grumphp,代码行数:28,代码来源:TaskRunner.php

示例3:

 function it_does_not_stop_on_a_non_blocking_failed_task_if_stop_on_failure(GrumPHP $grumPHP, TaskInterface $task1, TaskInterface $task2, ContextInterface $context)
 {
     $grumPHP->stopOnFailure()->willReturn(true);
     $grumPHP->isBlockingTask('task1')->willReturn(false);
     $task1->run($context)->willReturn(TaskResult::createFailed($task1->getWrappedObject(), $context->getWrappedObject(), ''));
     $task2->run($context)->shouldBeCalled();
     $this->run($context)->shouldHaveCount(2);
 }
开发者ID:Big-Shark,项目名称:grumphp,代码行数:8,代码来源:TaskRunnerSpec.php


注:本文中的GrumPHP\Configuration\GrumPHP::stopOnFailure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。