You are here

public function DateRecurFieldItemTest::testGenerateSampleValue in Recurring Dates Field 3.x

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

Test field item generation.

@covers ::generateSampleValue

File

tests/src/Kernel/DateRecurFieldItemTest.php, line 254

Class

DateRecurFieldItemTest
Tests date_recur field.

Namespace

Drupal\Tests\date_recur\Kernel

Code

public function testGenerateSampleValue() {
  $entity = DrEntityTest::create();
  $entity->dr
    ->generateSampleItems();
  $this
    ->assertRegExp('/^FREQ=DAILY;COUNT=\\d{1,2}$/', $entity->dr->rrule);
  $this
    ->assertFalse($entity->dr->infinite);
  $this
    ->assertTrue(in_array($entity->dr->timezone, timezone_identifiers_list(), TRUE));

  /** @var \Symfony\Component\Validator\ConstraintViolationListInterface $violations */
  $violations = $entity->dr
    ->validate();
  $this
    ->assertEquals(0, $violations
    ->count());
}