本文整理匯總了PHP中Cron::setLaravelLogging方法的典型用法代碼示例。如果您正苦於以下問題:PHP Cron::setLaravelLogging方法的具體用法?PHP Cron::setLaravelLogging怎麽用?PHP Cron::setLaravelLogging使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cron
的用法示例。
在下文中一共展示了Cron::setLaravelLogging方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testLaravelLogging
/**
* Test method for Laravals build in logging value
*
* @covers \Liebig\Cron\Cron::setLaravelLogging
* @covers \Liebig\Cron\Cron::isLaravelLogging
*/
public function testLaravelLogging()
{
$this->assertEquals(true, Cron::isLaravelLogging());
$this->assertEquals(null, Cron::getLogger());
$i = 0;
$tester = $this;
Log::listen(function ($level, $message) use(&$i, $tester) {
switch ($i) {
case 0:
$tester->assertEquals('notice', $level);
$tester->assertEquals('Cron run with manager id 1 has no previous managers.', $message);
break;
case 1:
$tester->assertEquals('info', $level);
$tester->assertEquals('The cron run with the manager id 1 was finished without errors.', $message);
break;
case 2:
$tester->assertEquals('error', $level);
$tester->assertEquals('Job with the name test1 was run with errors.', $message);
break;
case 3:
$tester->assertEquals('error', $level);
break;
case 4:
$tester->assertEquals('error', $level);
$tester->assertEquals('The cron run with the manager id 2 was finished with 1 errors.', $message);
break;
default:
throw new \UnexpectedValueException('Log listener is called to often - test case failed');
}
$i++;
});
Cron::run();
Cron::add('test1', '* * * * *', function () {
return 'test error';
});
Cron::run();
Cron::setLaravelLogging(false);
Cron::run();
// Check if the Log is called 5 times
$this->assertEquals(5, $i);
}