You are here

public function BlockConfigSchemaTest::testBlockConfigSchema in Drupal 8

Same name and namespace in other branches
  1. 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 68

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' => 'classy',
      '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
      ->assertEqual($config
      ->get('id'), $id);
    $this
      ->assertConfigSchema($this->typedConfig, $config
      ->getName(), $config
      ->get());
  }
}