diff --git a/core/modules/system/src/Tests/Installer/ConfigAfterInstallerTestBase.php b/core/modules/system/src/Tests/Installer/ConfigAfterInstallerTestBase.php index 4611e90..aa3ec3e 100644 --- a/core/modules/system/src/Tests/Installer/ConfigAfterInstallerTestBase.php +++ b/core/modules/system/src/Tests/Installer/ConfigAfterInstallerTestBase.php @@ -20,6 +20,12 @@ use AssertConfigTrait; + /** + * Ensures that all the installed config looks like the exported one. + * + * @param array $skipped_config + * An array of skipped config. + */ protected function assertInstalledConfig(array $skipped_config) { /** @var \Drupal\Core\Config\StorageInterface $active_config_storage */ $active_config_storage = $this->container->get('config.storage'); diff --git a/core/modules/system/src/Tests/Installer/MinimalInstallerTest.php b/core/modules/system/src/Tests/Installer/MinimalInstallerTest.php index 5946212..54c07b3 100644 --- a/core/modules/system/src/Tests/Installer/MinimalInstallerTest.php +++ b/core/modules/system/src/Tests/Installer/MinimalInstallerTest.php @@ -7,18 +7,14 @@ namespace Drupal\system\Tests\Installer; -use Drupal\Core\Config\FileStorage; -use Drupal\Core\Config\InstallStorage; -use Drupal\Core\Config\StorageInterface; use Drupal\KernelTests\AssertConfigTrait; -use Drupal\simpletest\InstallerTestBase; /** * Tests the interactive installer installing the minimal profile. * * @group Installer */ -class MinimalInstallerTest extends InstallerTestBase { +class MinimalInstallerTest extends ConfigAfterInstallerTestBase { use AssertConfigTrait; @@ -31,25 +27,7 @@ class MinimalInstallerTest extends InstallerTestBase { * Ensures that the exported minimal configuration is up to date. */ public function testMinimalConfig() { - /** @var \Drupal\Core\Config\StorageInterface $active_config_storage */ - $active_config_storage = $this->container->get('config.storage'); - /** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */ - $config_manager = $this->container->get('config.manager'); - - $profile = 'minimal'; - - $default_install_path = 'core/profiles/' . $profile . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY; - $profile_config_storage = new FileStorage($default_install_path, StorageInterface::DEFAULT_COLLECTION); - - $skipped_config = []; - foreach ($profile_config_storage->listAll() as $config_name) { - $result = $config_manager->diff($profile_config_storage, $active_config_storage, $config_name); - try { - $this->assertConfigDiff($result, $config_name, $skipped_config); - } - catch (\Exception $e) { - $this->fail($e->getMessage()); - } - } + $this->assertInstalledConfig([]); } + } diff --git a/core/modules/system/src/Tests/Installer/StandardInstallerTest.php b/core/modules/system/src/Tests/Installer/StandardInstallerTest.php index 72a5072..184e07b 100644 --- a/core/modules/system/src/Tests/Installer/StandardInstallerTest.php +++ b/core/modules/system/src/Tests/Installer/StandardInstallerTest.php @@ -7,20 +7,12 @@ namespace Drupal\system\Tests\Installer; -use Drupal\Core\Config\FileStorage; -use Drupal\Core\Config\InstallStorage; -use Drupal\Core\Config\StorageInterface; -use Drupal\KernelTests\AssertConfigTrait; -use Drupal\simpletest\InstallerTestBase; - /** * Tests the interactive installer installing the standard profile. * * @group Installer */ -class StandardInstallerTest extends InstallerTestBase { - - use AssertConfigTrait; +class StandardInstallerTest extends ConfigAfterInstallerTestBase { /** * {@inheritdoc} @@ -52,16 +44,6 @@ protected function setUpSite() { * Ensures that the exported standard configuration is up to date. */ public function testStandardConfig() { - /** @var \Drupal\Core\Config\StorageInterface $active_config_storage */ - $active_config_storage = $this->container->get('config.storage'); - /** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */ - $config_manager = $this->container->get('config.manager'); - - $profile = 'standard'; - - $default_install_path = 'core/profiles/' . $profile . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY; - $profile_config_storage = new FileStorage($default_install_path, StorageInterface::DEFAULT_COLLECTION); - $skipped_config = []; // \Drupal\simpletest\WebTestBase::installParameters() uses // simpletest@example.com as mail address. @@ -75,15 +57,7 @@ public function testStandardConfig() { $skipped_config['filter.format.restricted_html'][] = 'roles:'; $skipped_config['filter.format.restricted_html'][] = ' - anonymous'; - foreach ($profile_config_storage->listAll() as $config_name) { - $result = $config_manager->diff($profile_config_storage, $active_config_storage, $config_name); - try { - $this->assertConfigDiff($result, $config_name, $skipped_config); - } - catch (\Exception $e) { - $this->fail($e->getMessage()); - } - } + $this->assertInstalledConfig($skipped_config); } } diff --git a/core/tests/Drupal/KernelTests/AssertConfigTrait.php b/core/tests/Drupal/KernelTests/AssertConfigTrait.php index 1545814..437cf99 100644 --- a/core/tests/Drupal/KernelTests/AssertConfigTrait.php +++ b/core/tests/Drupal/KernelTests/AssertConfigTrait.php @@ -18,10 +18,16 @@ * Ensures that a specific config diff does not contain unwanted changes. * * @param \Drupal\Component\Diff\Diff $result - * @param $config_name + * The diff result for the passed in config name. + * @param string $config_name + * The config name to check. * @param array $skipped_config + * An array of skipped config, keyed by string. If the value is TRUE, the + * entire file will be ignored, otherwise its an array of strings which are + * ignored. * * @throws \Exception + * Thrown when a configuration is different. */ protected function assertConfigDiff(Diff $result, $config_name, array $skipped_config) { foreach ($result->getEdits() as $op) { @@ -31,7 +37,7 @@ protected function assertConfigDiff(Diff $result, $config_name, array $skipped_c break; case 'Drupal\Component\Diff\Engine\DiffOpDelete': case 'Drupal\Component\Diff\Engine\DiffOpChange': - // Its not part of the skipped config, so we can directly throw the + // It is not part of the skipped config, so we can directly throw the // exception. if (!in_array($config_name, array_keys($skipped_config))) { throw new \Exception($config_name . ': ' . var_export($op, TRUE)); diff --git a/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php b/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php index aa0ab63..0ee34e1 100644 --- a/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php +++ b/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php @@ -80,7 +80,7 @@ public function testModuleConfig($module) { $module_config_storage = new FileStorage($default_install_path, StorageInterface::DEFAULT_COLLECTION); // The following config entries are changed on module install, so compare - // it doesn't make sense. + // them doesn't make sense. $skipped_config = []; $skipped_config['locale.settings'][] = 'path: '; $skipped_config['syslog.settings'][] = 'facility: ';