function FunctionalTestSetupTrait::installModulesFromClassProperty
Same name in other branches
- 9 core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\FunctionalTestSetupTrait::installModulesFromClassProperty()
- 10 core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\FunctionalTestSetupTrait::installModulesFromClassProperty()
- 11.x 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.
3 calls to FunctionalTestSetupTrait::installModulesFromClassProperty()
- BrowserTestBase::installDrupal in core/
tests/ Drupal/ Tests/ BrowserTestBase.php - Installs Drupal into the Simpletest site.
- WebDriverTestBase::installModulesFromClassProperty in core/
tests/ Drupal/ FunctionalJavascriptTests/ WebDriverTestBase.php - Install modules defined by `static::$modules`.
- WebTestBase::setUp in core/
modules/ simpletest/ src/ WebTestBase.php - Sets up a Drupal site for running functional and integration tests.
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 464
Class
- FunctionalTestSetupTrait
- Defines a trait for shared functional test setup functionality.
Namespace
Drupal\Core\TestCode
protected function installModulesFromClassProperty(ContainerInterface $container) {
$class = get_class($this);
$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();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.