You are here

public function BlockUiTest::testBlockDemoUiPage in Drupal 9

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

Tests block demo page exists and functions correctly.

File

core/modules/block/tests/src/Functional/BlockUiTest.php, line 92

Class

BlockUiTest
Tests that the block configuration UI exists and stores data correctly.

Namespace

Drupal\Tests\block\Functional

Code

public function testBlockDemoUiPage() {
  $this
    ->drupalPlaceBlock('help_block', [
    'region' => 'help',
  ]);
  $this
    ->drupalGet('admin/structure/block');
  $this
    ->clickLink('Demonstrate block regions (Classy)');
  $this
    ->assertSession()
    ->elementExists('xpath', '//div[contains(@class, "region-highlighted")]/div[contains(@class, "block-region") and contains(text(), "Highlighted")]');

  // 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
    ->assertSession()
    ->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);
}