class BlockBackwardCompatibilityTest
Same name and namespace in other branches
- 11.x core/themes/stable9/tests/Unit/BlockBackwardCompatibilityTest.php \Drupal\Tests\stable9\Unit\BlockBackwardCompatibilityTest
Tests backward compatibility for block templates.
Attributes
#[Group('Theme')]
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\DrupalTestCaseTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\Tests\RandomGeneratorTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\stable9\Unit\BlockBackwardCompatibilityTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of BlockBackwardCompatibilityTest
File
-
core/
themes/ stable9/ tests/ Unit/ BlockBackwardCompatibilityTest.php, line 14
Namespace
Drupal\Tests\stable9\UnitView source
class BlockBackwardCompatibilityTest extends UnitTestCase {
/**
* Tests copying content attributes to the wrapper.
*
* @legacy-covers \Drupal\stable9\Hook\Stable9Hooks::preprocessBlock()
*/
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.