本文整理汇总了PHP中Robo\Result::stopOnFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Result::stopOnFail方法的具体用法?PHP Result::stopOnFail怎么用?PHP Result::stopOnFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Robo\Result
的用法示例。
在下文中一共展示了Result::stopOnFail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testStopOnFail
public function testStopOnFail()
{
$exceptionClass = false;
$task = new ResultDummyTask();
Result::$stopOnFail = true;
$result = Result::success($task, "Something that worked");
try {
$result = Result::error($task, "Something that did not work");
// stopOnFail will cause Result::error() to throw an exception,
// so we will never get here. If we did, the assert below would fail.
$this->assertTrue($result->wasSuccessful());
$this->assertTrue(false);
} catch (\Exception $e) {
$exceptionClass = get_class($e);
}
$this->assertEquals(TaskExitException::class, $exceptionClass);
$this->assertTrue($result->wasSuccessful());
/*
// This gives an error:
// Exception of class Robo\Exception\TaskExitException expected to
// be thrown, but PHPUnit_Framework_Exception caught
// This happens whether or not the expected exception is thrown
$this->guy->expectException(TaskExitException::class, function() {
// $result = Result::error($task, "Something that did not work");
$result = Result::success($task, "Something that worked");
});
*/
Result::$stopOnFail = false;
}
示例2: execute
function execute($opts)
{
$answer = $this->ask("Bulding Docker container takes some time, you can use already provisioned image instead.\nDo you want to continue? (y/n)");
if (trim(strtolower($answer)) != 'y') {
return;
}
Result::$stopOnFail = true;
$recipes = $opts['recipes'] ?: implode(',', Config::$travisRecipes);
(new BuildRecipe('base'))->tag('roboci_base')->run();
$res = (new DockerRun('base'))->option('-i')->option('--privileged')->exec('/usr/bin/chef-solo -j /travis.json -o ' . $recipes)->run();
$this->taskDeleteDir(Config::$buildDir)->run();
$data = $res->getData();
$this->yell("Container built in successfully. Run `docker commit {$data['cid']} yourname/imagename` to save it");
}
示例3: stopOnFail
protected function stopOnFail($stopOnFail = true)
{
Result::$stopOnFail = $stopOnFail;
}