function BlockBackwardCompatibilityTest::testAttributeCopy
Same name and namespace in other branches
- 11.x core/themes/stable9/tests/Unit/BlockBackwardCompatibilityTest.php \Drupal\Tests\stable9\Unit\BlockBackwardCompatibilityTest::testAttributeCopy()
Tests copying content attributes to the wrapper.
@legacy-covers \Drupal\stable9\Hook\Stable9Hooks::preprocessBlock()
File
-
core/
themes/ stable9/ tests/ Unit/ BlockBackwardCompatibilityTest.php, line 22
Class
- BlockBackwardCompatibilityTest
- Tests backward compatibility for block templates.
Namespace
Drupal\Tests\stable9\UnitCode
public function testAttributeCopy() : void {
$variables = [
'attributes' => [
'id' => 'test-block',
'class' => [
'wrapper-class',
],
],
'content' => [
'#attributes' => [
'class' => [
'content-class',
],
'data-foo' => 'bar',
],
],
];
$hooks = new Stable9Hooks();
$hooks->preprocessBlock($variables);
$expected = [
'attributes' => [
'id' => 'test-block',
'class' => [
'wrapper-class',
'content-class',
],
'data-foo' => 'bar',
],
'content' => [],
];
$this->assertEquals($expected, $variables);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.