function HtmlAttributesTest::testThemeHtmlAttributes

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Theme/HtmlAttributesTest.php \Drupal\Tests\system\Functional\Theme\HtmlAttributesTest::testThemeHtmlAttributes()
  2. 10 core/modules/system/tests/src/Functional/Theme/HtmlAttributesTest.php \Drupal\Tests\system\Functional\Theme\HtmlAttributesTest::testThemeHtmlAttributes()
  3. 11.x core/modules/system/tests/src/Functional/Theme/HtmlAttributesTest.php \Drupal\Tests\system\Functional\Theme\HtmlAttributesTest::testThemeHtmlAttributes()

Tests that attributes in the 'html' and 'body' elements can be altered.

File

core/modules/system/tests/src/Functional/Theme/HtmlAttributesTest.php, line 29

Class

HtmlAttributesTest
Tests attributes inserted in the 'html' and 'body' elements on the page.

Namespace

Drupal\Tests\system\Functional\Theme

Code

public function testThemeHtmlAttributes() {
    $this->drupalGet('');
    $this->assertSession()
        ->responseContains('<html lang="en" dir="ltr" theme_test_html_attribute="theme test html attribute value">');
    $attributes = $this->xpath('/body[@theme_test_body_attribute="theme test body attribute value"]');
    $this->assertCount(1, $attributes, "Attribute set in the 'body' element via hook_preprocess_HOOK() found.");
}

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