Issue #3059545 by alexpott, Lendude, tstoeckler, Mile23, neclimdul, vijaycs85, Morbus Iff: Improve \Drupal\KernelTests\Config\DefaultConfigTest to install all optional configuration

merge-requests/1119/head
catch 2019-06-19 16:21:24 +01:00
parent 54f8eb66b5
commit 3263c8cbab
16 changed files with 102 additions and 36 deletions

View File

@ -458,6 +458,8 @@ display:
multiple: false
remember_roles:
authenticated: authenticated
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -510,7 +512,7 @@ display:
- url
- url.query_args
- user.permissions
max-age: 0
max-age: -1
tags: { }
page_1:
display_plugin: page
@ -535,5 +537,5 @@ display:
- url
- url.query_args
- user.permissions
max-age: 0
max-age: -1
tags: { }

View File

@ -650,6 +650,8 @@ display:
multiple: false
remember_roles:
authenticated: authenticated
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -690,6 +692,8 @@ display:
authenticated: authenticated
anonymous: '0'
administrator: '0'
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -730,6 +734,8 @@ display:
authenticated: authenticated
anonymous: '0'
administrator: '0'
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -772,6 +778,8 @@ display:
anonymous: '0'
administrator: '0'
reduce: false
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -923,6 +931,8 @@ display:
multiple: false
remember_roles:
authenticated: authenticated
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -963,6 +973,8 @@ display:
authenticated: authenticated
anonymous: '0'
administrator: '0'
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -1003,6 +1015,8 @@ display:
authenticated: authenticated
anonymous: '0'
administrator: '0'
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -1045,6 +1059,8 @@ display:
anonymous: '0'
administrator: '0'
reduce: false
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''

View File

@ -176,6 +176,8 @@ display:
plugin_id: boolean
expose:
operator: ''
operator_limit_selection: false
operator_list: { }
group: 1
entity_type: comment
entity_field: status
@ -188,6 +190,8 @@ display:
plugin_id: boolean
expose:
operator: ''
operator_limit_selection: false
operator_list: { }
group: 1
entity_type: node
entity_field: status

View File

@ -1,8 +1,10 @@
langcode: en
status: true
dependencies:
enforced:
module:
- content_moderation
module:
- content_moderation
- node
- user
id: moderated_content
@ -524,6 +526,8 @@ display:
multiple: false
remember_roles:
authenticated: authenticated
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -563,6 +567,8 @@ display:
authenticated: authenticated
anonymous: '0'
administrator: '0'
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -604,6 +610,8 @@ display:
anonymous: '0'
administrator: '0'
reduce: false
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -647,6 +655,8 @@ display:
anonymous: '0'
administrator: '0'
reduce: true
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -687,6 +697,8 @@ display:
anonymous: '0'
administrator: '0'
reduce: false
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -727,6 +739,8 @@ display:
remember_roles:
authenticated: authenticated
reduce: false
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -787,7 +801,7 @@ display:
groups:
1: AND
cache_metadata:
max-age: 0
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
@ -806,7 +820,7 @@ display:
path: admin/content/moderated
display_description: ''
cache_metadata:
max-age: 0
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'

View File

@ -684,7 +684,7 @@ display:
1: AND
css_class: admin-dblog
cache_metadata:
max-age: 0
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
@ -701,7 +701,7 @@ display:
display_extenders: { }
path: admin/reports/dblog
cache_metadata:
max-age: 0
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'

View File

@ -729,7 +729,7 @@ display:
- url
- url.query_args
- user.permissions
max-age: 0
max-age: -1
tags: { }
page_1:
display_plugin: page
@ -766,7 +766,7 @@ display:
- url
- url.query_args
- user.permissions
max-age: 0
max-age: -1
tags: { }
page_2:
display_plugin: page
@ -1123,5 +1123,5 @@ display:
- url
- url.query_args
- user.permissions
max-age: 0
max-age: -1
tags: { }

View File

@ -1,6 +1,8 @@
langcode: en
status: true
dependencies: { }
dependencies:
module:
- language
id: language-add
label: 'Adding languages'
module: language

View File

@ -1,6 +1,8 @@
langcode: en
status: true
dependencies: { }
dependencies:
module:
- language
id: language-edit
label: 'Editing languages'
module: language

View File

@ -1,6 +1,8 @@
langcode: en
status: true
dependencies: { }
dependencies:
module:
- language
id: language
label: Language
module: language

View File

@ -1,6 +1,8 @@
langcode: en
status: true
dependencies:
config:
- image.style.thumbnail
module:
- image
- media

View File

@ -85,6 +85,8 @@ display:
authenticated: authenticated
required: false
use_operator: false
operator_limit_selection: false
operator_list: { }
exposed: false
field: promote
group: 1
@ -112,6 +114,8 @@ display:
status:
expose:
operator: ''
operator_limit_selection: false
operator_list: { }
field: status
group: 1
id: status
@ -145,6 +149,8 @@ display:
remember_roles:
authenticated: authenticated
reduce: false
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''

View File

@ -359,7 +359,7 @@ display:
- url.query_args
- 'user.node_grants:view'
- user.permissions
max-age: 0
max-age: -1
tags: { }
attachment_1:
id: attachment_1
@ -427,7 +427,7 @@ display:
- url.query_args
- 'user.node_grants:view'
- user.permissions
max-age: 0
max-age: -1
tags: { }
page_1:
id: page_1
@ -454,5 +454,5 @@ display:
- url.query_args
- 'user.node_grants:view'
- user.permissions
max-age: 0
max-age: -1
tags: { }

View File

@ -159,6 +159,8 @@ display:
remember_roles:
authenticated: authenticated
reduce: false
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
@ -197,6 +199,8 @@ display:
multiple: false
remember_roles:
authenticated: authenticated
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''

View File

@ -83,6 +83,7 @@ class DemoUmamiProfileTest extends BrowserTestBase {
// FunctionalTestSetupTrait::installParameters().
'system.site' => ['uuid:', 'name:', 'mail:'],
]);
$this->pass("$config_name has no differences");
}
else {
$this->fail("$config_name has not been installed");

View File

@ -34,6 +34,7 @@ abstract class ConfigAfterInstallerTestBase extends InstallerTestBase {
$result = $config_manager->diff($profile_config_storage, $active_config_storage, $config_name);
try {
$this->assertConfigDiff($result, $config_name, $skipped_config);
$this->pass("$config_name has no differences");
}
catch (\Exception $e) {
$this->fail($e->getMessage());

View File

@ -2,6 +2,7 @@
namespace Drupal\KernelTests\Config;
use Drupal\Core\Config\Entity\ConfigEntityDependency;
use Drupal\Core\Config\FileStorage;
use Drupal\Core\Config\InstallStorage;
use Drupal\Core\Config\StorageInterface;
@ -52,42 +53,42 @@ class DefaultConfigTest extends KernelTestBase {
public function testModuleConfig($module) {
// System and user are required in order to be able to install some of the
// other modules. Therefore they are put into static::$modules, which though
// doesn't install config files, so import those config files explicitly.
switch ($module) {
case 'system':
case 'user':
$this->installConfig([$module]);
break;
}
// doesn't install config files, so import those config files explicitly. Do
// this for all tests in case optional configuration depends on it.
$this->installConfig(['system', 'user']);
$module_path = drupal_get_path('module', $module) . '/';
/** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
$module_installer = $this->container->get('module_installer');
$module_config_storage = new FileStorage($module_path . InstallStorage::CONFIG_INSTALL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION);
$optional_config_storage = new FileStorage($module_path . InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION);
if (empty($optional_config_storage->listAll()) && empty($module_config_storage->listAll())) {
$this->markTestSkipped("$module has no configuration to test");
}
// Work out any additional modules and themes that need installing to create
// an optional config.
$optional_config_storage = new FileStorage($module_path . InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION);
$modules_to_install = [$module];
$themes_to_install = [];
foreach ($optional_config_storage->listAll() as $config_name) {
$data = $optional_config_storage->read($config_name);
if (isset($data['dependencies']['module'])) {
$modules_to_install = array_merge($modules_to_install, $data['dependencies']['module']);
}
if (isset($data['dependencies']['theme'])) {
$themes_to_install = array_merge($themes_to_install, $data['dependencies']['theme']);
}
$dependency = new ConfigEntityDependency($config_name, $data);
$modules_to_install = array_merge($modules_to_install, $dependency->getDependencies('module'));
$themes_to_install = array_merge($themes_to_install, $dependency->getDependencies('theme'));
}
$module_installer->install(array_unique($modules_to_install));
$this->container->get('theme_installer')->install($themes_to_install);
// Remove core because that cannot be installed.
$modules_to_install = array_diff(array_unique($modules_to_install), ['core']);
$module_installer->install($modules_to_install);
$this->container->get('theme_installer')->install(array_unique($themes_to_install));
// Test configuration in the module's config/install directory.
$module_config_storage = new FileStorage($module_path . InstallStorage::CONFIG_INSTALL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION);
$this->doTestsOnConfigStorage($module_config_storage);
$this->doTestsOnConfigStorage($module_config_storage, $module);
// Test configuration in the module's config/optional directory.
$this->doTestsOnConfigStorage($optional_config_storage);
$this->doTestsOnConfigStorage($optional_config_storage, $module);
}
/**
@ -96,7 +97,7 @@ class DefaultConfigTest extends KernelTestBase {
* @param \Drupal\Core\Config\StorageInterface $default_config_storage
* The default config storage to test.
*/
protected function doTestsOnConfigStorage(StorageInterface $default_config_storage) {
protected function doTestsOnConfigStorage(StorageInterface $default_config_storage, $module) {
/** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
$config_manager = $this->container->get('config.manager');
@ -118,6 +119,15 @@ class DefaultConfigTest extends KernelTestBase {
}
$result = $config_manager->diff($default_config_storage, $active_config_storage, $config_name);
$this->assertConfigDiff($result, $config_name, static::$skippedConfig);
// The method call above will throw an exception if the configuration is
// different.
$this->pass("$config_name has no differences");
}
else {
$info = $this->container->get('extension.list.module')->getExtensionInfo($module);
if (!isset($info['package']) || $info['package'] !== 'Core (Experimental)') {
$this->fail("$config_name provided by $module does not exist after installing all dependencies");
}
}
}
}