You are here

public function DateRecurViewsOccurrenceFilterTest::testDateRecurFilterTimezoneNonSecond in Recurring Dates Field 8.2

Same name and namespace in other branches
  1. 3.x tests/src/Kernel/DateRecurViewsOccurrenceFilterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurViewsOccurrenceFilterTest::testDateRecurFilterTimezoneNonSecond()
  2. 3.0.x tests/src/Kernel/DateRecurViewsOccurrenceFilterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurViewsOccurrenceFilterTest::testDateRecurFilterTimezoneNonSecond()
  3. 3.1.x tests/src/Kernel/DateRecurViewsOccurrenceFilterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurViewsOccurrenceFilterTest::testDateRecurFilterTimezoneNonSecond()

Tests timezone capability for non second granularity.

There is different handling of timezones for seconds vs other granularities.

File

tests/src/Kernel/DateRecurViewsOccurrenceFilterTest.php, line 571

Class

DateRecurViewsOccurrenceFilterTest
Tests the results of 'date_recur_occurrences_filter' filter plugin.

Namespace

Drupal\Tests\date_recur\Kernel

Code

public function testDateRecurFilterTimezoneNonSecond() {
  $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();
  $exposedIdentifier = 'dr_occurrences';
  $filterOptions = [
    'operator' => '=',
    'value' => '',
    // Doesnt matter which granularity, so long as it is not seconds.
    'value_granularity' => 'day',
    '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-12',
  ], [], $filterOptions, 'no match previous day');
  $this
    ->assertFilter([
    $exposedIdentifier => '2014-09-13',
  ], $expectedRowWithEntity, $filterOptions, 'match current day');
  $this
    ->assertFilter([
    $exposedIdentifier => '2014-09-14',
  ], [], $filterOptions, 'no match folowing day');
}