You are here

public function RollingIntervalTest::rollingIntervalProvider in Recurring Time Period 8

File

tests/src/Kernel/RollingIntervalTest.php, line 42

Class

RollingIntervalTest
Tests the rolling interval plugin.

Namespace

Drupal\Tests\recurring_period\Kernel

Code

public function rollingIntervalProvider() {
  return [
    '1 month' => [
      // Configuration.
      [
        'interval' => [
          'period' => 'month',
          'interval' => 1,
        ],
      ],
      // Start date.
      '2017-01-01T09:00:00',
      // Successive period dates.
      [
        [
          '2017-01-01T09:00:00+00:00',
          '2017-02-01T09:00:00+00:00',
        ],
        [
          '2017-02-01T09:00:00+00:00',
          '2017-03-01T09:00:00+00:00',
        ],
        // The end of this period is after the change to DST, so the offset
        // changes from 0 to +1.
        [
          '2017-03-01T09:00:00+00:00',
          '2017-04-01T09:00:00+01:00',
        ],
        [
          '2017-04-01T09:00:00+01:00',
          '2017-05-01T09:00:00+01:00',
        ],
        [
          '2017-05-01T09:00:00+01:00',
          '2017-06-01T09:00:00+01:00',
        ],
        [
          '2017-06-01T09:00:00+01:00',
          '2017-07-01T09:00:00+01:00',
        ],
        [
          '2017-07-01T09:00:00+01:00',
          '2017-08-01T09:00:00+01:00',
        ],
        [
          '2017-08-01T09:00:00+01:00',
          '2017-09-01T09:00:00+01:00',
        ],
        [
          '2017-09-01T09:00:00+01:00',
          '2017-10-01T09:00:00+01:00',
        ],
        [
          '2017-10-01T09:00:00+01:00',
          '2017-11-01T09:00:00+00:00',
        ],
        [
          '2017-11-01T09:00:00+00:00',
          '2017-12-01T09:00:00+00:00',
        ],
        [
          '2017-12-01T09:00:00+00:00',
          '2018-01-01T09:00:00+00:00',
        ],
      ],
    ],
    '2 weeks' => [
      // Configuration.
      [
        'interval' => [
          'period' => 'week',
          'interval' => 2,
        ],
      ],
      // Start date.
      '2017-01-01T09:00:00',
      // Successive period dates.
      [
        [
          '2017-01-01T09:00:00+00:00',
          '2017-01-15T09:00:00+00:00',
        ],
        [
          '2017-01-15T09:00:00+00:00',
          '2017-01-29T09:00:00+00:00',
        ],
      ],
    ],
  ];
}