You are here

public function BlockUiTest::testBlockDemoUiPage in Drupal 8

Same name and namespace in other branches
  1. 9 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\Functional

Code

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);
}