You are here

public function DateRecurRruleUnitTest::testTz in Recurring Dates Field 3.0.x

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

Test timezone.

@dataProvider providerTimezone

Parameters

\DateTimeZone $tz: A timezone for testing.

File

tests/src/Unit/DateRecurRruleUnitTest.php, line 45

Class

DateRecurRruleUnitTest
Date recur tests.

Namespace

Drupal\Tests\date_recur\Unit

Code

public function testTz(\DateTimeZone $tz) {
  $start = new \DateTime('11pm 7 June 2005', $tz);
  $rule = $this
    ->newRule('FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;INTERVAL=1', $start);

  // Test new method.
  $results = $rule
    ->getOccurrences(NULL, NULL, 1);
  $this
    ->assertInstanceOf(\DateTimeInterface::class, $results[0]
    ->getStart());
  $this
    ->assertTrue($start == $results[0]
    ->getStart());
}