function UninstallKernelTest::testUninstallPluginCacheClear

Same name in other branches
  1. 9 core/modules/system/tests/src/Kernel/Installer/UninstallKernelTest.php \Drupal\Tests\system\Kernel\Installer\UninstallKernelTest::testUninstallPluginCacheClear()
  2. 11.x core/modules/system/tests/src/Kernel/Installer/UninstallKernelTest.php \Drupal\Tests\system\Kernel\Installer\UninstallKernelTest::testUninstallPluginCacheClear()

Tests uninstalling a module with a plugin cache clearer service.

File

core/modules/system/tests/src/Kernel/Installer/UninstallKernelTest.php, line 55

Class

UninstallKernelTest
Tests the uninstallation of modules.

Namespace

Drupal\Tests\system\Kernel\Installer

Code

public function testUninstallPluginCacheClear() : void {
    \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));
    // The plugin cache clearer service should be called during dblog uninstall
    // without the dependency.
    \Drupal::service('module_installer')->uninstall([
        'dblog',
    ]);
    $this->assertFalse($this->container
        ->get('state')
        ->get(PluginManagerCacheClearer::class));
    // The service should not be called during module_test uninstall.
    $this->container
        ->get('state')
        ->delete(PluginManagerCacheClearer::class);
    \Drupal::service('module_installer')->uninstall([
        'module_test',
    ]);
    $this->assertNull($this->container
        ->get('state')
        ->get(PluginManagerCacheClearer::class));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.