public function DateTimeItemTest::testDateonlyValidation in Drupal 10
Same name and namespace in other branches
- 8 core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php \Drupal\Tests\datetime\Kernel\DateTimeItemTest::testDateonlyValidation()
- 9 core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php \Drupal\Tests\datetime\Kernel\DateTimeItemTest::testDateonlyValidation()
Tests the constraint validations for fields with date only.
@dataProvider dateonlyValidationProvider
File
- core/
modules/ datetime/ tests/ src/ Kernel/ DateTimeItemTest.php, line 318
Class
- DateTimeItemTest
- Tests the new entity API for the date field type.
Namespace
Drupal\Tests\datetime\KernelCode
public function testDateonlyValidation($value) {
$this
->expectException(AssertionFailedError::class);
$this->fieldStorage
->setSetting('datetime_type', DateTimeItem::DATETIME_TYPE_DATE);
$this->fieldStorage
->save();
$entity = EntityTest::create();
$entity
->set('field_datetime', $value);
$this
->entityValidateAndSave($entity);
}