Version 1
[yaffs-website] / web / core / modules / system / src / Tests / Theme / HtmlAttributesTest.php
1 <?php
2
3 namespace Drupal\system\Tests\Theme;
4
5 use Drupal\simpletest\WebTestBase;
6
7 /**
8  * Tests attributes inserted in the 'html' and 'body' elements on the page.
9  *
10  * @group Theme
11  */
12 class HtmlAttributesTest extends WebTestBase {
13
14   /**
15    * Modules to enable.
16    *
17    * @var array
18    */
19   public static $modules = ['theme_test'];
20
21   /**
22    * Tests that attributes in the 'html' and 'body' elements can be altered.
23    */
24   public function testThemeHtmlAttributes() {
25     $this->drupalGet('');
26     $attributes = $this->xpath('/html[@theme_test_html_attribute="theme test html attribute value"]');
27     $this->assertTrue(count($attributes) == 1, "Attribute set in the 'html' element via hook_preprocess_HOOK() found.");
28     $attributes = $this->xpath('/html/body[@theme_test_body_attribute="theme test body attribute value"]');
29     $this->assertTrue(count($attributes) == 1, "Attribute set in the 'body' element via hook_preprocess_HOOK() found.");
30   }
31
32 }