Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / system / src / Tests / Installer / ConfigAfterInstallerTestBase.php
1 <?php
2
3 namespace Drupal\system\Tests\Installer;
4
5 use Drupal\Core\Config\FileStorage;
6 use Drupal\Core\Config\InstallStorage;
7 use Drupal\Core\Config\StorageInterface;
8 use Drupal\KernelTests\AssertConfigTrait;
9 use Drupal\simpletest\InstallerTestBase;
10
11 /**
12  * Provides a class for install profiles to check their installed config.
13  */
14 abstract class ConfigAfterInstallerTestBase extends InstallerTestBase {
15
16   use AssertConfigTrait;
17
18   /**
19    * Ensures that all the installed config looks like the exported one.
20    *
21    * @param array $skipped_config
22    *   An array of skipped config.
23    */
24   protected function assertInstalledConfig(array $skipped_config) {
25     /** @var \Drupal\Core\Config\StorageInterface $active_config_storage */
26     $active_config_storage = $this->container->get('config.storage');
27     /** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
28     $config_manager = $this->container->get('config.manager');
29
30     $default_install_path = 'core/profiles/' . $this->profile . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
31     $profile_config_storage = new FileStorage($default_install_path, StorageInterface::DEFAULT_COLLECTION);
32
33     foreach ($profile_config_storage->listAll() as $config_name) {
34       $result = $config_manager->diff($profile_config_storage, $active_config_storage, $config_name);
35       try {
36         $this->assertConfigDiff($result, $config_name, $skipped_config);
37       }
38       catch (\Exception $e) {
39         $this->fail($e->getMessage());
40       }
41     }
42   }
43
44 }