function ModuleInstallerTest::testCacheBinCleanup

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php \Drupal\KernelTests\Core\Extension\ModuleInstallerTest::testCacheBinCleanup()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php \Drupal\KernelTests\Core\Extension\ModuleInstallerTest::testCacheBinCleanup()
  3. 11.x 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 63

Class

ModuleInstallerTest
Tests the ModuleInstaller class.

Namespace

Drupal\KernelTests\Core\Extension

Code

public function testCacheBinCleanup() : void {
    $schema = $this->container
        ->get('database')
        ->schema();
    $table = 'cache_module_cache_bin';
    $module_installer = $this->container
        ->get('module_installer');
    $module_installer->install([
        'module_cache_bin',
    ]);
    // Prime the bin.
    
    /** @var \Drupal\Core\Cache\CacheBackendInterface $cache_bin */
    $cache_bin = $this->container
        ->get('module_cache_bin.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_cache_bin',
    ]);
    $this->assertFalse($schema->tableExists($table));
}

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