You are here

public function DateRecurRlHelperUnitTest::testRedundantPartsOmitted 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::testRedundantPartsOmitted()
  2. 3.0.x tests/src/Unit/DateRecurRlHelperUnitTest.php \Drupal\Tests\date_recur\Unit\DateRecurRlHelperUnitTest::testRedundantPartsOmitted()
  3. 3.1.x tests/src/Unit/DateRecurRlHelperUnitTest.php \Drupal\Tests\date_recur\Unit\DateRecurRlHelperUnitTest::testRedundantPartsOmitted()

Tests parts that were not passed originally, are not returned.

File

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

Class

DateRecurRlHelperUnitTest
Tests Rlanvin implementation of helper.

Namespace

Drupal\Tests\date_recur\Unit

Code

public function testRedundantPartsOmitted() {
  $dtStart = new \DateTime('9am 16 June 2014');
  $rrule = 'FREQ=DAILY;COUNT=10';
  $instance = $this
    ->createHelper($rrule, $dtStart);
  $rules = $instance
    ->getRules();
  $this
    ->assertCount(1, $rules);
  $rule = $rules[0];
  $parts = $rule
    ->getParts();

  // Rlanvin/rrule will return parts: 'DTSTART', 'FREQ', 'COUNT', 'INTERVAL',
  // 'WKST'. However we just need to test completely unrelated parts such as
  // BYMONTHDAY etc arn't returned here.
  $this
    ->assertArrayHasKey('DTSTART', $parts);
  $this
    ->assertArrayHasKey('COUNT', $parts);
  $this
    ->assertArrayNotHasKey('BYMONTHDAY', $parts);
}