function NodeTypeValidationTest::testDescriptionAndHelpCannotBeEmpty
Tests that description and help text can be NULL, but not empty strings.
File
-
core/
modules/ node/ tests/ src/ Kernel/ NodeTypeValidationTest.php, line 72
Class
- NodeTypeValidationTest
- Tests validation of node_type entities.
Namespace
Drupal\Tests\node\KernelCode
public function testDescriptionAndHelpCannotBeEmpty() : void {
$this->entity
->set('description', NULL)
->set('help', NULL);
// The entity's getters should cast NULL values to empty strings.
$this->assertSame('', $this->entity
->getDescription());
$this->assertSame('', $this->entity
->getHelp());
// 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', '')
->set('help', '');
$this->assertValidationErrors([
'description' => 'This value should not be blank.',
'help' => 'This value should not be blank.',
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.