function DrupalFlushAllCachesTest::testDrupalFlushAllCachesModuleList

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Common/DrupalFlushAllCachesTest.php \Drupal\KernelTests\Core\Common\DrupalFlushAllCachesTest::testDrupalFlushAllCachesModuleList()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Common/DrupalFlushAllCachesTest.php \Drupal\KernelTests\Core\Common\DrupalFlushAllCachesTest::testDrupalFlushAllCachesModuleList()
  3. 10 core/tests/Drupal/KernelTests/Core/Common/DrupalFlushAllCachesTest.php \Drupal\KernelTests\Core\Common\DrupalFlushAllCachesTest::testDrupalFlushAllCachesModuleList()

Tests that drupal_flush_all_caches() uses core.extension properly.

File

core/tests/Drupal/KernelTests/Core/Common/DrupalFlushAllCachesTest.php, line 31

Class

DrupalFlushAllCachesTest
@covers ::drupal_flush_all_caches @group Common

Namespace

Drupal\KernelTests\Core\Common

Code

public function testDrupalFlushAllCachesModuleList() : void {
    $this->assertFalse(function_exists('system_test_help'));
    $core_extension = \Drupal::configFactory()->getEditable('core.extension');
    $module = $core_extension->get('module');
    $module['system_test'] = -10;
    $core_extension->set('module', module_config_sort($module))
        ->save();
    $this->containerBuilds = 0;
    drupal_flush_all_caches();
    $module_list = [
        'system_test',
        'system',
    ];
    $database_module = \Drupal::database()->getProvider();
    if ($database_module !== 'core') {
        $module_list[] = $database_module;
    }
    sort($module_list);
    $container_modules = array_keys($this->container
        ->getParameter('container.modules'));
    sort($container_modules);
    $this->assertSame($module_list, $container_modules);
    $this->assertSame(1, $this->containerBuilds);
    $this->assertTrue(function_exists('system_test_help'));
    $core_extension->clear('module.system_test')
        ->save();
    $this->containerBuilds = 0;
    drupal_flush_all_caches();
    $module_list = [
        'system',
    ];
    if ($database_module !== 'core') {
        $module_list[] = $database_module;
    }
    sort($module_list);
    $container_modules = array_keys($this->container
        ->getParameter('container.modules'));
    sort($container_modules);
    $this->assertSame($module_list, $container_modules);
    $this->assertSame(1, $this->containerBuilds);
}

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