ConfigAfterInstallerTestBase.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace Drupal\FunctionalTests\Installer;
  3. use Drupal\Core\Config\FileStorage;
  4. use Drupal\Core\Config\InstallStorage;
  5. use Drupal\Core\Config\StorageInterface;
  6. use Drupal\KernelTests\AssertConfigTrait;
  7. /**
  8. * Provides a class for install profiles to check their installed config.
  9. */
  10. abstract class ConfigAfterInstallerTestBase extends InstallerTestBase {
  11. use AssertConfigTrait;
  12. /**
  13. * Ensures that all the installed config looks like the exported one.
  14. *
  15. * @param array $skipped_config
  16. * An array of skipped config.
  17. */
  18. protected function assertInstalledConfig(array $skipped_config) {
  19. $this->addToAssertionCount(1);
  20. /** @var \Drupal\Core\Config\StorageInterface $active_config_storage */
  21. $active_config_storage = $this->container->get('config.storage');
  22. /** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
  23. $config_manager = $this->container->get('config.manager');
  24. $default_install_path = 'core/profiles/' . $this->profile . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
  25. $profile_config_storage = new FileStorage($default_install_path, StorageInterface::DEFAULT_COLLECTION);
  26. foreach ($profile_config_storage->listAll() as $config_name) {
  27. $result = $config_manager->diff($profile_config_storage, $active_config_storage, $config_name);
  28. $this->assertConfigDiff($result, $config_name, $skipped_config);
  29. }
  30. }
  31. }