本文整理汇总了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));
}
示例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;
}
示例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);
}