function BlockConfigSchemaTest::testBlockConfigSchema

Same name in this branch
  1. 10 core/modules/book/tests/src/Kernel/Block/BlockConfigSchemaTest.php \Drupal\Tests\book\Kernel\Block\BlockConfigSchemaTest::testBlockConfigSchema()
Same name and namespace in other branches
  1. 9 core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php \Drupal\Tests\block\Kernel\BlockConfigSchemaTest::testBlockConfigSchema()
  2. 8.9.x core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php \Drupal\Tests\block\Kernel\BlockConfigSchemaTest::testBlockConfigSchema()
  3. 11.x core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php \Drupal\Tests\block\Kernel\BlockConfigSchemaTest::testBlockConfigSchema()
  4. 11.x core/modules/book/tests/src/Kernel/Block/BlockConfigSchemaTest.php \Drupal\Tests\book\Kernel\Block\BlockConfigSchemaTest::testBlockConfigSchema()

Tests the block config schema for block plugins.

File

core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php, line 66

Class

BlockConfigSchemaTest
Tests the block config schema.

Namespace

Drupal\Tests\block\Kernel

Code

public function testBlockConfigSchema() : void {
  foreach ($this->blockManager
    ->getDefinitions() as $block_id => $definition) {
    $id = $this->randomMachineName();
    $block = Block::create([
      'id' => $id,
      'theme' => 'stark',
      'weight' => 00,
      'status' => TRUE,
      'region' => 'content',
      'plugin' => $block_id,
      'settings' => [
        'label' => $this->randomMachineName(),
        'provider' => 'system',
        'label_display' => FALSE,
      ],
      'visibility' => [],
    ]);
    $block->save();
    $config = $this->config("block.block.{$id}");
    $this->assertEquals($id, $config->get('id'));
    $this->assertConfigSchema($this->typedConfig, $config->getName(), $config->get());
  }
}

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