public function DateRecurBasicFormatterTest::testFormatterOccurrencesPerItem in Recurring Dates Field 8.2
Same name and namespace in other branches
- 3.x tests/src/Kernel/DateRecurBasicFormatterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurBasicFormatterTest::testFormatterOccurrencesPerItem()
- 3.0.x tests/src/Kernel/DateRecurBasicFormatterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurBasicFormatterTest::testFormatterOccurrencesPerItem()
- 3.1.x tests/src/Kernel/DateRecurBasicFormatterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurBasicFormatterTest::testFormatterOccurrencesPerItem()
Tests occurrences.
File
- tests/
src/ Kernel/ DateRecurBasicFormatterTest.php, line 95
Class
- DateRecurBasicFormatterTest
- Tests date recur formatter.
Namespace
Drupal\Tests\date_recur\KernelCode
public function testFormatterOccurrencesPerItem() {
$this->dateFormat = DateFormat::create([
'id' => $this
->randomMachineName(),
'pattern' => 'H:i',
]);
$this->dateFormat
->save();
$dateFormatId = $this->dateFormat
->id();
$settings = [
'show_next' => 2,
'count_per_item' => TRUE,
'format_type' => $dateFormatId,
'occurrence_format_type' => $dateFormatId,
'same_end_date_format_type' => $dateFormatId,
'interpreter' => $this->interpreter
->id(),
];
$entity = DrEntityTest::create();
$entity->dr = [
[
// 10am-4pm weekdaily.
'value' => '2008-06-16T00:00:00',
'end_value' => '2008-06-16T06:00:00',
'rrule' => 'FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR',
'infinite' => '1',
'timezone' => 'Australia/Sydney',
],
[
// 9am-5pm weekdaily.
'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
->renderFormatterSettings($entity, $settings);
$occurrences = $this
->cssSelect('.date-recur-occurrences li');
$this
->assertCount(4, $occurrences);
$this
->assertEquals('10:00', (string) $occurrences[0]->time[0]);
$this
->assertEquals('16:00', (string) $occurrences[0]->time[1]);
$this
->assertEquals('10:00', (string) $occurrences[1]->time[0]);
$this
->assertEquals('16:00', (string) $occurrences[1]->time[1]);
$this
->assertEquals('09:00', (string) $occurrences[2]->time[0]);
$this
->assertEquals('17:00', (string) $occurrences[2]->time[1]);
$this
->assertEquals('09:00', (string) $occurrences[3]->time[0]);
$this
->assertEquals('17:00', (string) $occurrences[3]->time[1]);
}