function BlockHtmlTest::testHtml

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

Tests for valid HTML for a block.

File

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

Class

BlockHtmlTest
Tests block HTML ID validity.

Namespace

Drupal\Tests\block\Functional

Code

public function testHtml() {
    $this->drupalGet('');
    // Ensure that a block's ID is converted to an HTML valid ID, and that
    // block-specific attributes are added to the same DOM element.
    $this->assertSession()
        ->elementExists('xpath', '//div[@id="block-test-html-block" and @data-custom-attribute="foo"]');
    // Ensure expected markup for a menu block.
    $this->assertSession()
        ->elementExists('xpath', '//nav[@id="block-test-menu-block"]/ul/li');
}

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