3 namespace Drupal\Tests\config\Kernel;
5 use Drupal\Core\Config\ConfigImporter;
6 use Drupal\Core\Config\StorageComparer;
7 use Drupal\KernelTests\KernelTestBase;
10 * Tests importing configuration from files into active configuration.
14 class ConfigUninstallViaCliImportTest extends KernelTestBase {
16 * Config Importer object used for testing.
18 * @var \Drupal\Core\Config\ConfigImporter
20 protected $configImporter;
27 public static $modules = ['system', 'config'];
29 protected function setUp() {
31 if (PHP_SAPI !== 'cli') {
32 $this->markTestSkipped('This test has to be run from the CLI');
35 $this->installConfig(['system']);
36 $this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
38 // Set up the ConfigImporter object for testing.
39 $storage_comparer = new StorageComparer(
40 $this->container->get('config.storage.sync'),
41 $this->container->get('config.storage'),
42 $this->container->get('config.manager')
44 $this->configImporter = new ConfigImporter(
45 $storage_comparer->createChangelist(),
46 $this->container->get('event_dispatcher'),
47 $this->container->get('config.manager'),
48 $this->container->get('lock'),
49 $this->container->get('config.typed'),
50 $this->container->get('module_handler'),
51 $this->container->get('module_installer'),
52 $this->container->get('theme_handler'),
53 $this->container->get('string_translation')
58 * Tests that the config module can be uninstalled via CLI config import.
60 * @see \Drupal\config\ConfigSubscriber
62 public function testConfigUninstallViaCli() {
63 $this->assertTrue($this->container->get('module_handler')->moduleExists('config'));
64 $sync = $this->container->get('config.storage.sync');
65 $extensions = $sync->read('core.extension');
66 unset($extensions['module']['config']);
67 $sync->write('core.extension', $extensions);
68 $this->configImporter->reset()->import();
69 $this->assertFalse($this->container->get('module_handler')->moduleExists('config'));