function AttributeTest::testChainAddRemoveClasses
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::testChainAddRemoveClasses()
- 8.9.x core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::testChainAddRemoveClasses()
- 10 core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::testChainAddRemoveClasses()
Tests removing class attributes with the Attribute helper methods. @covers ::removeClass @covers ::addClass
File
-
core/
tests/ Drupal/ Tests/ Core/ Template/ AttributeTest.php, line 253
Class
- AttributeTest
- @coversDefaultClass \Drupal\Core\Template\Attribute @group Template
Namespace
Drupal\Tests\Core\TemplateCode
public function testChainAddRemoveClasses() : void {
$attribute = new Attribute([
'class' => [
'example-class',
'red',
'green',
'blue',
],
]);
$attribute->removeClass([
'red',
'green',
'pink',
])
->addClass([
'apple',
'lime',
'grapefruit',
])
->addClass([
'banana',
]);
$expected = [
'example-class',
'blue',
'apple',
'lime',
'grapefruit',
'banana',
];
$this->assertEquals($expected, $attribute['class']->value(), 'Attributes chained');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.