3 namespace Drupal\Tests\block\Functional;
5 use Drupal\Tests\BrowserTestBase;
8 * Tests that a newly installed theme does not inherit blocks to its hidden
13 class BlockHiddenRegionTest extends BrowserTestBase {
16 * An administrative user to configure the test environment.
25 public static $modules = ['block', 'block_test', 'search'];
27 protected function setUp() {
30 // Create administrative user.
31 $this->adminUser = $this->drupalCreateUser([
38 $this->drupalLogin($this->adminUser);
39 $this->drupalPlaceBlock('search_form_block');
40 $this->drupalPlaceBlock('local_tasks_block');
44 * Tests that hidden regions do not inherit blocks when a theme is installed.
46 public function testBlockNotInHiddenRegion() {
48 // Ensure that the search form block is displayed.
50 $this->assertText('Search', 'Block was displayed on the front page.');
52 // Install "block_test_theme" and set it as the default theme.
53 $theme = 'block_test_theme';
54 // We need to install a non-hidden theme so that there is more than one
56 \Drupal::service('theme_handler')->install([$theme, 'stark']);
57 $this->config('system.theme')
58 ->set('default', $theme)
60 // Installing a theme will cause the kernel terminate event to rebuild the
61 // router. Simulate that here.
62 \Drupal::service('router.builder')->rebuildIfNeeded();
64 // Ensure that "block_test_theme" is set as the default theme.
65 $this->drupalGet('admin/structure/block');
66 $this->assertText('Block test theme(' . t('active tab') . ')', 'Default local task on blocks admin page is the block test theme.');
68 // Ensure that the search form block is displayed.
70 $this->assertText('Search', 'Block was displayed on the front page.');