function ConfigEntityValidationTestBase::testLabelValidation
Same name in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Config/ConfigEntityValidationTestBase.php \Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBase::testLabelValidation()
Tests validation of config entity's label.
See also
\Drupal\Core\Entity\EntityInterface::label()
\Drupal\Core\Entity\EntityBase::label()
3 methods override ConfigEntityValidationTestBase::testLabelValidation()
- BlockValidationTest::testLabelValidation in core/
modules/ block/ tests/ src/ Kernel/ BlockValidationTest.php - Tests validation of config entity's label.
- EditorValidationTest::testLabelValidation in core/
modules/ editor/ tests/ src/ Kernel/ EditorValidationTest.php - Tests validation of config entity's label.
- LayoutBuilderEntityViewDisplayValidationTest::testLabelValidation in core/
modules/ layout_builder/ tests/ src/ Kernel/ LayoutBuilderEntityViewDisplayValidationTest.php - Tests validation of config entity's label.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ ConfigEntityValidationTestBase.php, line 349
Class
- ConfigEntityValidationTestBase
- Base class for testing validation of config entities.
Namespace
Drupal\KernelTests\Core\ConfigCode
public function testLabelValidation() : void {
// Some entity types do not have a label.
if (!$this->hasLabel) {
$this->markTestSkipped();
}
if ($this->entity
->getEntityType()
->getKey('label') === $this->entity
->getEntityType()
->getKey('id')) {
$this->markTestSkipped('This entity type uses the ID as the label; an entity without a label is hence impossible.');
}
static::setLabel($this->entity, "Multi\nLine");
$this->assertValidationErrors([
$this->entity
->getEntityType()
->getKey('label') => "Labels are not allowed to span multiple lines or contain control characters.",
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.