public function AttributeTest::testChainAddRemoveClasses in Drupal 8
Same name and namespace in other branches
- 9 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 246
Class
- AttributeTest
- @coversDefaultClass \Drupal\Core\Template\Attribute @group Template
Namespace
Drupal\Tests\Core\TemplateCode
public function testChainAddRemoveClasses() {
$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
->assertArrayEquals($expected, $attribute['class']
->value(), 'Attributes chained');
}