function AttributeTest::providerTestAttributeClassHelpers

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::providerTestAttributeClassHelpers()
  2. 8.9.x core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::providerTestAttributeClassHelpers()
  3. 10 core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::providerTestAttributeClassHelpers()

Provides tests data for testEscaping.

Return value

array An array of test data each containing of a twig template string, a resulting string of classes and an optional array of attributes.

File

core/tests/Drupal/Tests/Core/Template/AttributeTest.php, line 288

Class

AttributeTest
@coversDefaultClass \Drupal\Core\Template\Attribute @group Template

Namespace

Drupal\Tests\Core\Template

Code

public static function providerTestAttributeClassHelpers() {
    // cSpell:disable
    return [
        [
            "{{ attributes.class }}",
            '',
        ],
        [
            "{{ attributes.addClass('everest').class }}",
            'everest',
        ],
        [
            "{{ attributes.addClass(['k2', 'kangchenjunga']).class }}",
            'k2 kangchenjunga',
        ],
        [
            "{{ attributes.addClass('lhotse', 'makalu', 'cho-oyu').class }}",
            'lhotse makalu cho-oyu',
        ],
        [
            "{{ attributes.addClass('nanga-parbat').class }}",
            'dhaulagiri manaslu nanga-parbat',
            [
                'class' => [
                    'dhaulagiri',
                    'manaslu',
                ],
            ],
        ],
        [
            "{{ attributes.removeClass('annapurna').class }}",
            'gasherbrum-i',
            [
                'class' => [
                    'annapurna',
                    'gasherbrum-i',
                ],
            ],
        ],
        [
            "{{ attributes.removeClass(['broad peak']).class }}",
            'gasherbrum-ii',
            [
                'class' => [
                    'broad peak',
                    'gasherbrum-ii',
                ],
            ],
        ],
        [
            "{{ attributes.removeClass('gyachung-kang', 'shishapangma').class }}",
            '',
            [
                'class' => [
                    'shishapangma',
                    'gyachung-kang',
                ],
            ],
        ],
        [
            "{{ attributes.removeClass('nuptse').addClass('annapurna-ii').class }}",
            'himalchuli annapurna-ii',
            [
                'class' => [
                    'himalchuli',
                    'nuptse',
                ],
            ],
        ],
        // Test for the removal of an empty class name.
[
            "{{ attributes.addClass('rakaposhi', '').class }}",
            'rakaposhi',
        ],
    ];
    // cSpell:enable
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.