本文整理匯總了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);
}