function BlockValidationTest::setLabel

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

Sets the label of the given config entity.

Parameters

\Drupal\Core\Config\Entity\ConfigEntityInterface $entity: The config entity to modify.

string $label: The label to set.

Overrides ConfigEntityValidationTestBase::setLabel

1 call to BlockValidationTest::setLabel()
BlockValidationTest::testLabelValidation in core/modules/block/tests/src/Kernel/BlockValidationTest.php
Tests validation of config entity's label.

File

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

Class

BlockValidationTest
Tests validation of block entities.

Namespace

Drupal\Tests\block\Kernel

Code

protected static function setLabel(ConfigEntityInterface $block, string $label) : void {
    static::assertInstanceOf(Block::class, $block);
    $settings = $block->get('settings');
    static::assertNotEmpty($settings['label']);
    $settings['label'] = $label;
    $block->set('settings', $settings);
}

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