You are here

public function BlockTest::testUninstallTheme in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/block/tests/src/Functional/BlockTest.php \Drupal\Tests\block\Functional\BlockTest::testUninstallTheme()

Tests that uninstalling a theme removes its block configuration.

File

core/modules/block/tests/src/Functional/BlockTest.php, line 491

Class

BlockTest
Tests basic block functionality.

Namespace

Drupal\Tests\block\Functional

Code

public function testUninstallTheme() {

  /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
  $theme_installer = \Drupal::service('theme_installer');
  $theme_installer
    ->install([
    'seven',
  ]);
  $this
    ->config('system.theme')
    ->set('default', 'seven')
    ->save();
  $block = $this
    ->drupalPlaceBlock('system_powered_by_block', [
    'theme' => 'seven',
    'region' => 'help',
  ]);
  $this
    ->drupalGet('<front>');
  $this
    ->assertText('Powered by Drupal');
  $this
    ->config('system.theme')
    ->set('default', 'classy')
    ->save();
  $theme_installer
    ->uninstall([
    'seven',
  ]);

  // Ensure that the block configuration does not exist anymore.
  $this
    ->assertIdentical(NULL, Block::load($block
    ->id()));
}