function ConfigImporterTest::testUninstallThemeIncrementsCount
Same name in other branches
- 10 core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testUninstallThemeIncrementsCount()
- 11.x core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testUninstallThemeIncrementsCount()
Tests that uninstall a theme in config import correctly imports all config.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Config/ ConfigImporterTest.php, line 863
Class
- ConfigImporterTest
- Tests importing configuration from files into active configuration.
Namespace
Drupal\KernelTests\Core\ConfigCode
public function testUninstallThemeIncrementsCount() : void {
$theme_installer = $this->container
->get('theme_installer');
// Install our theme.
$theme = 'test_basetheme';
$theme_installer->install([
$theme,
]);
$this->assertTrue($this->container
->get('theme_handler')
->themeExists($theme));
$sync = $this->container
->get('config.storage.sync');
// Update 2 pieces of config in sync.
$systemSiteName = 'system.site';
$system = $sync->read($systemSiteName);
$system['name'] = 'Foo';
$sync->write($systemSiteName, $system);
$cronName = 'system.cron';
$cron = $sync->read($cronName);
$this->assertEquals(1, $cron['logging']);
$cron['logging'] = 0;
$sync->write($cronName, $cron);
// Uninstall the theme in sync.
$extensions = $sync->read('core.extension');
unset($extensions['theme'][$theme]);
$sync->write('core.extension', $extensions);
$this->configImporter()
->import();
// The theme should be uninstalled.
$this->assertFalse($this->container
->get('theme_handler')
->themeExists($theme));
// Both pieces of config should be updated.
\Drupal::configFactory()->reset($systemSiteName);
\Drupal::configFactory()->reset($cronName);
$this->assertEquals('Foo', $this->config($systemSiteName)
->get('name'));
$this->assertEquals(0, $this->config($cronName)
->get('logging'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.