本文整理汇总了PHP中Cron::setDisableJob方法的典型用法代码示例。如果您正苦于以下问题:PHP Cron::setDisableJob方法的具体用法?PHP Cron::setDisableJob怎么用?PHP Cron::setDisableJob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cron
的用法示例。
在下文中一共展示了Cron::setDisableJob方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testEnableDisableJobsBySetter
/**
* Test method for enable and disable jobs by using the setter methods
*
* @covers \Liebig\Cron\Cron::setEnableJob
* @covers \Liebig\Cron\Cron::setDisableJob
* @covers \Liebig\Cron\Cron::isJobEnabled
*/
public function testEnableDisableJobsBySetter()
{
$iTest1 = 0;
$iTest2 = 0;
$iTest3 = 0;
Cron::add('test1', '* * * * *', function () use(&$iTest1) {
$iTest1++;
return false;
}, true);
Cron::add('test2', '* * * * *', function () use(&$iTest2) {
$iTest2++;
return false;
}, true);
Cron::add('test3', '* * * * *', function () use(&$iTest3) {
$iTest3++;
return false;
}, false);
$this->assertEquals(true, Cron::isJobEnabled('test1'));
$this->assertEquals(true, Cron::isJobEnabled('test2'));
$this->assertEquals(false, Cron::isJobEnabled('test3'));
$this->assertEquals(null, Cron::isJobEnabled('test4'));
Cron::run();
$this->assertEquals(1, $iTest1);
$this->assertEquals(1, $iTest2);
$this->assertEquals(0, $iTest3);
$this->assertEquals(1, \Liebig\Cron\Models\Manager::count());
$this->assertEquals(2, \Liebig\Cron\Models\Job::count());
$this->assertEquals(true, Cron::setEnableJob('test3'));
$this->assertEquals(true, Cron::isJobEnabled('test1'));
$this->assertEquals(true, Cron::isJobEnabled('test2'));
$this->assertEquals(true, Cron::isJobEnabled('test3'));
$this->assertEquals(null, Cron::isJobEnabled('test4'));
Cron::run();
$this->assertEquals(2, $iTest1);
$this->assertEquals(2, $iTest2);
$this->assertEquals(1, $iTest3);
$this->assertEquals(2, \Liebig\Cron\Models\Manager::count());
$this->assertEquals(5, \Liebig\Cron\Models\Job::count());
$this->assertEquals(true, Cron::setDisableJob('test1'));
$this->assertEquals(true, Cron::setDisableJob('test3'));
$this->assertEquals(false, Cron::setDisableJob('noSuchJob'));
$this->assertEquals(false, Cron::isJobEnabled('test1'));
$this->assertEquals(true, Cron::isJobEnabled('test2'));
$this->assertEquals(false, Cron::isJobEnabled('test3'));
$this->assertEquals(null, Cron::isJobEnabled('test4'));
Cron::run();
$this->assertEquals(2, $iTest1);
$this->assertEquals(3, $iTest2);
$this->assertEquals(1, $iTest3);
$this->assertEquals(3, \Liebig\Cron\Models\Manager::count());
$this->assertEquals(6, \Liebig\Cron\Models\Job::count());
$this->assertEquals(true, Cron::setEnableJob('test2', false));
$this->assertEquals(false, Cron::isJobEnabled('test1'));
$this->assertEquals(false, Cron::isJobEnabled('test2'));
$this->assertEquals(false, Cron::isJobEnabled('test3'));
$this->assertEquals(null, Cron::isJobEnabled('test4'));
Cron::run();
$this->assertEquals(2, $iTest1);
$this->assertEquals(3, $iTest2);
$this->assertEquals(1, $iTest3);
$this->assertEquals(4, \Liebig\Cron\Models\Manager::count());
$this->assertEquals(6, \Liebig\Cron\Models\Job::count());
$this->assertEquals(true, Cron::setEnableJob('test1', true));
$this->assertEquals(true, Cron::isJobEnabled('test1'));
$this->assertEquals(false, Cron::isJobEnabled('test2'));
$this->assertEquals(false, Cron::isJobEnabled('test3'));
$this->assertEquals(null, Cron::isJobEnabled('test4'));
Cron::run();
$this->assertEquals(3, $iTest1);
$this->assertEquals(3, $iTest2);
$this->assertEquals(1, $iTest3);
$this->assertEquals(5, \Liebig\Cron\Models\Manager::count());
$this->assertEquals(7, \Liebig\Cron\Models\Job::count());
}