You are here

trait FileSystemModuleDiscoveryDataProviderTrait in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/FileSystemModuleDiscoveryDataProviderTrait.php \Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait

A trait used in testing for providing a list of modules in a dataProvider.

Hierarchy

11 files declare their use of FileSystemModuleDiscoveryDataProviderTrait
DefaultConfigTest.php in core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php
DestinationCategoryTest.php in core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/DestinationCategoryTest.php
MigrateDrupal6AuditIdsTest.php in core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php
MigrateDrupal7AuditIdsTest.php in core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php
MigrationLabelExistTest.php in core/modules/migrate_drupal_ui/tests/src/Kernel/MigrationLabelExistTest.php

... See full list

File

core/tests/Drupal/KernelTests/FileSystemModuleDiscoveryDataProviderTrait.php, line 8

Namespace

Drupal\KernelTests
View source
trait FileSystemModuleDiscoveryDataProviderTrait {

  /**
   * A data provider that lists every module in core.
   *
   * @return array
   *   An array of module names to test.
   */
  public function coreModuleListDataProvider() {
    $prefix = dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'modules';
    $module_dirs = array_keys(iterator_to_array(new \FilesystemIterator($prefix)));
    $module_names = array_map(function ($path) use ($prefix) {
      return str_replace($prefix . DIRECTORY_SEPARATOR, '', $path);
    }, $module_dirs);
    $modules_keyed = array_combine($module_names, $module_names);
    $data = array_map(function ($module) {
      return [
        $module,
      ];
    }, $modules_keyed);
    return $data;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FileSystemModuleDiscoveryDataProviderTrait::coreModuleListDataProvider public function A data provider that lists every module in core.