function IconTestTrait::createTestIcon

Create an icon.

Parameters

array $data: The icon data to create.

Return value

\Drupal\Core\Theme\Icon\IconDefinitionInterface The icon mocked.

1 call to IconTestTrait::createTestIcon()
IconTest::testPreRenderIcon in core/tests/Drupal/Tests/Core/Theme/Icon/IconTest.php
Test the Icon::preRenderIcon method.

File

core/tests/Drupal/Tests/Core/Theme/Icon/IconTestTrait.php, line 24

Class

IconTestTrait
Provides methods to generate icons for tests.

Namespace

Drupal\Tests\Core\Theme\Icon

Code

protected function createTestIcon(array $data = []) : IconDefinitionInterface {
    $filtered_data = $data;
    $keys = [
        'pack_id',
        'icon_id',
        'template',
        'source',
        'group',
    ];
    foreach ($keys as $key) {
        unset($filtered_data[$key]);
    }
    return IconDefinition::create($data['pack_id'] ?? 'foo', $data['icon_id'] ?? 'bar', $data['template'] ?? 'baz', $data['source'] ?? NULL, $data['group'] ?? NULL, $filtered_data);
}

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