function KernelTestBase::getModulesToEnable

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::getModulesToEnable()
  2. 8.9.x core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::getModulesToEnable()
  3. 10 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::getModulesToEnable()

Returns the modules to enable for this test.

Parameters

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

Return value

array

1 call to KernelTestBase::getModulesToEnable()
KernelTestBase::bootKernel in core/tests/Drupal/KernelTests/KernelTestBase.php
Bootstraps a kernel for a test.

File

core/tests/Drupal/KernelTests/KernelTestBase.php, line 984

Class

KernelTestBase
Base class for functional integration tests.

Namespace

Drupal\KernelTests

Code

private static function getModulesToEnable($class) {
    $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_values(array_reverse($modules));
    return call_user_func_array('array_merge_recursive', $modules);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.