public function DateRecurPartGridTest::testAllowedNothing in Recurring Dates Field 3.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/DateRecurPartGridTest.php \Drupal\Tests\date_recur\Kernel\DateRecurPartGridTest::testAllowedNothing()
- 3.0.x tests/src/Kernel/DateRecurPartGridTest.php \Drupal\Tests\date_recur\Kernel\DateRecurPartGridTest::testAllowedNothing()
- 3.1.x tests/src/Kernel/DateRecurPartGridTest.php \Drupal\Tests\date_recur\Kernel\DateRecurPartGridTest::testAllowedNothing()
Tests when nothing is allowed.
File
- tests/
src/ Kernel/ DateRecurPartGridTest.php, line 97
Class
- DateRecurPartGridTest
- Tests field validation failures as a result part grids.
Namespace
Drupal\Tests\date_recur\KernelCode
public function testAllowedNothing() {
$this
->setPartSettings([
'all' => FALSE,
'frequencies' => [
// Nothing is allowed.
'SECONDLY' => [],
'MINUTELY' => [],
'HOURLY' => [],
'DAILY' => [],
'WEEKLY' => [],
'MONTHLY' => [],
'YEARLY' => [],
],
]);
$entity = EntityTest::create();
$entity->foo = [
'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' => 'Australia/Sydney',
];
/** @var \Symfony\Component\Validator\ConstraintViolationListInterface $violations */
$violations = $entity->foo
->validate();
$this
->assertEquals(1, $violations
->count());
$violation = $violations
->get(0);
$message = strip_tags((string) $violation
->getMessage());
$this
->assertEquals('Weekly is not a permitted frequency.', $message);
}