You are here

public function BlockHiddenRegionTest::testBlockNotInHiddenRegion in Drupal 10

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

Tests that hidden regions do not inherit blocks when a theme is installed.

File

core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php, line 51

Class

BlockHiddenRegionTest
Tests that a newly installed theme does not inherit blocks to its hidden regions.

Namespace

Drupal\Tests\block\Functional

Code

public function testBlockNotInHiddenRegion() {

  // Ensure that the search form block is displayed.
  $this
    ->drupalGet('');
  $this
    ->assertSession()
    ->pageTextContains('Search');

  // Install "block_test_theme" and set it as the default theme.
  $theme = 'block_test_theme';

  // We need to install a non-hidden theme so that there is more than one
  // local task.
  \Drupal::service('theme_installer')
    ->install([
    $theme,
    'stark',
  ]);
  $this
    ->config('system.theme')
    ->set('default', $theme)
    ->save();

  // Installing a theme will cause the kernel terminate event to rebuild the
  // router. Simulate that here.
  \Drupal::service('router.builder')
    ->rebuildIfNeeded();

  // Ensure that "block_test_theme" is set as the default theme.
  $this
    ->drupalGet('admin/structure/block');
  $this
    ->assertSession()
    ->pageTextContains('Block test theme(active tab)');

  // Ensure that the search form block is displayed.
  $this
    ->drupalGet('');
  $this
    ->assertSession()
    ->pageTextContains('Search');
}