function AttributeTest::testTwigAddRemoveClasses

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::testTwigAddRemoveClasses()
  2. 10 core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::testTwigAddRemoveClasses()
  3. 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 266

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 \Twig_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.