function ConfigImporterTest::testInstallBaseAndSubThemes

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testInstallBaseAndSubThemes()
  2. 11.x core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php \Drupal\KernelTests\Core\Config\ConfigImporterTest::testInstallBaseAndSubThemes()

Tests installing a base themes and sub themes during configuration import.

See also

\Drupal\Core\EventSubscriber\ConfigImportSubscriber

File

core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php, line 694

Class

ConfigImporterTest
Tests importing configuration from files into active configuration.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testInstallBaseAndSubThemes() {
    $sync = $this->container
        ->get('config.storage.sync');
    $extensions = $sync->read('core.extension');
    $extensions['theme']['test_basetheme'] = 0;
    $extensions['theme']['test_subtheme'] = 0;
    $extensions['theme']['test_subsubtheme'] = 0;
    $sync->write('core.extension', $extensions);
    $config_importer = $this->configImporter();
    $config_importer->import();
    $this->assertTrue($this->container
        ->get('theme_handler')
        ->themeExists('test_basetheme'));
    $this->assertTrue($this->container
        ->get('theme_handler')
        ->themeExists('test_subsubtheme'));
    $this->assertTrue($this->container
        ->get('theme_handler')
        ->themeExists('test_subtheme'));
    // Test uninstalling them.
    $extensions = $sync->read('core.extension');
    unset($extensions['theme']['test_basetheme']);
    unset($extensions['theme']['test_subsubtheme']);
    unset($extensions['theme']['test_subtheme']);
    $sync->write('core.extension', $extensions);
    $config_importer = $this->configImporter();
    $config_importer->import();
    $this->assertFalse($this->container
        ->get('theme_handler')
        ->themeExists('test_basetheme'));
    $this->assertFalse($this->container
        ->get('theme_handler')
        ->themeExists('test_subsubtheme'));
    $this->assertFalse($this->container
        ->get('theme_handler')
        ->themeExists('test_subtheme'));
}

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