You are here

public function AttributeTest::testTwigAddRemoveClasses in Drupal 9

Same name and namespace in other branches
  1. 8 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\Template

Code

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);
}