annotate core/modules/system/src/Tests/Installer/ConfigAfterInstallerTestBase.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 129ea1e6d783
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\system\Tests\Installer;
Chris@0 4
Chris@0 5 use Drupal\Core\Config\FileStorage;
Chris@0 6 use Drupal\Core\Config\InstallStorage;
Chris@0 7 use Drupal\Core\Config\StorageInterface;
Chris@0 8 use Drupal\KernelTests\AssertConfigTrait;
Chris@0 9 use Drupal\simpletest\InstallerTestBase;
Chris@0 10
Chris@0 11 /**
Chris@0 12 * Provides a class for install profiles to check their installed config.
Chris@0 13 */
Chris@0 14 abstract class ConfigAfterInstallerTestBase extends InstallerTestBase {
Chris@0 15
Chris@0 16 use AssertConfigTrait;
Chris@0 17
Chris@0 18 /**
Chris@0 19 * Ensures that all the installed config looks like the exported one.
Chris@0 20 *
Chris@0 21 * @param array $skipped_config
Chris@0 22 * An array of skipped config.
Chris@0 23 */
Chris@0 24 protected function assertInstalledConfig(array $skipped_config) {
Chris@0 25 /** @var \Drupal\Core\Config\StorageInterface $active_config_storage */
Chris@0 26 $active_config_storage = $this->container->get('config.storage');
Chris@0 27 /** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
Chris@0 28 $config_manager = $this->container->get('config.manager');
Chris@0 29
Chris@0 30 $default_install_path = 'core/profiles/' . $this->profile . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
Chris@0 31 $profile_config_storage = new FileStorage($default_install_path, StorageInterface::DEFAULT_COLLECTION);
Chris@0 32
Chris@0 33 foreach ($profile_config_storage->listAll() as $config_name) {
Chris@0 34 $result = $config_manager->diff($profile_config_storage, $active_config_storage, $config_name);
Chris@0 35 try {
Chris@0 36 $this->assertConfigDiff($result, $config_name, $skipped_config);
Chris@0 37 }
Chris@0 38 catch (\Exception $e) {
Chris@0 39 $this->fail($e->getMessage());
Chris@0 40 }
Chris@0 41 }
Chris@0 42 }
Chris@0 43
Chris@0 44 }