You are here

private function FactoryMapperTest::getFactoryClassNamesFromFilesystem in Hook Event Dispatcher 8

Get the Factory class names from the filesystems directory.

Return value

array Class names array.

1 call to FactoryMapperTest::getFactoryClassNamesFromFilesystem()
FactoryMapperTest::testYamlHasAllFactories in tests/src/Unit/Preprocess/FactoryMapperTest.php
Test if all factories are in the YAML file.

File

tests/src/Unit/Preprocess/FactoryMapperTest.php, line 49

Class

FactoryMapperTest
Class FactoryMapperTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Preprocess

Code

private function getFactoryClassNamesFromFilesystem() {
  $files = \scandir(\dirname(\dirname(\dirname(\dirname(__DIR__)))) . '/src/Event/Preprocess/Factory', SCANDIR_SORT_NONE);
  $invalidFactories = [
    '.',
    '..',
    'PreprocessEventFactoryInterface.php',
  ];
  $files = \array_filter($files, function ($file) use ($invalidFactories) {
    return !\in_array($file, $invalidFactories, TRUE);
  });
  $classNames = [];
  foreach ($files as $file) {
    $classNames[] = 'Drupal\\hook_event_dispatcher\\Event\\Preprocess\\Factory\\' . \substr($file, 0, -4);
  }
  return $classNames;
}