You are here

function BlockHtmlTest::testHtml in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/block/src/Tests/BlockHtmlTest.php \Drupal\block\Tests\BlockHtmlTest::testHtml()

Tests for valid HTML for a block.

File

core/modules/block/src/Tests/BlockHtmlTest.php, line 43
Contains \Drupal\block\Tests\BlockHtmlTest.

Class

BlockHtmlTest
Tests block HTML ID validity.

Namespace

Drupal\block\Tests

Code

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
    ->assertFieldByXPath('//div[@id="block-test-html-block" and @data-custom-attribute="foo"]', NULL, 'HTML ID and attributes for test block are valid and on the same DOM element.');

  // Ensure expected markup for a menu block.
  $elements = $this
    ->xpath('//nav[contains(@class, :nav-class)]/ul[contains(@class, :ul-class)]/li', array(
    ':nav-class' => 'block-menu',
    ':ul-class' => 'menu',
  ));
  $this
    ->assertTrue(!empty($elements), 'The proper block markup was found.');
}