function BlockHtmlTest::setUp

Same name and namespace in other branches
  1. 9 core/modules/block/tests/src/Functional/BlockHtmlTest.php \Drupal\Tests\block\Functional\BlockHtmlTest::setUp()
  2. 8.9.x core/modules/block/tests/src/Functional/BlockHtmlTest.php \Drupal\Tests\block\Functional\BlockHtmlTest::setUp()
  3. 11.x core/modules/block/tests/src/Functional/BlockHtmlTest.php \Drupal\Tests\block\Functional\BlockHtmlTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/block/tests/src/Functional/BlockHtmlTest.php, line 29

Class

BlockHtmlTest
Tests block HTML ID validity.

Namespace

Drupal\Tests\block\Functional

Code

protected function setUp() : void {
  parent::setUp();
  $this->drupalLogin($this->drupalCreateUser([
    'administer blocks',
    'access administration pages',
  ]));
  // Enable the test_html block, to test HTML ID and attributes.
  \Drupal::keyValue('block_test')->set('attributes', [
    'data-custom-attribute' => 'foo',
  ]);
  \Drupal::keyValue('block_test')->set('content', $this->randomMachineName());
  $this->drupalPlaceBlock('test_html', [
    'id' => 'test_html_block',
  ]);
  // Enable a menu block, to test more complicated HTML.
  $this->drupalPlaceBlock('system_menu_block:admin', [
    'id' => 'test_menu_block',
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.