function ConfigImporterTest::testUninstallThemeIncrementsCount

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testUninstallThemeIncrementsCount()
  2. 10 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 909

Class

ConfigImporterTest
Tests importing configuration from files into active configuration.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testUninstallThemeIncrementsCount() : void {
    $theme_installer = $this->container
        ->get('theme_installer');
    // Install our theme.
    $theme = 'test_base_theme';
    $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->assertTrue($cron['logging']);
    $cron['logging'] = FALSE;
    $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.