public function DateRecurBasicFormatterTest::testFormatterOccurrencesNotPerItem 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::testFormatterOccurrencesNotPerItem()
- 3.0.x tests/src/Kernel/DateRecurBasicFormatterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurBasicFormatterTest::testFormatterOccurrencesNotPerItem()
- 3.1.x tests/src/Kernel/DateRecurBasicFormatterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurBasicFormatterTest::testFormatterOccurrencesNotPerItem()
Tests occurrences.
File
- tests/
src/ Kernel/ DateRecurBasicFormatterTest.php, line 147
Class
- DateRecurBasicFormatterTest
- Tests date recur formatter.
Namespace
Drupal\Tests\date_recur\KernelCode
public function testFormatterOccurrencesNotPerItem() {
$this->dateFormat = DateFormat::create([
'id' => $this
->randomMachineName(),
'pattern' => 'H:i',
]);
$this->dateFormat
->save();
$dateFormatId = $this->dateFormat
->id();
$settings = [
'show_next' => 2,
'count_per_item' => FALSE,
'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(2, $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]);
}