function BlockValidationTest::testRegionValidation

Tests validating a block's region in a theme.

File

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

Class

BlockValidationTest
Tests validation of block entities.

Namespace

Drupal\Tests\block\Kernel

Code

public function testRegionValidation() : void {
    $this->entity
        ->set('region', 'non_existent');
    $this->assertValidationErrors([
        'region' => 'This is not a valid region of the <em class="placeholder">stark</em> theme.',
    ]);
    // Set a valid region and assert it is saved properly.
    $this->entity
        ->set('region', 'header');
    $this->assertValidationErrors([]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.