function SvgExtractorTest::providerLoadIconSvg

Data provider for ::testLoadIconSvg().

Return value

\Generator The test cases, icons data returned by SvgExtractor::discoverIcons.

File

core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/SvgExtractorTest.php, line 176

Class

SvgExtractorTest
@coversDefaultClass \Drupal\Core\Theme\Plugin\IconExtractor\SvgExtractor

Namespace

Drupal\Tests\Core\Theme\Icon\Plugin

Code

public static function providerLoadIconSvg() {
    (yield 'svg file empty' => [
        [
            [
                'icon_id' => 'foo',
                'source' => 'source/foo.svg',
                'absolute_path' => '/path/source/foo.svg',
            ],
        ],
        [
            '',
        ],
    ]);
    (yield 'svg file' => [
        [
            [
                'icon_id' => 'foo',
                'source' => 'source/foo.svg',
                'absolute_path' => '/path/source/foo.svg',
            ],
        ],
        [
            '<svg xmlns="https://www.w3.org/2000/svg"><g><path d="M8 15a.5.5 0 0 0"/></g></svg>',
        ],
        [
            '<g><path d="M8 15a.5.5 0 0 0"/></g>',
        ],
    ]);
    (yield 'svg file with group' => [
        [
            [
                'icon_id' => 'foo',
                'source' => 'source/foo.svg',
                'absolute_path' => '/path/source/foo.svg',
                'group' => 'bar',
            ],
        ],
        [
            '<svg xmlns="https://www.w3.org/2000/svg"><g><path d="M8 15a.5.5 0 0 0"/></g></svg>',
        ],
        [
            '<g><path d="M8 15a.5.5 0 0 0"/></g>',
        ],
    ]);
    (yield 'svg file with attributes' => [
        [
            [
                'icon_id' => 'foo',
                'source' => 'source/foo.svg',
                'absolute_path' => '/path/source/foo.svg',
            ],
        ],
        [
            '<svg xmlns="https://www.w3.org/2000/svg" data-foo="bar" data-baz="foo"><g><path d="M8 15a.5.5 0 0 0"/></g></svg>',
        ],
        [
            '<g><path d="M8 15a.5.5 0 0 0"/></g>',
        ],
        [
            [
                'data-foo' => 'bar',
                'data-baz' => 'foo',
            ],
        ],
    ]);
    (yield 'svg sprite is ignored' => [
        [
            [
                'icon_id' => 'foo',
                'source' => 'source/foo.svg',
                'absolute_path' => '/path/source/foo.svg',
            ],
        ],
        [
            '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><symbol id="foo"><g><path d="M8 15a.5.5 0 0 0"/></g></symbol>/svg>',
        ],
        [
            '',
        ],
    ]);
}

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