You are here

public function DateRecurRlHelperUnitTest::testRdateMultiple in Recurring Dates Field 8.2

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

Tests multiple RDATE values.

File

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

Class

DateRecurRlHelperUnitTest
Tests Rlanvin implementation of helper.

Namespace

Drupal\Tests\date_recur\Unit

Code

public function testRdateMultiple() {
  $timeZone = new \DateTimeZone('Asia/Singapore');
  $dtStart = new \DateTime('11am 4 Oct 2012', $timeZone);
  $rrule = 'RRULE:FREQ=WEEKLY;COUNT=3
RDATE:20121006T120000Z,20121013T120000Z';
  $instance = $this
    ->createHelper($rrule, $dtStart);

  // Tests the RDATE is found between all the RRULE occurrences, such that it
  // is chronological date order, not simply appended to the RRULE list.
  $occurrences = $instance
    ->getOccurrences();
  $this
    ->assertCount(5, $occurrences);

  // Occurrence time zones are same as start date.
  $this
    ->assertEquals('Thu, 04 Oct 2012 11:00:00 +0800', $occurrences[0]
    ->getStart()
    ->format('r'));

  // The RDATE date/time zone is not normalised to the start-date time zone.
  $this
    ->assertEquals('Sat, 06 Oct 2012 12:00:00 +0000', $occurrences[1]
    ->getStart()
    ->format('r'));
  $this
    ->assertEquals('Thu, 11 Oct 2012 11:00:00 +0800', $occurrences[2]
    ->getStart()
    ->format('r'));
  $this
    ->assertEquals('Sat, 13 Oct 2012 12:00:00 +0000', $occurrences[3]
    ->getStart()
    ->format('r'));
  $this
    ->assertEquals('Thu, 18 Oct 2012 11:00:00 +0800', $occurrences[4]
    ->getStart()
    ->format('r'));

  // Rdate time zones are same as original, not same as start date.
  $rDates = $instance
    ->getRlRuleset()
    ->getDates();
  $this
    ->assertCount(2, $rDates);
  $this
    ->assertEquals('Sat, 06 Oct 2012 12:00:00 +0000', $rDates[0]
    ->format('r'));
  $this
    ->assertEquals('Sat, 13 Oct 2012 12:00:00 +0000', $rDates[1]
    ->format('r'));
}