You are here

public function BlockStorageUnitTest::testDefaultBlocks in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php \Drupal\Tests\block\Kernel\BlockStorageUnitTest::testDefaultBlocks()
  2. 10 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 145

Class

BlockStorageUnitTest
Tests the storage of blocks.

Namespace

Drupal\Tests\block\Kernel

Code

public function testDefaultBlocks() {
  \Drupal::service('theme_installer')
    ->install([
    'classy',
  ]);
  $entities = $this->controller
    ->loadMultiple();
  $this
    ->assertTrue(empty($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
    ->assertEqual($entity
    ->id(), 'test_block', 'The default test block was loaded.');
}