3 namespace Drupal\Tests\block\Kernel;
5 use Drupal\block\Entity\Block;
6 use Drupal\Tests\SchemaCheckTestTrait;
7 use Drupal\KernelTests\KernelTestBase;
10 * Tests the block config schema.
14 class BlockConfigSchemaTest extends KernelTestBase {
16 use SchemaCheckTestTrait;
21 public static $modules = [
30 // BlockManager->getModuleName() calls system_get_info().
38 * The typed config manager.
40 * @var \Drupal\Core\Config\TypedConfigManagerInterface
42 protected $typedConfig;
47 * @var \Drupal\Core\Block\BlockManagerInterface
49 protected $blockManager;
54 protected function setUp() {
57 $this->typedConfig = \Drupal::service('config.typed');
58 $this->blockManager = \Drupal::service('plugin.manager.block');
59 $this->installEntitySchema('block_content');
60 $this->installEntitySchema('taxonomy_term');
61 $this->installEntitySchema('node');
62 $this->installSchema('book', ['book']);
66 * Tests the block config schema for block plugins.
68 public function testBlockConfigSchema() {
69 foreach ($this->blockManager->getDefinitions() as $block_id => $definition) {
70 $id = strtolower($this->randomMachineName());
71 $block = Block::create([
76 'region' => 'content',
77 'plugin' => $block_id,
79 'label' => $this->randomMachineName(),
80 'provider' => 'system',
81 'label_display' => FALSE,
87 $config = $this->config("block.block.$id");
88 $this->assertEqual($config->get('id'), $id);
89 $this->assertConfigSchema($this->typedConfig, $config->getName(), $config->get());