You are here

public function DateRecurRlInterpretationUnitTest::testDisplayTimeZone in Recurring Dates Field 3.x

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/DateRecurRlInterpretationUnitTest.php \Drupal\Tests\date_recur\Unit\DateRecurRlInterpretationUnitTest::testDisplayTimeZone()
  2. 3.0.x tests/src/Unit/DateRecurRlInterpretationUnitTest.php \Drupal\Tests\date_recur\Unit\DateRecurRlInterpretationUnitTest::testDisplayTimeZone()
  3. 3.1.x tests/src/Unit/DateRecurRlInterpretationUnitTest.php \Drupal\Tests\date_recur\Unit\DateRecurRlInterpretationUnitTest::testDisplayTimeZone()

Tests output is in the same time zone as requested.

File

tests/src/Unit/DateRecurRlInterpretationUnitTest.php, line 190

Class

DateRecurRlInterpretationUnitTest
Tests Rlanvin implementation of interpreter.

Namespace

Drupal\Tests\date_recur\Unit

Code

public function testDisplayTimeZone() {
  $parts = [
    'FREQ' => 'WEEKLY',
    // Africa/Tripoli: UTC+2 No DST.
    'DTSTART' => new \DateTime('4am 15 July 2012', new \DateTimeZone('Africa/Tripoli')),
  ];
  $rules[] = new RlDateRecurRule($parts);
  $configuration = [
    'date_format' => $this
      ->randomMachineName(),
  ];
  $interpreter = RlInterpreter::create($this->testContainer, $configuration, '', []);

  // Asia/Singapore: UTC+8 No DST.
  $displayTimeZone = new \DateTimeZone('Asia/Singapore');
  $interpretation = $interpreter
    ->interpret($rules, 'en', $displayTimeZone);
  $this
    ->assertEquals('weekly, starting from Sun, 15 Jul 2012 10:00:00 +0800, forever', $interpretation);
}