You are here

protected function PluginTypeManagerTest::setUp in Plugin 8.2

Same name in this branch
  1. 8.2 tests/src/Unit/PluginType/PluginTypeManagerTest.php \Drupal\Tests\plugin\Unit\PluginType\PluginTypeManagerTest::setUp()
  2. 8.2 tests/src/Kernel/PluginType/PluginTypeManagerTest.php \Drupal\Tests\plugin\Kernel\PluginType\PluginTypeManagerTest::setUp()

Overrides KernelTestBase::setUp

File

tests/src/Kernel/PluginType/PluginTypeManagerTest.php, line 23

Class

PluginTypeManagerTest
@coversDefaultClass \Drupal\plugin\PluginType\PluginTypeManager

Namespace

Drupal\Tests\plugin\Kernel\PluginType

Code

protected function setUp() : void {

  // Get any directory within Drupal core.
  $class_reflector = new \ReflectionClass(KernelTestBase::class);
  $directory = $class_reflector
    ->getFileName();

  // Find Drupal core's module directory.
  while ($directory = dirname($directory)) {
    $core_module_directory = $directory . '/core/modules';
    if (file_exists($core_module_directory)) {
      break;
    }
  }

  // Find the names of Drupal core modules.
  $module_directories = array_keys(iterator_to_array(new \FilesystemIterator($core_module_directory)));
  $module_names = array_map(function ($module_directory) {
    return basename($module_directory);
  }, $module_directories);

  // Set all Drupal core modules to be enabled for this test.
  static::$modules = array_merge(static::$modules, $module_names);
  parent::setUp();
}