function BlockStorageUnitTest::testDefaultBlocks

Same name in other branches
  1. 9 core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php \Drupal\Tests\block\Kernel\BlockStorageUnitTest::testDefaultBlocks()
  2. 8.9.x core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php \Drupal\Tests\block\Kernel\BlockStorageUnitTest::testDefaultBlocks()
  3. 11.x core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php \Drupal\Tests\block\Kernel\BlockStorageUnitTest::testDefaultBlocks()

Tests the installation of default blocks.

File

core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php, line 148

Class

BlockStorageUnitTest
Tests the storage of blocks.

Namespace

Drupal\Tests\block\Kernel

Code

public function testDefaultBlocks() : void {
    \Drupal::service('theme_installer')->install([
        'stark',
    ]);
    $entities = $this->controller
        ->loadMultiple();
    $this->assertEmpty($entities, 'There are no blocks initially.');
    // Install the block_test.module, so that its default config is installed.
    $this->installConfig([
        'block_test',
    ]);
    $entities = $this->controller
        ->loadMultiple();
    $entity = reset($entities);
    $this->assertEquals('test_block', $entity->id(), 'The default test block was loaded.');
}

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