annotate core/tests/Drupal/FunctionalTests/Installer/ConfigAfterInstallerTestBase.php @ 19:fa3358dc1485 tip

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