function BlockConfigSchemaTest::testBlockConfigSchema

Same name in other branches
  1. 8.9.x core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php \Drupal\Tests\block\Kernel\BlockConfigSchemaTest::testBlockConfigSchema()
  2. 10 core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php \Drupal\Tests\block\Kernel\BlockConfigSchemaTest::testBlockConfigSchema()
  3. 10 core/modules/book/tests/src/Kernel/Block/BlockConfigSchemaTest.php \Drupal\Tests\book\Kernel\Block\BlockConfigSchemaTest::testBlockConfigSchema()
  4. 11.x core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php \Drupal\Tests\block\Kernel\BlockConfigSchemaTest::testBlockConfigSchema()
  5. 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 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());
    }
}

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