You are here

public function DateRecurTest::testHelperNonRecurringWithNoEnd in Recurring Dates Field 3.x

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

Tests accessing occurrences with fields with no end date or rule.

File

tests/src/Kernel/DateRecurTest.php, line 128

Class

DateRecurTest
Tests basic functionality of date_recur fields.

Namespace

Drupal\Tests\date_recur\Kernel

Code

public function testHelperNonRecurringWithNoEnd() {
  $entity = DrEntityTest::create();
  $entity->dr = [
    'value' => '2014-06-15T23:00:00',
    'end_value' => '',
    'rrule' => '',
    'infinite' => '0',
    'timezone' => 'Australia/Sydney',
  ];

  // Ensure a non repeating field value generates a single occurrence.

  /** @var \Drupal\date_recur\DateRange[] $occurrences */
  $occurrences = iterator_to_array($entity->dr->occurrences);
  $this
    ->assertCount(1, $occurrences);
  $tz = new \DateTimeZone('Australia/Sydney');
  $startAssert = new \DateTime('9am 16 June 2014', $tz);
  $this
    ->assertEquals($startAssert, $occurrences[0]
    ->getStart());
  $this
    ->assertEquals($startAssert, $occurrences[0]
    ->getEnd());
}