public function RollingIntervalTest::testRollingInterval in Recurring Time Period 8
Tests the TODO.
@dataProvider rollingIntervalProvider
File
- tests/
src/ Kernel/ RollingIntervalTest.php, line 19
Class
- RollingIntervalTest
- Tests the rolling interval plugin.
Namespace
Drupal\Tests\recurring_period\KernelCode
public function testRollingInterval($configuration, $start_date, $period_dates) {
$rolling_interval_plugin = $this->recurringPeriodManager
->createInstance('rolling_interval', $configuration);
$timezone_london = new \DateTimeZone('Europe/London');
$start_date_time = new \DateTimeImmutable($start_date, $timezone_london);
$period = $rolling_interval_plugin
->getPeriodFromDate($start_date_time);
$first_period_dates = array_shift($period_dates);
$this
->assertEquals($first_period_dates[0], $period
->getStartDate()
->format(\DateTimeInterface::ATOM));
$this
->assertEquals($first_period_dates[1], $period
->getEndDate()
->format(\DateTimeInterface::ATOM));
while ($next_period_dates = array_shift($period_dates)) {
// TODO: also check the value of calculateDate().
$period = $rolling_interval_plugin
->getNextPeriod($period);
$this
->assertEquals($next_period_dates[0], $period
->getStartDate()
->format(\DateTimeInterface::ATOM));
$this
->assertEquals($next_period_dates[1], $period
->getEndDate()
->format(\DateTimeInterface::ATOM));
}
}