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