Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3101671
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3101671
Commits
cc6885bd
Commit
cc6885bd
authored
8 years ago
by
catch
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2755843
by alexpott, xjm: The order in which config is saved affects dependency calculations
parent
260c6ee9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/rest/config/optional/rest.resource.entity.node.yml
+7
-5
7 additions, 5 deletions
...odules/rest/config/optional/rest.resource.entity.node.yml
core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php
+79
-28
79 additions, 28 deletions
core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php
with
86 additions
and
33 deletions
core/modules/rest/config/optional/rest.resource.entity.node.yml
+
7
−
5
View file @
cc6885bd
langcode
:
en
status
:
true
dependencies
:
module
:
-
basic_auth
-
hal
-
node
id
:
entity.node
plugin_id
:
'
entity:node'
granularity
:
method
...
...
@@ -22,8 +29,3 @@ configuration:
-
hal_json
supported_auth
:
-
basic_auth
dependencies
:
module
:
-
node
-
basic_auth
-
hal
This diff is collapsed.
Click to expand it.
core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php
+
79
−
28
View file @
cc6885bd
...
...
@@ -27,6 +27,21 @@ class DefaultConfigTest extends KernelTestBase {
*/
public
static
$modules
=
[
'system'
,
'user'
];
/**
* The following config entries are changed on module install.
*
* Compare them does not make sense.
*
* @todo Figure out why simpletest.settings is not installed.
*
* @var array
*/
public
static
$skippedConfig
=
[
'locale.settings'
=>
[
'path: '
],
'syslog.settings'
=>
[
'facility: '
],
'simpletest.settings'
=>
TRUE
,
];
/**
* {@inheritdoc}
*/
...
...
@@ -49,45 +64,81 @@ protected function setUp() {
* @dataProvider providerTestModuleConfig
*/
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
;
}
$module_path
=
drupal_get_path
(
'module'
,
$module
)
.
'/'
;
/** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
$module_installer
=
$this
->
container
->
get
(
'module_installer'
);
/** @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'
);
// @todo https://www.drupal.org/node/2308745 Rest has an implicit dependency
// on the Node module remove once solved.
if
(
in_array
(
$module
,
[
'rest'
,
'hal'
]))
{
$module_installer
->
install
([
'node'
]);
}
$module_installer
->
install
([
$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
;
// Work out any additional modules and themes that need installing to create
// and 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'
]);
}
}
$module_installer
->
install
(
array_unique
(
$modules_to_install
));
$this
->
container
->
get
(
'theme_installer'
)
->
install
(
$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
);
// Test configuration in the module's config/optional directory.
$this
->
doTestsOnConfigStorage
(
$optional_config_storage
);
}
/**
* Tests that default config matches the installed config.
*
* @param \Drupal\Core\Config\StorageInterface $default_config_storage
* The default config storage to test.
*/
protected
function
doTestsOnConfigStorage
(
StorageInterface
$default_config_storage
)
{
/** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
$config_manager
=
$this
->
container
->
get
(
'config.manager'
);
// Just connect directly to the config table so we don't need to worry about
// the cache layer.
$active_config_storage
=
$this
->
container
->
get
(
'config.storage'
);
$default_install_path
=
drupal_get_path
(
'module'
,
$module
)
.
'/'
.
InstallStorage
::
CONFIG_INSTALL_DIRECTORY
;
$modul
e_config_storage
=
new
FileStorage
(
$default_install_path
,
StorageInterface
::
DEFAULT_COLLECTION
);
//
The following config entries are changed on module install, so compare
// them doesn't make sense.
$skipped_config
=
[];
$skipped_config
[
'locale.settings'
][]
=
'path: '
;
$skipped_config
[
'syslog.settings'
][]
=
'facility: '
;
// @todo Figure out why simpletest.settings is not installed.
$skipped_config
[
'simpletest.settings'
]
=
TRUE
;
// Compare the installed config with the one in the module directory.
foreach
(
$mod
ul
e
_config_storage
->
listAll
()
as
$config_name
)
{
$result
=
$config_manager
->
diff
(
$module_config_storage
,
$active_config_storage
,
$config_name
);
$this
->
assertConfigDiff
(
$result
,
$config_name
,
$skipped_config
);
foreach
(
$default_config_storage
->
listAll
()
as
$config_name
)
{
if
(
$activ
e_config_storage
->
exists
(
$config_name
))
{
// If it is a config entity re-save it. This ensures that any
//
recalculation of dependencies does not cause config change.
if
(
$entity_type
=
$config_manager
->
getEntityTypeIdByName
(
$config_name
))
{
$entity_storage
=
$config_manager
->
getEntityManager
()
->
getStorage
(
$entity_type
)
;
$id
=
$entity_storage
->
getIDFromConfigName
(
$config_name
,
$entity_storage
->
getEntityType
()
->
getConfigPrefix
())
;
$entity_storage
->
load
(
$id
)
->
calculateDependencies
()
->
save
();
}
$result
=
$config_manager
->
diff
(
$defa
ul
t
_config_storage
,
$active_config_storage
,
$config_name
)
;
$this
->
assertConfigDiff
(
$result
,
$config_name
,
static
::
$skippedConfig
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment