You are here

function RulesUnitTest::testIntervals2MinuteRangeWithOffset in Ultimate Cron 8.2

File

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

Class

RulesUnitTest
Tests Drupal\ultimate_cron\CronRule.

Namespace

Drupal\Tests\ultimate_cron\Unit

Code

function testIntervals2MinuteRangeWithOffset() {
  $intervals = $this
    ->getIntervals('0-1+1 12 * * *');
  $this
    ->assertEquals(range(2, 1, -1), $intervals['minutes'], 'Expected minutes to be 1, 2');
  $intervals = $this
    ->getIntervals('10-11+1 12 * * *');
  $this
    ->assertEquals(range(12, 11, -1), $intervals['minutes'], 'Expected minutes to be 11, 12');

  // Note, this test is testing for correct behaviour when the minutes wrap around
  // Previously, this test would generate 43, 0 due to a bug in expandRange/expandInterval
  $intervals = $this
    ->getIntervals('42-43+1 12 * * *');
  $this
    ->assertEquals(array(
    44,
    43,
  ), $intervals['minutes'], 'Expected minutes to be 43, 44');

  // Note, this test is testing for correct behaviour when the minutes wrap around
  $intervals = $this
    ->getIntervals('58-59+1 12 * * *');
  $this
    ->assertEquals(array(
    59,
    0,
  ), $intervals['minutes'], 'Expected minutes to be 59, 0');
}