You are here

public function BlockConfigSchemaTest::testBlockConfigSchema in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php \Drupal\Tests\block\Kernel\BlockConfigSchemaTest::testBlockConfigSchema()
  2. 9 core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php \Drupal\Tests\block\Kernel\BlockConfigSchemaTest::testBlockConfigSchema()

Tests the block config schema for block plugins.

File

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

Class

BlockConfigSchemaTest
Tests the block config schema.

Namespace

Drupal\Tests\block\Kernel

Code

public function testBlockConfigSchema() {
  foreach ($this->blockManager
    ->getDefinitions() as $block_id => $definition) {
    $id = strtolower($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());
  }
}