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. 10 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 26

Class

BlockHtmlTest
Tests block HTML ID validity.

Namespace

Drupal\Tests\block\Functional

Code

protected function setUp() {
    parent::setUp();
    $this->drupalLogin($this->rootUser);
    // Enable the test_html block, to test HTML ID and attributes.
    \Drupal::state()->set('block_test.attributes', [
        'data-custom-attribute' => 'foo',
    ]);
    \Drupal::state()->set('block_test.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');
}

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