class BlockHiddenRegionTest
Same name and namespace in other branches
- 11.x core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php \Drupal\Tests\block\Functional\BlockHiddenRegionTest
- 10 core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php \Drupal\Tests\block\Functional\BlockHiddenRegionTest
- 8.9.x core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php \Drupal\Tests\block\Functional\BlockHiddenRegionTest
Tests that blocks are not added to hidden regions on theme installation.
@group block
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\block\Functional\BlockHiddenRegionTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of BlockHiddenRegionTest
File
-
core/
modules/ block/ tests/ src/ Functional/ BlockHiddenRegionTest.php, line 12
Namespace
Drupal\Tests\block\FunctionalView source
class BlockHiddenRegionTest extends BrowserTestBase {
/**
* An administrative user to configure the test environment.
*/
protected $adminUser;
/**
* Modules to install.
*
* @var array
*/
protected static $modules = [
'block',
'block_test',
'search',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
// Create administrative user.
$this->adminUser = $this->drupalCreateUser([
'administer blocks',
'administer themes',
'search content',
]);
$this->drupalLogin($this->adminUser);
$this->drupalPlaceBlock('search_form_block');
$this->drupalPlaceBlock('local_tasks_block');
}
/**
* Tests that hidden regions do not inherit blocks when a theme is installed.
*/
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');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.