function StageConflictTest::testUninstallModuleDuringApply
Test uninstalling any module while the staged changes are being applied.
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ StageConflictTest.php, line 197
Class
- StageConflictTest
- @coversDefaultClass \Drupal\package_manager\SandboxManagerBase @covers \Drupal\package_manager\PackageManagerUninstallValidator @group package_manager @group #slow @internal
Namespace
Drupal\Tests\package_manager\KernelCode
public function testUninstallModuleDuringApply() : void {
$listener = function (PreApplyEvent $event) : void {
$this->assertTrue($event->sandboxManager
->isApplying());
// Trying to uninstall any module while the stage is being applied should
// result in a module uninstall validation error.
try {
$this->container
->get('module_installer')
->uninstall([
'package_manager_bypass',
]);
$this->fail('Expected an exception to be thrown while uninstalling a module.');
} catch (ModuleUninstallValidatorException $e) {
$this->assertStringContainsString('Modules cannot be uninstalled while Package Manager is applying staged changes to the active code base.', $e->getMessage());
}
};
$this->addEventTestListener($listener);
$stage = $this->createStage();
$stage->create();
$stage->require([
'ext-json:*',
]);
$stage->apply();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.