function NodeTypeValidationTest::testPreviewModeValidation
Same name in other branches
- 10 core/modules/node/tests/src/Kernel/NodeTypeValidationTest.php \Drupal\Tests\node\Kernel\NodeTypeValidationTest::testPreviewModeValidation()
Tests that a node type's preview mode is constrained to certain values.
File
-
core/
modules/ node/ tests/ src/ Kernel/ NodeTypeValidationTest.php, line 45
Class
- NodeTypeValidationTest
- Tests validation of node_type entities.
Namespace
Drupal\Tests\node\KernelCode
public function testPreviewModeValidation() : void {
$this->entity
->setPreviewMode(38);
$this->assertValidationErrors([
'preview_mode' => 'The value you selected is not a valid choice.',
]);
$this->entity
->setPreviewMode(-1);
$this->assertValidationErrors([
'preview_mode' => 'The value you selected is not a valid choice.',
]);
$allowed_values = [
DRUPAL_DISABLED,
DRUPAL_OPTIONAL,
DRUPAL_REQUIRED,
];
foreach ($allowed_values as $allowed_value) {
$this->entity
->setPreviewMode($allowed_value);
$this->assertValidationErrors([]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.