comparison core/tests/Drupal/FunctionalTests/Installer/ConfigAfterInstallerTestBase.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
1 <?php
2
3 namespace Drupal\FunctionalTests\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
10 /**
11 * Provides a class for install profiles to check their installed config.
12 */
13 abstract class ConfigAfterInstallerTestBase extends InstallerTestBase {
14
15 use AssertConfigTrait;
16
17 /**
18 * Ensures that all the installed config looks like the exported one.
19 *
20 * @param array $skipped_config
21 * An array of skipped config.
22 */
23 protected function assertInstalledConfig(array $skipped_config) {
24 $this->addToAssertionCount(1);
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 }