You are here

function test_elysia_cron_should_run in Elysia Cron 7

Same name in this branch
  1. 7 elysia_cron_scheduler.inc \test_elysia_cron_should_run()
  2. 7 elysia_cron_scheduler_old.inc \test_elysia_cron_should_run()
Same name and namespace in other branches
  1. 5.2 elysia_cron_scheduler.inc \test_elysia_cron_should_run()
  2. 5.2 elysia_cron_scheduler_old.inc \test_elysia_cron_should_run()
  3. 5 elysia_cron_scheduler.inc \test_elysia_cron_should_run()
  4. 5 elysia_cron_scheduler_old.inc \test_elysia_cron_should_run()
  5. 6.2 elysia_cron_scheduler.inc \test_elysia_cron_should_run()
  6. 6.2 elysia_cron_scheduler_old.inc \test_elysia_cron_should_run()
  7. 6 elysia_cron_scheduler.inc \test_elysia_cron_should_run()
  8. 6 elysia_cron_scheduler_old.inc \test_elysia_cron_should_run()
  9. 7.2 elysia_cron_scheduler.inc \test_elysia_cron_should_run()

File

./elysia_cron_scheduler_old.inc, line 160

Code

function test_elysia_cron_should_run() {
  dprint("Start test");
  $start = microtime(true);

  //mktime: hr min sec mon day yr
  dprint(" 1." . (false == elysia_cron_should_run(array(
    'rule' => '0 12 * * *',
    'last_run' => mktime(12, 0, 0, 1, 2, 2008),
  ), mktime(12, 01, 0, 1, 2, 2008))));
  dprint(" 2." . (false == elysia_cron_should_run(array(
    'rule' => '0 12 * * *',
    'last_run' => mktime(12, 0, 0, 1, 2, 2008),
  ), mktime(15, 00, 0, 1, 2, 2008))));
  dprint(" 3." . (false == elysia_cron_should_run(array(
    'rule' => '0 12 * * *',
    'last_run' => mktime(12, 0, 0, 1, 2, 2008),
  ), mktime(11, 59, 0, 1, 3, 2008))));
  dprint(" 4." . (true == elysia_cron_should_run(array(
    'rule' => '0 12 * * *',
    'last_run' => mktime(12, 0, 0, 1, 2, 2008),
  ), mktime(12, 00, 0, 1, 3, 2008))));
  dprint(" 5." . (false == elysia_cron_should_run(array(
    'rule' => '59 23 * * *',
    'last_run' => mktime(23, 59, 0, 1, 2, 2008),
  ), mktime(0, 00, 0, 1, 3, 2008))));
  dprint(" 6." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 * * *',
    'last_run' => mktime(23, 59, 0, 1, 2, 2008),
  ), mktime(23, 59, 0, 1, 3, 2008))));
  dprint(" 7." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 * * *',
    'last_run' => mktime(23, 59, 0, 1, 2, 2008),
  ), mktime(0, 00, 0, 1, 4, 2008))));
  dprint(" 8." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 * * *',
    'last_run' => mktime(23, 58, 0, 1, 2, 2008),
  ), mktime(23, 59, 0, 1, 2, 2008))));
  dprint(" 9." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 * * *',
    'last_run' => mktime(23, 58, 0, 1, 2, 2008),
  ), mktime(0, 0, 0, 1, 3, 2008))));
  dprint("10." . (false == elysia_cron_should_run(array(
    'rule' => '59 23 * * 0',
    'last_run' => mktime(23, 58, 0, 1, 5, 2008),
  ), mktime(23, 59, 0, 1, 5, 2008))));
  dprint("11." . (false == elysia_cron_should_run(array(
    'rule' => '59 23 * * 0',
    'last_run' => mktime(23, 58, 0, 1, 5, 2008),
  ), mktime(0, 0, 0, 1, 6, 2008))));
  dprint("12." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 * * 0',
    'last_run' => mktime(23, 58, 0, 1, 5, 2008),
  ), mktime(23, 59, 0, 1, 6, 2008))));
  dprint("13." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 * * 0',
    'last_run' => mktime(23, 58, 0, 1, 5, 2008),
  ), mktime(00, 00, 0, 1, 7, 2008))));
  dprint("14." . (true == elysia_cron_should_run(array(
    'rule' => '29,59 23 * * 0',
    'last_run' => mktime(23, 58, 0, 1, 5, 2008),
  ), mktime(23, 29, 0, 1, 6, 2008))));
  dprint("15." . (true == elysia_cron_should_run(array(
    'rule' => '29,59 23 * * 0',
    'last_run' => mktime(23, 58, 0, 1, 5, 2008),
  ), mktime(23, 59, 0, 1, 6, 2008))));
  dprint("16." . (false == elysia_cron_should_run(array(
    'rule' => '29,59 23 * * 0',
    'last_run' => mktime(23, 58, 0, 1, 5, 2008),
  ), mktime(23, 59, 0, 1, 5, 2008))));
  dprint("17." . (true == elysia_cron_should_run(array(
    'rule' => '29,59 23 * * 0',
    'last_run' => mktime(23, 58, 0, 1, 5, 2008),
  ), mktime(23, 58, 0, 1, 6, 2008))));
  dprint("18." . (false == elysia_cron_should_run(array(
    'rule' => '29,59 23 * * 0',
    'last_run' => mktime(23, 58, 0, 1, 5, 2008),
  ), mktime(23, 28, 0, 1, 6, 2008))));
  dprint("19." . (false == elysia_cron_should_run(array(
    'rule' => '29,59 23 * * 0',
    'last_run' => mktime(23, 28, 0, 1, 5, 2008),
  ), mktime(23, 29, 0, 1, 5, 2008))));
  dprint("20." . (false == elysia_cron_should_run(array(
    'rule' => '29,59 23 * * 0',
    'last_run' => mktime(23, 28, 0, 1, 5, 2008),
  ), mktime(23, 30, 0, 1, 5, 2008))));
  dprint("21." . (false == elysia_cron_should_run(array(
    'rule' => '29,59 23 * * 0',
    'last_run' => mktime(23, 28, 0, 1, 5, 2008),
  ), mktime(23, 59, 0, 1, 5, 2008))));
  dprint("22." . (true == elysia_cron_should_run(array(
    'rule' => '29,59 23 * * 0',
    'last_run' => mktime(23, 28, 0, 1, 5, 2008),
  ), mktime(23, 29, 0, 1, 6, 2008))));
  dprint("23." . (false == elysia_cron_should_run(array(
    'rule' => '29,59 23 * * 5',
    'last_run' => mktime(23, 59, 0, 2, 22, 2008),
  ), mktime(23, 59, 0, 2, 28, 2008))));
  dprint("24." . (true == elysia_cron_should_run(array(
    'rule' => '29,59 23 * * 5',
    'last_run' => mktime(23, 59, 0, 2, 22, 2008),
  ), mktime(23, 59, 0, 2, 29, 2008))));
  dprint("25." . (true == elysia_cron_should_run(array(
    'rule' => '29,59 23 * * 5',
    'last_run' => mktime(23, 59, 0, 2, 22, 2008),
  ), mktime(0, 0, 0, 3, 1, 2008))));
  dprint("26." . (false == elysia_cron_should_run(array(
    'rule' => '59 23 * * 3',
    'last_run' => mktime(23, 59, 0, 12, 31, 2008),
  ), mktime(0, 0, 0, 1, 1, 2009))));
  dprint("27." . (false == elysia_cron_should_run(array(
    'rule' => '59 23 * * 3',
    'last_run' => mktime(23, 59, 0, 12, 31, 2008),
  ), mktime(0, 0, 0, 1, 7, 2009))));
  dprint("28." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 * * 3',
    'last_run' => mktime(23, 59, 0, 12, 31, 2008),
  ), mktime(23, 59, 0, 1, 7, 2009))));
  dprint("29." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 * 2 5',
    'last_run' => mktime(23, 59, 0, 2, 22, 2008),
  ), mktime(23, 59, 0, 2, 29, 2008))));
  dprint("30." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 * 2 5',
    'last_run' => mktime(23, 59, 0, 2, 22, 2008),
  ), mktime(0, 0, 0, 3, 1, 2008))));
  dprint("31." . (false == elysia_cron_should_run(array(
    'rule' => '59 23 * 2 5',
    'last_run' => mktime(23, 59, 0, 2, 29, 2008),
  ), mktime(23, 59, 0, 3, 7, 2008))));
  dprint("32." . (false == elysia_cron_should_run(array(
    'rule' => '59 23 * 2 5',
    'last_run' => mktime(23, 59, 0, 2, 29, 2008),
  ), mktime(23, 58, 0, 2, 6, 2009))));
  dprint("33." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 * 2 5',
    'last_run' => mktime(23, 59, 0, 2, 29, 2008),
  ), mktime(23, 59, 0, 2, 6, 2009))));
  dprint("34." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 *' . '/10 * *',
    'last_run' => mktime(23, 58, 0, 1, 10, 2008),
  ), mktime(23, 59, 0, 1, 10, 2008))));
  dprint("35." . (false == elysia_cron_should_run(array(
    'rule' => '59 23 *' . '/10 * *',
    'last_run' => mktime(23, 59, 0, 1, 10, 2008),
  ), mktime(23, 59, 0, 1, 11, 2008))));
  dprint("36." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 *' . '/10 * *',
    'last_run' => mktime(23, 59, 0, 1, 10, 2008),
  ), mktime(23, 59, 0, 1, 20, 2008))));
  dprint("37." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 1-5,10-15 * *',
    'last_run' => mktime(23, 59, 0, 1, 4, 2008),
  ), mktime(23, 59, 0, 1, 5, 2008))));
  dprint("38." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 1-5,10-15 * *',
    'last_run' => mktime(23, 59, 0, 1, 4, 2008),
  ), mktime(23, 59, 0, 1, 6, 2008))));
  dprint("39." . (false == elysia_cron_should_run(array(
    'rule' => '59 23 1-5,10-15 * *',
    'last_run' => mktime(23, 59, 0, 1, 5, 2008),
  ), mktime(23, 59, 0, 1, 6, 2008))));
  dprint("40." . (false == elysia_cron_should_run(array(
    'rule' => '59 23 1-5,10-15 * *',
    'last_run' => mktime(23, 59, 0, 1, 5, 2008),
  ), mktime(23, 58, 0, 1, 10, 2008))));
  dprint("41." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 1-5,10-15 * *',
    'last_run' => mktime(23, 59, 0, 1, 5, 2008),
  ), mktime(23, 59, 0, 1, 10, 2008))));
  dprint("42." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 1-5,10-15 * *',
    'last_run' => mktime(23, 59, 0, 1, 5, 2008),
  ), mktime(23, 59, 0, 1, 16, 2008))));
  dprint("43." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 1-5 1 0',
    'last_run' => mktime(23, 59, 0, 1, 4, 2008),
  ), mktime(23, 59, 0, 1, 5, 2008))));
  dprint("44." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 1-5 1 0',
    'last_run' => mktime(23, 59, 0, 1, 5, 2008),
  ), mktime(23, 59, 0, 1, 6, 2008))));
  dprint("45." . (false == elysia_cron_should_run(array(
    'rule' => '59 23 1-5 1 0',
    'last_run' => mktime(23, 59, 0, 1, 6, 2008),
  ), mktime(23, 59, 0, 1, 7, 2008))));
  dprint("46." . (true == elysia_cron_should_run(array(
    'rule' => '59 23 1-5 1 0',
    'last_run' => mktime(23, 59, 0, 1, 6, 2008),
  ), mktime(23, 59, 0, 1, 13, 2008))));
  dprint("47." . (false == elysia_cron_should_run(array(
    'rule' => '59 23 1-5 1 0',
    'last_run' => mktime(23, 59, 0, 2, 4, 2008),
  ), mktime(23, 59, 0, 2, 5, 2008))));
  dprint("48." . (false == elysia_cron_should_run(array(
    'rule' => '59 23 1-5 1 0',
    'last_run' => mktime(23, 59, 0, 2, 5, 2008),
  ), mktime(23, 59, 0, 2, 10, 2008))));
  dprint("49." . (false == elysia_cron_should_run(array(
    'rule' => '59 23 1-5 1 0',
    'last_run' => mktime(23, 59, 0, 2, 10, 2008),
  ), mktime(23, 59, 0, 2, 17, 2008))));
  dprint("49." . (true == elysia_cron_should_run(array(
    'rule' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *',
    'last_run' => mktime(8, 58, 0, 2, 10, 2008),
  ), mktime(8, 59, 0, 2, 10, 2008))));
  dprint("50." . (false == elysia_cron_should_run(array(
    'rule' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *',
    'last_run' => mktime(8, 59, 0, 2, 10, 2008),
  ), mktime(9, 00, 0, 2, 10, 2008))));
  dprint("51." . (false == elysia_cron_should_run(array(
    'rule' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *',
    'last_run' => mktime(8, 59, 0, 2, 10, 2008),
  ), mktime(17, 59, 0, 2, 10, 2008))));
  dprint("52." . (true == elysia_cron_should_run(array(
    'rule' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *',
    'last_run' => mktime(8, 59, 0, 2, 10, 2008),
  ), mktime(18, 00, 0, 2, 10, 2008))));
  dprint("53." . (true == elysia_cron_should_run(array(
    'rule' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *',
    'last_run' => mktime(18, 00, 0, 2, 10, 2008),
  ), mktime(18, 01, 0, 2, 10, 2008))));
  dprint("54." . (true == elysia_cron_should_run(array(
    'rule' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *',
    'last_run' => mktime(18, 00, 0, 2, 10, 2008),
  ), mktime(19, 0, 0, 2, 10, 2008))));
  dprint("55." . (true == elysia_cron_should_run(array(
    'rule' => '* 0,1,2,3,4,5,6,7,8,18,19,20,21,22,23 * * *',
    'last_run' => mktime(18, 00, 0, 2, 10, 2008),
  ), mktime(9, 0, 0, 3, 10, 2008))));
  dprint("End test (" . (microtime(true) - $start) . ")");
}