You are here

private static function MenuLinkFormatterTest::getModulesToEnable in Menu Link (Field) 8

Returns the modules to enable for this test.

Parameters

string $class: The fully-qualified class name of this test.

Return value

array

Overrides KernelTestBase::getModulesToEnable

1 call to MenuLinkFormatterTest::getModulesToEnable()
MenuLinkFormatterTest::bootKernel in tests/src/Kernel/MenuLinkFormatterTest.php
Bootstraps a kernel for a test.

File

tests/src/Kernel/MenuLinkFormatterTest.php, line 167

Class

MenuLinkFormatterTest
Tests the menu link field formatters.

Namespace

Drupal\Tests\menu_link\Kernel

Code

private static function getModulesToEnable(string $class) : array {
  $modules = [];
  while ($class) {
    if (property_exists($class, 'modules')) {

      // Only add the modules, if the $modules property was not inherited.
      $rp = new \ReflectionProperty($class, 'modules');
      if ($rp->class === $class) {
        $modules[$class] = $class::$modules;
      }
    }
    $class = get_parent_class($class);
  }

  // Modules have been collected in reverse class hierarchy order; modules
  // defined by base classes should be sorted first. Then, merge the results
  // together.
  $modules = array_reverse($modules);
  return call_user_func_array('array_merge_recursive', $modules);
}