function BlockUiTest::testBlockDemoUiPage
Same name in other branches
- 9 core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::testBlockDemoUiPage()
- 10 core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::testBlockDemoUiPage()
- 11.x core/modules/block/tests/src/Functional/BlockUiTest.php \Drupal\Tests\block\Functional\BlockUiTest::testBlockDemoUiPage()
Test block demo page exists and functions correctly.
File
-
core/
modules/ block/ tests/ src/ Functional/ BlockUiTest.php, line 85
Class
- BlockUiTest
- Tests that the block configuration UI exists and stores data correctly.
Namespace
Drupal\Tests\block\FunctionalCode
public function testBlockDemoUiPage() {
$this->drupalPlaceBlock('help_block', [
'region' => 'help',
]);
$this->drupalGet('admin/structure/block');
$this->clickLink(t('Demonstrate block regions (@theme)', [
'@theme' => 'Classy',
]));
$elements = $this->xpath('//div[contains(@class, "region-highlighted")]/div[contains(@class, "block-region") and contains(text(), :title)]', [
':title' => 'Highlighted',
]);
$this->assertTrue(!empty($elements), 'Block demo regions are shown.');
// Ensure that other themes can use the block demo page.
\Drupal::service('theme_installer')->install([
'test_theme',
]);
$this->drupalGet('admin/structure/block/demo/test_theme');
$this->assertEscaped('<strong>Test theme</strong>');
// Ensure that a hidden theme cannot use the block demo page.
\Drupal::service('theme_installer')->install([
'stable',
]);
$this->drupalGet('admin/structure/block/demo/stable');
$this->assertSession()
->statusCodeEquals(404);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.