HtmlAttributesTest.php

Same filename in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/Theme/HtmlAttributesTest.php
  2. 10 core/modules/system/tests/src/Functional/Theme/HtmlAttributesTest.php
  3. 11.x core/modules/system/tests/src/Functional/Theme/HtmlAttributesTest.php

Namespace

Drupal\Tests\system\Functional\Theme

File

core/modules/system/tests/src/Functional/Theme/HtmlAttributesTest.php

View source
<?php

namespace Drupal\Tests\system\Functional\Theme;

use Drupal\Tests\BrowserTestBase;

/**
 * Tests attributes inserted in the 'html' and 'body' elements on the page.
 *
 * @group Theme
 */
class HtmlAttributesTest extends BrowserTestBase {
    
    /**
     * Modules to enable.
     *
     * @var array
     */
    protected static $modules = [
        'theme_test',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected $defaultTheme = 'stark';
    
    /**
     * Tests that attributes in the 'html' and 'body' elements can be altered.
     */
    public function testThemeHtmlAttributes() {
        $this->drupalGet('');
        $this->assertSession()
            ->responseContains('<html lang="en" dir="ltr" theme_test_html_attribute="theme test html attribute value">');
        $this->assertSession()
            ->elementsCount('xpath', '/body[@theme_test_body_attribute="theme test body attribute value"]', 1);
    }

}

Classes

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

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