function ConfigImportUITest::testExtensionValidation
Same name in other branches
- 9 core/modules/config/tests/src/Functional/ConfigImportUITest.php \Drupal\Tests\config\Functional\ConfigImportUITest::testExtensionValidation()
- 8.9.x core/modules/config/tests/src/Functional/ConfigImportUITest.php \Drupal\Tests\config\Functional\ConfigImportUITest::testExtensionValidation()
- 11.x core/modules/config/tests/src/Functional/ConfigImportUITest.php \Drupal\Tests\config\Functional\ConfigImportUITest::testExtensionValidation()
Tests config importer cannot uninstall extensions which are depended on.
See also
\Drupal\Core\EventSubscriber\ConfigImportSubscriber
File
-
core/
modules/ config/ tests/ src/ Functional/ ConfigImportUITest.php, line 507
Class
- ConfigImportUITest
- Tests the user interface for importing configuration.
Namespace
Drupal\Tests\config\FunctionalCode
public function testExtensionValidation() : void {
\Drupal::service('module_installer')->install([
'node',
]);
\Drupal::service('theme_installer')->install([
'test_subtheme',
]);
$this->rebuildContainer();
$sync = $this->container
->get('config.storage.sync');
$this->copyConfig($this->container
->get('config.storage'), $sync);
$core = $sync->read('core.extension');
// Node depends on text.
unset($core['module']['text']);
$module_data = $this->container
->get('extension.list.module')
->getList();
$this->assertTrue(isset($module_data['node']->requires['text']), 'The Node module depends on the Text module.');
unset($core['theme']['test_basetheme']);
$theme_data = \Drupal::service('extension.list.theme')->reset()
->getList();
$this->assertTrue(isset($theme_data['test_subtheme']->requires['test_basetheme']), 'The Test Subtheme theme depends on the Test Basetheme theme.');
// This module does not exist.
$core['module']['does_not_exist'] = 0;
// This theme does not exist.
$core['theme']['does_not_exist'] = 0;
$sync->write('core.extension', $core);
$this->drupalGet('admin/config/development/configuration');
$this->submitForm([], 'Import all');
$this->assertSession()
->pageTextContains('The configuration cannot be imported because it failed validation for the following reasons:');
$this->assertSession()
->pageTextContains('Unable to uninstall the Text module since the Node module is installed.');
$this->assertSession()
->pageTextContains('Unable to uninstall the Theme test base theme theme since the Theme test subtheme theme is installed.');
$this->assertSession()
->pageTextContains('Unable to install the does_not_exist module since it does not exist.');
$this->assertSession()
->pageTextContains('Unable to install the does_not_exist theme since it does not exist.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.