function BlockValidationTest::testLabelValidation

Same name in other branches
  1. 11.x core/modules/block/tests/src/Kernel/BlockValidationTest.php \Drupal\Tests\block\Kernel\BlockValidationTest::testLabelValidation()

Overrides ConfigEntityValidationTestBase::testLabelValidation

File

core/modules/block/tests/src/Kernel/BlockValidationTest.php, line 86

Class

BlockValidationTest
Tests validation of block entities.

Namespace

Drupal\Tests\block\Kernel

Code

public function testLabelValidation() : void {
    static::setLabel($this->entity, "Multi\nLine");
    // TRICKY: because the Block config entity type does not specify a `label`
    // key, it is impossible for the generic ::testLabelValidation()
    // implementation in the base class to know at which property to expect a
    // validation error. Hence it is hardcoded in this case.
    $this->assertValidationErrors([
        'settings.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.