public function DateRecurRlHelperUnitTest::testRdate in Recurring Dates Field 3.x
Same name and namespace in other branches
- 8.2 tests/src/Unit/DateRecurRlHelperUnitTest.php \Drupal\Tests\date_recur\Unit\DateRecurRlHelperUnitTest::testRdate()
- 3.0.x tests/src/Unit/DateRecurRlHelperUnitTest.php \Drupal\Tests\date_recur\Unit\DateRecurRlHelperUnitTest::testRdate()
- 3.1.x tests/src/Unit/DateRecurRlHelperUnitTest.php \Drupal\Tests\date_recur\Unit\DateRecurRlHelperUnitTest::testRdate()
Tests single RDATE value.
Rdates serve to add extra fixed time occurrences, they are combined with any dates computed by RRULEs.
File
- tests/
src/ Unit/ DateRecurRlHelperUnitTest.php, line 193
Class
- DateRecurRlHelperUnitTest
- Tests Rlanvin implementation of helper.
Namespace
Drupal\Tests\date_recur\UnitCode
public function testRdate() {
$timeZone = new \DateTimeZone('Asia/Singapore');
$dtStart = new \DateTime('11am 4 Oct 2012', $timeZone);
$rrule = 'RRULE:FREQ=WEEKLY;COUNT=3
RDATE:20121006T120000Z';
$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(4, $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('Thu, 18 Oct 2012 11:00:00 +0800', $occurrences[3]
->getStart()
->format('r'));
// Rdate time zones are same as original, not same as start date.
$rDates = $instance
->getRlRuleset()
->getDates();
$this
->assertCount(1, $rDates);
$this
->assertEquals('Sat, 06 Oct 2012 12:00:00 +0000', $rDates[0]
->format('r'));
}