Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / config / tests / src / Kernel / ConfigUninstallViaCliImportTest.php
1 <?php
2
3 namespace Drupal\Tests\config\Kernel;
4
5 use Drupal\Core\Config\ConfigImporter;
6 use Drupal\Core\Config\StorageComparer;
7 use Drupal\KernelTests\KernelTestBase;
8
9 /**
10  * Tests importing configuration from files into active configuration.
11  *
12  * @group config
13  */
14 class ConfigUninstallViaCliImportTest extends KernelTestBase {
15   /**
16    * Config Importer object used for testing.
17    *
18    * @var \Drupal\Core\Config\ConfigImporter
19    */
20   protected $configImporter;
21
22   /**
23    * Modules to enable.
24    *
25    * @var array
26    */
27   public static $modules = ['system', 'config'];
28
29   protected function setUp() {
30     parent::setUp();
31     if (PHP_SAPI !== 'cli') {
32       $this->markTestSkipped('This test has to be run from the CLI');
33     }
34
35     $this->installConfig(['system']);
36     $this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
37
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')
43     );
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')
54     );
55   }
56
57   /**
58    * Tests that the config module can be uninstalled via CLI config import.
59    *
60    * @see \Drupal\config\ConfigSubscriber
61    */
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'));
70   }
71
72 }