protected function FunctionalTestSetupTrait::installModulesFromClassProperty in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\FunctionalTestSetupTrait::installModulesFromClassProperty()
- 9 core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\FunctionalTestSetupTrait::installModulesFromClassProperty()
Install modules defined by `static::$modules`.
To install test modules outside of the testing environment, add
$settings['extension_discovery_scan_tests'] = TRUE;
to your settings.php.
Parameters
\Symfony\Component\DependencyInjection\ContainerInterface $container: The container.
2 calls to FunctionalTestSetupTrait::installModulesFromClassProperty()
- BrowserTestBase::installDrupal in core/
tests/ Drupal/ Tests/ BrowserTestBase.php - Installs Drupal into the test site.
- WebDriverTestBase::installModulesFromClassProperty in core/
tests/ Drupal/ FunctionalJavascriptTests/ WebDriverTestBase.php - Install modules defined by `static::$modules`.
1 method overrides FunctionalTestSetupTrait::installModulesFromClassProperty()
- WebDriverTestBase::installModulesFromClassProperty in core/
tests/ Drupal/ FunctionalJavascriptTests/ WebDriverTestBase.php - Install modules defined by `static::$modules`.
File
- core/
lib/ Drupal/ Core/ Test/ FunctionalTestSetupTrait.php, line 462
Class
- FunctionalTestSetupTrait
- Defines a trait for shared functional test setup functionality.
Namespace
Drupal\Core\TestCode
protected function installModulesFromClassProperty(ContainerInterface $container) {
$class = static::class;
$modules = [];
while ($class) {
if (property_exists($class, 'modules')) {
$modules = array_merge($modules, $class::$modules);
}
$class = get_parent_class($class);
}
if ($modules) {
$modules = array_unique($modules);
try {
$success = $container
->get('module_installer')
->install($modules, TRUE);
$this
->assertTrue($success, new FormattableMarkup('Enabled modules: %modules', [
'%modules' => implode(', ', $modules),
]));
} catch (MissingDependencyException $e) {
// The exception message has all the details.
$this
->fail($e
->getMessage());
}
// The container was already rebuilt by the ModuleInstaller.
$this->container = \Drupal::getContainer();
}
}