annotate 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
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\FunctionalTests\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
Chris@0 10 /**
Chris@0 11 * Provides a class for install profiles to check their installed config.
Chris@0 12 */
Chris@0 13 abstract class ConfigAfterInstallerTestBase extends InstallerTestBase {
Chris@0 14
Chris@0 15 use AssertConfigTrait;
Chris@0 16
Chris@0 17 /**
Chris@0 18 * Ensures that all the installed config looks like the exported one.
Chris@0 19 *
Chris@0 20 * @param array $skipped_config
Chris@0 21 * An array of skipped config.
Chris@0 22 */
Chris@0 23 protected function assertInstalledConfig(array $skipped_config) {
Chris@0 24 $this->addToAssertionCount(1);
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 }