trait IconTestTrait

Provides methods to generate icons for tests.

Hierarchy

3 files declare their use of IconTestTrait
PathExtractorTest.php in core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/PathExtractorTest.php
SvgExtractorTest.php in core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/SvgExtractorTest.php
SvgSpriteExtractorTest.php in core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/SvgSpriteExtractorTest.php

File

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

Namespace

Drupal\Tests\Core\Theme\Icon
View source
trait IconTestTrait {
  
  /**
   * Create an icon.
   *
   * @param array $data
   *   The icon data to create.
   *
   * @return \Drupal\Core\Theme\Icon\IconDefinitionInterface
   *   The icon mocked.
   */
  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);
  }

}

Members

Title Sort descending Modifiers Object type Summary
IconTestTrait::createTestIcon protected function Create an icon.

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