function ModuleHandlerTest::testProfileAllDependencies
Same name in other branches
- 9 core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php \Drupal\Tests\system\Kernel\Extension\ModuleHandlerTest::testProfileAllDependencies()
- 10 core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php \Drupal\Tests\system\Kernel\Extension\ModuleHandlerTest::testProfileAllDependencies()
- 11.x core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php \Drupal\Tests\system\Kernel\Extension\ModuleHandlerTest::testProfileAllDependencies()
Tests that a profile can supply only real dependencies
File
-
core/
modules/ system/ tests/ src/ Kernel/ Extension/ ModuleHandlerTest.php, line 234
Class
- ModuleHandlerTest
- Tests ModuleHandler functionality.
Namespace
Drupal\Tests\system\Kernel\ExtensionCode
public function testProfileAllDependencies() {
$profile = 'testing_install_profile_all_dependencies';
$dependencies = [
'dblog',
'ban',
];
$this->setInstallProfile($profile);
// Prime the drupal_get_filename() static cache with the location of the
// testing_install_profile_dependencies profile as it is not the currently
// active profile and we don't yet have any cached way to retrieve its
// location.
// @todo Remove as part of https://www.drupal.org/node/2186491
drupal_get_filename('profile', $profile, 'core/profiles/' . $profile . '/' . $profile . '.info.yml');
$this->enableModules([
'module_test',
$profile,
]);
$data = \Drupal::service('extension.list.module')->reset()
->getList();
foreach ($dependencies as $dependency) {
$this->assertArrayHasKey($dependency, $data[$profile]->requires);
}
$this->moduleInstaller()
->install($dependencies);
foreach ($dependencies as $dependency) {
$this->assertTrue($this->moduleHandler()
->moduleExists($dependency));
}
// Try uninstalling the dependencies.
$this->expectException(ModuleUninstallValidatorException::class);
$this->expectExceptionMessage('The following reasons prevent the modules from being uninstalled: The Testing install profile all dependencies module is required');
$this->moduleInstaller()
->uninstall($dependencies);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.