public function DateRecurViewsOccurrenceFilterTest::testDateRecurFilterAbsoluteSecond in Recurring Dates Field 3.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/DateRecurViewsOccurrenceFilterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurViewsOccurrenceFilterTest::testDateRecurFilterAbsoluteSecond()
- 3.0.x tests/src/Kernel/DateRecurViewsOccurrenceFilterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurViewsOccurrenceFilterTest::testDateRecurFilterAbsoluteSecond()
- 3.1.x tests/src/Kernel/DateRecurViewsOccurrenceFilterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurViewsOccurrenceFilterTest::testDateRecurFilterAbsoluteSecond()
Tests date recur filter plugin.
File
- tests/
src/ Kernel/ DateRecurViewsOccurrenceFilterTest.php, line 488
Class
- DateRecurViewsOccurrenceFilterTest
- Tests the results of 'date_recur_occurrences_filter' filter plugin.
Namespace
Drupal\Tests\date_recur\KernelCode
public function testDateRecurFilterAbsoluteSecond() {
$entity = $this
->createEntity();
$entity->{$this->fieldName} = [
[
// 13 Sept 2014, 9-5am.
'value' => '2014-09-12T23:00:00',
'end_value' => '2014-09-13T07:00:00',
'rrule' => 'FREQ=DAILY;COUNT=1',
'infinite' => '1',
'timezone' => 'Australia/Sydney',
],
];
$entity
->save();
// Decoy.
$entity2 = $this
->createEntity();
$entity2->{$this->fieldName} = [
[
// 14 Sept 2014, 9-5am.
'value' => '2014-09-13T23:00:00',
'end_value' => '2014-09-14T07:00:00',
'rrule' => 'FREQ=DAILY;COUNT=1',
'infinite' => '1',
'timezone' => 'Australia/Sydney',
],
];
$entity2
->save();
$exposedIdentifier = 'dr_occurrences';
$filterOptions = [
'operator' => '=',
'value' => '',
'value_granularity' => 'second',
'exposed' => TRUE,
'expose' => [
'identifier' => $exposedIdentifier,
'operator' => 'dr_occurrences_op',
'use_operator' => FALSE,
'required' => FALSE,
],
];
$expectedRowWithEntity = [
[
'id' => $entity
->id(),
],
];
// Input values are in the users timezone.
$this
->assertFilter([
$exposedIdentifier => '2014-09-13T08:59:59',
], [], $filterOptions, 'before occurrence, no match');
$this
->assertFilter([
$exposedIdentifier => '2014-09-13T09:00:00',
], $expectedRowWithEntity, $filterOptions, 'start of occurrence, match');
$this
->assertFilter([
$exposedIdentifier => '2014-09-13T09:01:00',
], $expectedRowWithEntity, $filterOptions, 'within occurrence, match');
$this
->assertFilter([
$exposedIdentifier => '2014-09-13T17:00:00',
], $expectedRowWithEntity, $filterOptions, 'end of occurrence, match');
$this
->assertFilter([
$exposedIdentifier => '2014-09-13T17:00:01',
], [], $filterOptions, 'after occurrence, no match');
}