function EntityFormModeValidationTest::testDescriptionCannotBeEmpty
Tests that description can be NULL, but not empty strings.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFormModeValidationTest.php, line 80
Class
- EntityFormModeValidationTest
- Tests validation of entity_form_mode entities.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testDescriptionCannotBeEmpty() : void {
$this->entity
->set('description', NULL);
// The entity's getters should cast NULL values to empty strings.
$this->assertSame('', $this->entity
->getDescription());
// But NULL values should be valid at the config level.
$this->assertValidationErrors([]);
// But they cannot be empty strings, because that doesn't make sense.
$this->entity
->set('description', '');
$this->assertValidationErrors([
'description' => 'This value should not be blank.',
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.