function AttributeTest::testTwigAddRemoveClasses
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::testTwigAddRemoveClasses()
- 10 core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::testTwigAddRemoveClasses()
- 11.x core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::testTwigAddRemoveClasses()
Tests the twig calls to the Attribute. @dataProvider providerTestAttributeClassHelpers
@covers ::removeClass @covers ::addClass
File
-
core/
tests/ Drupal/ Tests/ Core/ Template/ AttributeTest.php, line 267
Class
- AttributeTest
- @coversDefaultClass \Drupal\Core\Template\Attribute @group Template
Namespace
Drupal\Tests\Core\TemplateCode
public function testTwigAddRemoveClasses($template, $expected, $seed_attributes = []) {
$loader = new StringLoader();
$twig = new Environment($loader);
$data = [
'attributes' => new Attribute($seed_attributes),
];
$result = $twig->createTemplate($template)
->render($data);
$this->assertEquals($expected, $result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.