public function DateRecurFieldItemListTest::testList in Recurring Dates Field 3.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/DateRecurFieldItemListTest.php \Drupal\Tests\date_recur\Kernel\DateRecurFieldItemListTest::testList()
- 3.0.x tests/src/Kernel/DateRecurFieldItemListTest.php \Drupal\Tests\date_recur\Kernel\DateRecurFieldItemListTest::testList()
- 3.1.x tests/src/Kernel/DateRecurFieldItemListTest.php \Drupal\Tests\date_recur\Kernel\DateRecurFieldItemListTest::testList()
Tests list.
File
- tests/
src/ Kernel/ DateRecurFieldItemListTest.php, line 79
Class
- DateRecurFieldItemListTest
- Tests date_recur field lists.
Namespace
Drupal\Tests\date_recur\KernelCode
public function testList() {
$this->entity->foo = [
'value' => '2014-06-15T23:00:00',
'end_value' => '2014-06-16T07:00:00',
'rrule' => 'FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR',
'infinite' => '1',
'timezone' => 'Australia/Sydney',
];
$this
->assertTrue($this->entity->foo->occurrences instanceof \Generator);
// Iterate over it a bit, because this is an infinite RRULE it will go
// forever.
$iterationCount = 0;
$maxIterations = 7;
foreach ($this->entity->foo->occurrences as $occurrence) {
$this
->assertTrue($occurrence instanceof DateRange);
$iterationCount++;
if ($iterationCount >= $maxIterations) {
break;
}
}
$this
->assertEquals($maxIterations, $iterationCount);
}