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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -83,6 +83,7 @@ class DemoUmamiProfileTest extends BrowserTestBase {
// FunctionalTestSetupTrait::installParameters(). // FunctionalTestSetupTrait::installParameters().
'system.site' => ['uuid:', 'name:', 'mail:'], 'system.site' => ['uuid:', 'name:', 'mail:'],
]); ]);
$this->pass("$config_name has no differences");
} }
else { else {
$this->fail("$config_name has not been installed"); $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); $result = $config_manager->diff($profile_config_storage, $active_config_storage, $config_name);
try { try {
$this->assertConfigDiff($result, $config_name, $skipped_config); $this->assertConfigDiff($result, $config_name, $skipped_config);
$this->pass("$config_name has no differences");
} }
catch (\Exception $e) { catch (\Exception $e) {
$this->fail($e->getMessage()); $this->fail($e->getMessage());

View File

@ -2,6 +2,7 @@
namespace Drupal\KernelTests\Config; namespace Drupal\KernelTests\Config;
use Drupal\Core\Config\Entity\ConfigEntityDependency;
use Drupal\Core\Config\FileStorage; use Drupal\Core\Config\FileStorage;
use Drupal\Core\Config\InstallStorage; use Drupal\Core\Config\InstallStorage;
use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\StorageInterface;
@ -52,42 +53,42 @@ class DefaultConfigTest extends KernelTestBase {
public function testModuleConfig($module) { public function testModuleConfig($module) {
// System and user are required in order to be able to install some of the // 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 // other modules. Therefore they are put into static::$modules, which though
// doesn't install config files, so import those config files explicitly. // doesn't install config files, so import those config files explicitly. Do
switch ($module) { // this for all tests in case optional configuration depends on it.
case 'system': $this->installConfig(['system', 'user']);
case 'user':
$this->installConfig([$module]);
break;
}
$module_path = drupal_get_path('module', $module) . '/'; $module_path = drupal_get_path('module', $module) . '/';
/** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */ /** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
$module_installer = $this->container->get('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 // Work out any additional modules and themes that need installing to create
// an optional config. // an optional config.
$optional_config_storage = new FileStorage($module_path . InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION);
$modules_to_install = [$module]; $modules_to_install = [$module];
$themes_to_install = []; $themes_to_install = [];
foreach ($optional_config_storage->listAll() as $config_name) { foreach ($optional_config_storage->listAll() as $config_name) {
$data = $optional_config_storage->read($config_name); $data = $optional_config_storage->read($config_name);
if (isset($data['dependencies']['module'])) { $dependency = new ConfigEntityDependency($config_name, $data);
$modules_to_install = array_merge($modules_to_install, $data['dependencies']['module']); $modules_to_install = array_merge($modules_to_install, $dependency->getDependencies('module'));
} $themes_to_install = array_merge($themes_to_install, $dependency->getDependencies('theme'));
if (isset($data['dependencies']['theme'])) {
$themes_to_install = array_merge($themes_to_install, $data['dependencies']['theme']);
}
} }
$module_installer->install(array_unique($modules_to_install)); // Remove core because that cannot be installed.
$this->container->get('theme_installer')->install($themes_to_install); $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. // 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, $module);
$this->doTestsOnConfigStorage($module_config_storage);
// Test configuration in the module's config/optional directory. // 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 * @param \Drupal\Core\Config\StorageInterface $default_config_storage
* The default config storage to test. * 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 */ /** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
$config_manager = $this->container->get('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); $result = $config_manager->diff($default_config_storage, $active_config_storage, $config_name);
$this->assertConfigDiff($result, $config_name, static::$skippedConfig); $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");
}
} }
} }
} }