function EnabledExtensionsValidatorTest::testExtensionRemoved
Tests that error is raised if Drupal modules, profiles or themes are removed.
@dataProvider providerExtensionRemoved
Parameters
array $packages: Packages that will be added to the active directory, and removed from the stage directory.
\Drupal\package_manager\ValidationResult[] $expected_results: The expected validation results.
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ EnabledExtensionsValidatorTest.php, line 102
Class
- EnabledExtensionsValidatorTest
- @covers \Drupal\package_manager\Validator\EnabledExtensionsValidator @group package_manager @internal
Namespace
Drupal\Tests\package_manager\KernelCode
public function testExtensionRemoved(array $packages, array $expected_results) : void {
$project_root = $this->container
->get(PathLocator::class)
->getProjectRoot();
$this->installComposerInstallers($project_root);
$active_manipulator = new ActiveFixtureManipulator();
$stage_manipulator = $this->getStageFixtureManipulator();
foreach ($packages as $package) {
$active_manipulator->addPackage($package, FALSE, TRUE);
$stage_manipulator->removePackage($package['name']);
}
$active_manipulator->commitChanges();
foreach ($packages as $package) {
$extension_name = str_replace('drupal/', '', $package['name']);
$extension = self::createExtension($project_root, $package['type'], $extension_name);
if ($extension->getType() === 'theme') {
/** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
$theme_handler = $this->container
->get('theme_handler');
$theme_handler->addTheme($extension);
$this->assertArrayHasKey($extension_name, $theme_handler->listInfo());
}
else {
/** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */
$module_handler = $this->container
->get('module_handler');
$module_list = $module_handler->getModuleList();
$module_list[$extension_name] = $extension;
$module_handler->setModuleList($module_list);
$this->assertArrayHasKey($extension_name, $module_handler->getModuleList());
}
}
$this->assertResults($expected_results, PreApplyEvent::class);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.