You are here

public function ModuleInstallerTest::testCacheBinCleanup in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php \Drupal\KernelTests\Core\Extension\ModuleInstallerTest::testCacheBinCleanup()
  2. 9 core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php \Drupal\KernelTests\Core\Extension\ModuleInstallerTest::testCacheBinCleanup()

Tests cache bins defined by modules are removed when uninstalled.

@covers ::removeCacheBins

File

core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php, line 61

Class

ModuleInstallerTest
Tests the ModuleInstaller class.

Namespace

Drupal\KernelTests\Core\Extension

Code

public function testCacheBinCleanup() {
  $schema = $this->container
    ->get('database')
    ->schema();
  $table = 'cache_module_cachebin';
  $module_installer = $this->container
    ->get('module_installer');
  $module_installer
    ->install([
    'module_cachebin',
  ]);

  // Prime the bin.

  /** @var \Drupal\Core\Cache\CacheBackendInterface $cache_bin */
  $cache_bin = $this->container
    ->get('module_cachebin.cache_bin');
  $cache_bin
    ->set('foo', 'bar');

  // A database backend is used so there is a convenient way check whether the
  // backend is uninstalled.
  $this
    ->assertTrue($schema
    ->tableExists($table));
  $module_installer
    ->uninstall([
    'module_cachebin',
  ]);
  $this
    ->assertFalse($schema
    ->tableExists($table));
}