You are here

function RulesUnitTest::testRules in Ultimate Cron 8.2

File

tests/src/Unit/RulesUnitTest.php, line 82

Class

RulesUnitTest
Tests Drupal\ultimate_cron\CronRule.

Namespace

Drupal\Tests\ultimate_cron\Unit

Code

function testRules() {
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '0 12 * * *',
    'last_run' => '2008-01-02 12:00:00',
    'now' => '2008-01-02 12:01:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '0 12 * * *',
    'last_run' => '2008-01-02 12:00:00',
    'now' => '2008-01-02 15:00:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '0 12 * * *',
    'last_run' => '2008-01-02 12:00:00',
    'now' => '2008-01-03 11:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '0 12 * * *',
    'last_run' => '2008-01-02 12:00:00',
    'now' => '2008-01-03 12:00:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '59 23 * * *',
    'last_run' => '2008-01-02 23:59:00',
    'now' => '2008-01-03 00:00:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 * * *',
    'last_run' => '2008-01-02 23:59:00',
    'now' => '2008-01-03 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 * * *',
    'last_run' => '2008-01-02 23:59:00',
    'now' => '2008-01-04 00:00:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 * * *',
    'last_run' => '2008-01-02 23:58:00',
    'now' => '2008-01-02 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 * * *',
    'last_run' => '2008-01-02 23:58:00',
    'now' => '2008-01-03 00:00:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '59 23 * * 0',
    'last_run' => '2008-01-05 23:58:00',
    'now' => '2008-01-05 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '59 23 * * 0',
    'last_run' => '2008-01-05 23:58:00',
    'now' => '2008-01-06 00:00:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 * * 0',
    'last_run' => '2008-01-05 23:58:00',
    'now' => '2008-01-06 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 * * 0',
    'last_run' => '2008-01-05 23:58:00',
    'now' => '2008-01-07 00:00:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '29,59 23 * * 0',
    'last_run' => '2008-01-05 23:58:00',
    'now' => '2008-01-06 23:29:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '29,59 23 * * 0',
    'last_run' => '2008-01-05 23:58:00',
    'now' => '2008-01-06 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '29,59 23 * * 0',
    'last_run' => '2008-01-05 23:58:00',
    'now' => '2008-01-05 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '29,59 23 * * 0',
    'last_run' => '2008-01-05 23:58:00',
    'now' => '2008-01-06 23:58:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '29,59 23 * * 0',
    'last_run' => '2008-01-05 23:58:00',
    'now' => '2008-01-06 23:28:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '29,59 23 * * 0',
    'last_run' => '2008-01-05 23:28:00',
    'now' => '2008-01-05 23:29:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '29,59 23 * * 0',
    'last_run' => '2008-01-05 23:28:00',
    'now' => '2008-01-05 23:30:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '29,59 23 * * 0',
    'last_run' => '2008-01-05 23:28:00',
    'now' => '2008-01-05 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '29,59 23 * * 0',
    'last_run' => '2008-01-05 23:28:00',
    'now' => '2008-01-06 23:29:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '29,59 23 * * 5',
    'last_run' => '2008-02-22 23:59:00',
    'now' => '2008-02-28 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '29,59 23 * * 5',
    'last_run' => '2008-02-22 23:59:00',
    'now' => '2008-02-29 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '29,59 23 * * 5',
    'last_run' => '2008-02-22 23:59:00',
    'now' => '2008-03-01 00:00:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '59 23 * * 3',
    'last_run' => '2008-12-31 23:59:00',
    'now' => '2009-01-01 00:00:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '59 23 * * 3',
    'last_run' => '2008-12-31 23:59:00',
    'now' => '2009-01-07 00:00:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 * * 3',
    'last_run' => '2008-12-31 23:59:00',
    'now' => '2009-01-07 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 * 2 5',
    'last_run' => '2008-02-22 23:59:00',
    'now' => '2008-02-29 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 * 2 5',
    'last_run' => '2008-02-22 23:59:00',
    'now' => '2008-03-01 00:00:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '59 23 * 2 5',
    'last_run' => '2008-02-29 23:59:00',
    'now' => '2008-03-07 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '59 23 * 2 5',
    'last_run' => '2008-02-29 23:59:00',
    'now' => '2009-02-06 23:58:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 * 2 5',
    'last_run' => '2008-02-29 23:59:00',
    'now' => '2009-02-06 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '59 23 */10 * *',
    'last_run' => '2008-01-10 23:58:00',
    'now' => '2008-01-10 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 */10 * *',
    'last_run' => '2008-01-10 23:59:00',
    'now' => '2008-01-11 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 */10 * *',
    'last_run' => '2008-01-10 23:59:00',
    'now' => '2008-01-20 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 1-5,10-15 * *',
    'last_run' => '2008-01-04 23:59:00',
    'now' => '2008-01-05 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 1-5,10-15 * *',
    'last_run' => '2008-01-04 23:59:00',
    'now' => '2008-01-06 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '59 23 1-5,10-15 * *',
    'last_run' => '2008-01-05 23:59:00',
    'now' => '2008-01-06 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '59 23 1-5,10-15 * *',
    'last_run' => '2008-01-05 23:59:00',
    'now' => '2008-01-10 23:58:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 1-5,10-15 * *',
    'last_run' => '2008-01-05 23:59:00',
    'now' => '2008-01-10 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 1-5,10-15 * *',
    'last_run' => '2008-01-05 23:59:00',
    'now' => '2008-01-16 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 1-5 1 0',
    'last_run' => '2008-01-04 23:59:00',
    'now' => '2008-01-05 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 1-5 1 0',
    'last_run' => '2008-01-05 23:59:00',
    'now' => '2008-01-06 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '59 23 1-5 1 0',
    'last_run' => '2008-01-06 23:59:00',
    'now' => '2008-01-07 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '59 23 1-5 1 0',
    'last_run' => '2008-01-06 23:59:00',
    'now' => '2008-01-13 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '59 23 1-5 1 0',
    'last_run' => '2008-02-04 23:59:00',
    'now' => '2008-02-05 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '59 23 1-5 1 0',
    'last_run' => '2008-02-05 23:59:00',
    'now' => '2008-02-10 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '59 23 1-5 1 0',
    'last_run' => '2008-02-10 23:59:00',
    'now' => '2008-02-17 23:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *',
    'last_run' => '2008-02-10 08:58:00',
    'now' => '2008-02-10 08:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *',
    'last_run' => '2008-02-10 08:59:00',
    'now' => '2008-02-10 09:00:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => FALSE,
    'rules' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *',
    'last_run' => '2008-02-10 08:59:00',
    'now' => '2008-02-10 17:59:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *',
    'last_run' => '2008-02-10 08:59:00',
    'now' => '2008-02-10 18:00:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *',
    'last_run' => '2008-02-10 18:00:00',
    'now' => '2008-02-10 18:01:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *',
    'last_run' => '2008-02-10 18:00:00',
    'now' => '2008-02-10 19:00:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
  $result = $this
    ->assertRule(array(
    'result' => True,
    'rules' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *',
    'last_run' => '2008-02-10 18:00:00',
    'now' => '2008-03-10 09:00:00',
  ));
  $this
    ->assertTrue($result[0], $result[1]);
}