public function DateRecurViewsOccurrenceFilterTest::testDateRecurFilterAbsoluteDay in Recurring Dates Field 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/DateRecurViewsOccurrenceFilterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurViewsOccurrenceFilterTest::testDateRecurFilterAbsoluteDay()
- 3.x tests/src/Kernel/DateRecurViewsOccurrenceFilterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurViewsOccurrenceFilterTest::testDateRecurFilterAbsoluteDay()
- 3.1.x tests/src/Kernel/DateRecurViewsOccurrenceFilterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurViewsOccurrenceFilterTest::testDateRecurFilterAbsoluteDay()
Tests date recur filter plugin.
File
- tests/
src/ Kernel/ DateRecurViewsOccurrenceFilterTest.php, line 343
Class
- DateRecurViewsOccurrenceFilterTest
- Tests the results of 'date_recur_occurrences_filter' filter plugin.
Namespace
Drupal\Tests\date_recur\KernelCode
public function testDateRecurFilterAbsoluteDay() {
// Testing around 13 September 2014 in users local timezone.
$entity1 = $this
->createEntity();
$entity1->{$this->fieldName} = [
[
// Before 13 September 2014.
'value' => '2014-09-11T23:00:00',
'end_value' => '2014-09-12T07:00:00',
'rrule' => 'FREQ=DAILY;COUNT=1',
'infinite' => '0',
'timezone' => 'Australia/Sydney',
],
];
$entity1
->save();
$entity2 = $this
->createEntity();
$entity2->{$this->fieldName} = [
[
// Intersecting start of 13 September 2014.
// 11pm 12 September 2014.
'value' => '2014-09-12T13:00:00',
// 1am 13 September 2014.
'end_value' => '2014-09-12T15:00:00',
'rrule' => 'FREQ=DAILY;COUNT=1',
'infinite' => '0',
'timezone' => 'Australia/Sydney',
],
];
$entity2
->save();
$entity3 = $this
->createEntity();
$entity3->{$this->fieldName} = [
[
// Within 13 September 2014.
// 2am 13 September 2014.
'value' => '2014-09-12T16:00:00',
// 4am 13 September 2014.
'end_value' => '2014-09-12T18:00:00',
'rrule' => 'FREQ=DAILY;COUNT=1',
'infinite' => '0',
'timezone' => 'Australia/Sydney',
],
];
$entity3
->save();
$entity4 = $this
->createEntity();
$entity4->{$this->fieldName} = [
[
// Intersecting end of 13 September 2014.
// 10pm 13 September 2014.
'value' => '2014-09-13T12:00:00',
// 2am 14 September 2014.
'end_value' => '2014-09-13T16:00:00',
'rrule' => 'FREQ=DAILY;COUNT=1',
'infinite' => '0',
'timezone' => 'Australia/Sydney',
],
];
$entity4
->save();
$entity5 = $this
->createEntity();
$entity5->{$this->fieldName} = [
[
// After 13 September 2014.
// 2am 14 September 2014.
'value' => '2014-09-13T16:00:00',
// 4am 14 September 2014.
'end_value' => '2014-09-13T18:00:00',
'rrule' => 'FREQ=DAILY;COUNT=1',
'infinite' => '0',
'timezone' => 'Australia/Sydney',
],
];
$entity5
->save();
$entity6 = $this
->createEntity();
$entity6->{$this->fieldName} = [
[
// Covering entirety of 13 September 2014.
// 11pm 12 September 2014.
'value' => '2014-09-12T13:00:00',
// 4am 14 September 2014.
'end_value' => '2014-09-13T18:00:00',
'rrule' => 'FREQ=DAILY;COUNT=1',
'infinite' => '0',
'timezone' => 'Australia/Sydney',
],
];
$entity6
->save();
$exposedIdentifier = 'dr_occurrences';
$filterOptions = [
'operator' => '=',
'value' => '',
'value_granularity' => 'day',
'exposed' => TRUE,
'expose' => [
'identifier' => $exposedIdentifier,
'operator' => 'dr_occurrences_op',
'use_operator' => FALSE,
'required' => FALSE,
],
];
// Input values are in the users timezone.
$this
->assertFilter([
$exposedIdentifier => '2014-09-11',
], [], $filterOptions, 'day before');
$this
->assertFilter([
$exposedIdentifier => '2014-09-12',
], [
[
'id' => $entity1
->id(),
],
[
'id' => $entity2
->id(),
],
[
'id' => $entity6
->id(),
],
], $filterOptions);
$this
->assertFilter([
$exposedIdentifier => '2014-09-13',
], [
[
'id' => $entity2
->id(),
],
[
'id' => $entity3
->id(),
],
[
'id' => $entity4
->id(),
],
[
'id' => $entity6
->id(),
],
], $filterOptions);
$this
->assertFilter([
$exposedIdentifier => '2014-09-14',
], [
[
'id' => $entity4
->id(),
],
[
'id' => $entity5
->id(),
],
[
'id' => $entity6
->id(),
],
], $filterOptions);
$this
->assertFilter([
$exposedIdentifier => '2014-09-15',
], [], $filterOptions, 'day after');
}