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