function IconDefinitionTest::providerGetPreview

Data provider for ::testGetPreview().

Return value

\Generator Provide test data as icon data and expected result.

File

core/tests/Drupal/Tests/Core/Theme/Icon/IconDefinitionTest.php, line 245

Class

IconDefinitionTest
@coversDefaultClass \Drupal\Core\Theme\Icon\IconDefinition

Namespace

Drupal\Tests\Core\Theme\Icon

Code

public static function providerGetPreview() : iterable {
    (yield 'minimal icon' => [
        [
            'pack_id' => 'foo',
            'icon_id' => 'bar',
            'template' => 'baz',
        ],
        [],
        [
            '#icon_label' => 'Bar',
            '#icon_id' => 'bar',
            '#pack_id' => 'foo',
            '#extractor' => NULL,
            '#source' => NULL,
            '#library' => NULL,
            '#settings' => [],
        ],
    ]);
    (yield 'minimal icon with settings' => [
        [
            'pack_id' => 'foo',
            'icon_id' => 'bar',
            'template' => 'baz',
        ],
        [
            'baz' => 'corge',
            0 => 1,
            'grault',
        ],
        [
            '#icon_label' => 'Bar',
            '#icon_id' => 'bar',
            '#pack_id' => 'foo',
            '#extractor' => NULL,
            '#source' => NULL,
            '#library' => NULL,
            '#settings' => [
                'baz' => 'corge',
                0 => 1,
                1 => 'grault',
            ],
        ],
    ]);
    (yield 'icon with data and settings' => [
        [
            'pack_id' => 'foo',
            'icon_id' => 'bar',
            'template' => 'baz',
            'data' => [
                'extractor' => 'qux',
            ],
        ],
        [
            'baz' => 'corge',
        ],
        [
            '#icon_label' => 'Bar',
            '#icon_id' => 'bar',
            '#pack_id' => 'foo',
            '#extractor' => 'qux',
            '#source' => NULL,
            '#library' => NULL,
            '#settings' => [
                'baz' => 'corge',
            ],
        ],
    ]);
    (yield 'icon with data' => [
        [
            'pack_id' => 'foo',
            'icon_id' => 'bar',
            'template' => 'baz',
            'source' => 'quux',
            'data' => [
                'extractor' => 'qux',
                'library' => 'corge',
            ],
        ],
        [
            'baz' => 'corge',
        ],
        [
            '#icon_label' => 'Bar',
            '#icon_id' => 'bar',
            '#pack_id' => 'foo',
            '#extractor' => 'qux',
            '#source' => 'quux',
            '#library' => 'corge',
            '#settings' => [
                'baz' => 'corge',
            ],
        ],
    ]);
}

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