You are here

public function DateRecurFieldItemTest::testTimeZoneConstraintInvalidZone in Recurring Dates Field 8.2

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

Tests violations when time zone is not a recognised by PHP.

File

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

Class

DateRecurFieldItemTest
Tests date_recur field.

Namespace

Drupal\Tests\date_recur\Kernel

Code

public function testTimeZoneConstraintInvalidZone() {
  $entity = DrEntityTest::create();
  $entity->dr = [
    'value' => '2014-06-15T23:00:00',
    'end_value' => '2014-06-16T07:00:00',
    'rrule' => 'FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=3',
    'infinite' => '0',
    'timezone' => 'Mars/Mariner',
  ];

  /** @var \Symfony\Component\Validator\ConstraintViolationListInterface $violations */
  $violations = $entity->dr
    ->validate();
  $this
    ->assertEquals(1, $violations
    ->count());
  $violation = $violations
    ->get(0);
  $message = (string) $violation
    ->getMessage();
  $this
    ->assertEquals('<em class="placeholder">Mars/Mariner</em> is not a valid time zone.', $message);
}