You are here

public function DateRecurRlHelperUnitTest::testExdate in Recurring Dates Field 3.x

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

Tests single EXDATE value.

File

tests/src/Unit/DateRecurRlHelperUnitTest.php, line 121

Class

DateRecurRlHelperUnitTest
Tests Rlanvin implementation of helper.

Namespace

Drupal\Tests\date_recur\Unit

Code

public function testExdate() {
  $timeZone = new \DateTimeZone('Asia/Singapore');

  // Difference between exdate (UTC) and Singapore is 8 hours.
  $dtStart = new \DateTime('10am 16 June 2014', $timeZone);
  $rrule = 'RRULE:FREQ=DAILY;COUNT=6
EXDATE:20140617T020000Z';
  $instance = $this
    ->createHelper($rrule, $dtStart);
  $occurrences = $instance
    ->getOccurrences();
  $this
    ->assertCount(5, $occurrences);

  // Occurrence time zones are same as start date.
  $this
    ->assertEquals('Mon, 16 Jun 2014 10:00:00 +0800', $occurrences[0]
    ->getStart()
    ->format('r'));
  $this
    ->assertEquals('Wed, 18 Jun 2014 10:00:00 +0800', $occurrences[1]
    ->getStart()
    ->format('r'));
  $this
    ->assertEquals('Thu, 19 Jun 2014 10:00:00 +0800', $occurrences[2]
    ->getStart()
    ->format('r'));
  $this
    ->assertEquals('Fri, 20 Jun 2014 10:00:00 +0800', $occurrences[3]
    ->getStart()
    ->format('r'));
  $this
    ->assertEquals('Sat, 21 Jun 2014 10:00:00 +0800', $occurrences[4]
    ->getStart()
    ->format('r'));

  // Exdate time zones are same as original, not same as start date.
  $exDates = $instance
    ->getRlRuleset()
    ->getExDates();
  $this
    ->assertCount(1, $exDates);
  $this
    ->assertEquals('Tue, 17 Jun 2014 02:00:00 +0000', $exDates[0]
    ->format('r'));
}