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. 10 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 60

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));
}

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