You are here

public function DefaultConfigTest::themeListDataProvider in Drupal 10

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php \Drupal\KernelTests\Config\DefaultConfigTest::themeListDataProvider()

A data provider that lists every theme in core.

Also adds a deprecated theme with config.

Return value

string[][] An array of theme names to test, with both key and value being the name of the theme.

File

core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php, line 145

Class

DefaultConfigTest
Tests that the installed config matches the default config.

Namespace

Drupal\KernelTests\Config

Code

public function themeListDataProvider() {
  $prefix = dirname(__DIR__, 4) . DIRECTORY_SEPARATOR . 'themes';
  $theme_dirs = array_keys(iterator_to_array(new \FilesystemIterator($prefix)));
  $theme_names = array_map(function ($path) use ($prefix) {
    return str_replace($prefix . DIRECTORY_SEPARATOR, '', $path);
  }, $theme_dirs);
  $themes_keyed = array_combine($theme_names, $theme_names);

  // Engines is not a theme.
  unset($themes_keyed['engines']);

  // Add a deprecated theme with config.
  $themes_keyed['test_deprecated_theme'] = 'test_deprecated_theme';
  return array_map(function ($theme) {
    return [
      $theme,
    ];
  }, $themes_keyed);
}