UninstallKernelTest.php in Drupal 9
File
core/modules/system/tests/src/Kernel/Installer/UninstallKernelTest.php
View source
<?php
namespace Drupal\Tests\system\Kernel\Installer;
use Drupal\KernelTests\KernelTestBase;
use Drupal\module_test\PluginManagerCacheClearer;
class UninstallKernelTest extends KernelTestBase {
protected static $modules = [
'system',
'user',
'field',
'file',
'image',
'media',
];
protected function setUp() : void {
parent::setUp();
$this
->installSchema('user', [
'users_data',
]);
$this
->installEntitySchema('media');
$this
->installEntitySchema('file');
$this
->installConfig([
'media',
]);
}
public function testUninstallMedia() {
\Drupal::service('module_installer')
->uninstall([
'media',
]);
\Drupal::service('module_installer')
->uninstall([
'file',
]);
}
public function testUninstallPluginCacheClear() {
\Drupal::service('module_installer')
->install([
'module_test',
]);
$this
->assertFalse($this->container
->get('state')
->get(PluginManagerCacheClearer::class));
\Drupal::service('module_installer')
->install([
'dblog',
]);
$this
->assertTrue($this->container
->get('state')
->get(PluginManagerCacheClearer::class));
\Drupal::service('module_installer')
->uninstall([
'dblog',
]);
$this
->assertFalse($this->container
->get('state')
->get(PluginManagerCacheClearer::class));
$this->container
->get('state')
->delete(PluginManagerCacheClearer::class);
\Drupal::service('module_installer')
->uninstall([
'module_test',
]);
$this
->assertNull($this->container
->get('state')
->get(PluginManagerCacheClearer::class));
}
}