public function UpdatePathTestBaseTest::testModuleListChange in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php \Drupal\FunctionalTests\Update\UpdatePathTestBaseTest::testModuleListChange()
- 10 core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBaseTest.php \Drupal\FunctionalTests\Update\UpdatePathTestBaseTest::testModuleListChange()
Tests that test running environment is updated when module list changes.
See also
update_test_schema_update_8003()
File
- core/
tests/ Drupal/ FunctionalTests/ Update/ UpdatePathTestBaseTest.php, line 158
Class
- UpdatePathTestBaseTest
- Tests the update path base class.
Namespace
Drupal\FunctionalTests\UpdateCode
public function testModuleListChange() {
// Set a value in the cache to prove caches are cleared.
\Drupal::service('cache.default')
->set(__CLASS__, 'Test');
// Ensure that modules are installed and uninstalled as expected prior to
// running updates.
$extension_config = $this
->config('core.extension')
->get();
$this
->assertArrayHasKey('page_cache', $extension_config['module']);
$this
->assertArrayNotHasKey('module_test', $extension_config['module']);
$module_list = \Drupal::moduleHandler()
->getModuleList();
$this
->assertArrayHasKey('page_cache', $module_list);
$this
->assertArrayNotHasKey('module_test', $module_list);
$namespaces = \Drupal::getContainer()
->getParameter('container.namespaces');
$this
->assertArrayHasKey('Drupal\\page_cache', $namespaces);
$this
->assertArrayNotHasKey('Drupal\\module_test', $namespaces);
// Increment the schema version so that update_test_schema_update_8003()
// runs.
\Drupal::state()
->set('update_test_schema_version', 8003);
$this
->runUpdates();
// Ensure that test running environment has been updated with the changes to
// the module list.
$extension_config = $this
->config('core.extension')
->get();
$this
->assertArrayNotHasKey('page_cache', $extension_config['module']);
$this
->assertArrayHasKey('module_test', $extension_config['module']);
$module_list = \Drupal::moduleHandler()
->getModuleList();
$this
->assertArrayNotHasKey('page_cache', $module_list);
$this
->assertArrayHasKey('module_test', $module_list);
$namespaces = \Drupal::getContainer()
->getParameter('container.namespaces');
$this
->assertArrayNotHasKey('Drupal\\page_cache', $namespaces);
$this
->assertArrayHasKey('Drupal\\module_test', $namespaces);
// Ensure the test runners cache has been cleared.
$this
->assertFalse(\Drupal::service('cache.default')
->get(__CLASS__));
}