function BlockHtmlTest::testHtml
Same name in other branches
- 8.9.x core/modules/block/tests/src/Functional/BlockHtmlTest.php \Drupal\Tests\block\Functional\BlockHtmlTest::testHtml()
- 10 core/modules/block/tests/src/Functional/BlockHtmlTest.php \Drupal\Tests\block\Functional\BlockHtmlTest::testHtml()
- 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\FunctionalCode
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.