function ThemeTest::testAttributeMerging in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Theme/ThemeTest.php \Drupal\system\Tests\Theme\ThemeTest::testAttributeMerging()
Test attribute merging.
Render arrays that use a render element and templates (and hence call template_preprocess()) must ensure the attributes at different occasions are all merged correctly:
- $variables['attributes'] as passed in to _theme()
- the render element's #attributes
- any attributes set in the template's preprocessing function
File
- core/
modules/ system/ src/ Tests/ Theme/ ThemeTest.php, line 47 - Contains \Drupal\system\Tests\Theme\ThemeTest.
Class
- ThemeTest
- Tests low-level theme functions.
Namespace
Drupal\system\Tests\ThemeCode
function testAttributeMerging() {
$theme_test_render_element = array(
'elements' => array(
'#attributes' => array(
'data-foo' => 'bar',
),
),
'attributes' => array(
'id' => 'bazinga',
),
);
$this
->assertThemeOutput('theme_test_render_element', $theme_test_render_element, '<div id="bazinga" data-foo="bar" data-variables-are-preprocessed></div>' . "\n");
}