diff --git a/src/ConfigListerWithProviders.php b/src/ConfigListerWithProviders.php index 5c50c98..cc0f635 100644 --- a/src/ConfigListerWithProviders.php +++ b/src/ConfigListerWithProviders.php @@ -85,11 +85,12 @@ class ConfigListerWithProviders extends ConfigLister implements ConfigListByProv return $this->providers; } - // Calculate if it hasn't been set up yet. - // List all of the profile, modules, and themes. + // Calculate the list of who provides which config, if it hasn't been set + // up yet. List all of the profile, modules, and themes. Profile needs to + // come last, so it will override config in modules and themes in our list, + // matching what the config system does. $extensionsToDo = []; $profile = $this->getProfileName(); - $extensionsToDo[] = ['profile', $profile]; $modules = $this->moduleHandler->getModuleList(); foreach ($modules as $machine_name => $module) { if ($machine_name != $profile) { @@ -102,6 +103,8 @@ class ConfigListerWithProviders extends ConfigLister implements ConfigListByProv $extensionsToDo[] = ['theme', $machine_name]; } + $extensionsToDo[] = ['profile', $profile]; + // For each extension, figure out if it has config, and make an index of // config item => provider. $this->extensionsWithConfig = [ diff --git a/tests/src/Unit/ConfigListerTest.php b/tests/src/Unit/ConfigListerTest.php index 668e8b9..d9d1952 100644 --- a/tests/src/Unit/ConfigListerTest.php +++ b/tests/src/Unit/ConfigListerTest.php @@ -24,15 +24,21 @@ class ConfigListerTest extends ConfigUpdateUnitTestBase { * List of configuration by provider in the mocks. * * This is an array whose keys are provider names, and whose values are - * each an array containing the provider type, the name of one config item - * mocked to be in config/install, and one in config/optional. + * each an array containing the provider type, an array of config items + * mocked to be in config/install, and the same for config/optional. In + * all cases, the first item in the array of config items should be tested + * to be provided by that provider, and any others should not be there. * * @var array */ protected $configProviderList = [ - 'foo_module' => ['module', 'foo.barbaz.one', 'foo.barbaz.two'], - 'foo_theme' => ['theme', 'foo.bar.one', 'foo.bar.two'], - 'standard' => ['profile', 'baz.bar.one', 'baz.bar.two'], + 'foo_module' => [ + 'module', + ['foo.barbaz.one', 'baz.bar.one'], + ['foo.barbaz.two'], + ], + 'foo_theme' => ['theme', ['foo.bar.one'], ['foo.bar.two']], + 'standard' => ['profile', ['baz.bar.one'], ['baz.bar.two']], ]; /** @@ -56,10 +62,10 @@ class ConfigListerTest extends ConfigUpdateUnitTestBase { $map = []; foreach ($this->configProviderList as $provider => $info) { - // Info has: [type, install storage item, optional storage item]. + // Info has: [type, install storage items, optional storage items]. // Map needs: [type, provider name, isOptional, [config items]]. - $map[] = [$info[0], $provider, FALSE, [$info[1]]]; - $map[] = [$info[0], $provider, TRUE, [$info[2]]]; + $map[] = [$info[0], $provider, FALSE, $info[1]]; + $map[] = [$info[0], $provider, TRUE, $info[2]]; } $lister->method('listProvidedItems') ->will($this->returnValueMap($map)); @@ -148,7 +154,7 @@ class ConfigListerTest extends ConfigUpdateUnitTestBase { 'something.else', 'another.one', ], - ['foo.barbaz.one'], + ['foo.barbaz.one', 'baz.bar.one'], ['foo.barbaz.two'], ], ], @@ -233,10 +239,12 @@ class ConfigListerTest extends ConfigUpdateUnitTestBase { $return = $this->configLister->listProviders(); $expected = []; foreach ($this->configProviderList as $provider => $info) { - // Info has: [type, install storage item, optional storage item]. + // Info has: [type, install storage items, optional storage items], with + // only the first item in each list that should be present in + // listProviders(). // Expected needs: key is item name, value is [type, provider name]. - $expected[$info[1]] = [$info[0], $provider]; - $expected[$info[2]] = [$info[0], $provider]; + $expected[$info[1][0]] = [$info[0], $provider]; + $expected[$info[2][0]] = [$info[0], $provider]; } ksort($return); ksort($expected); @@ -257,10 +265,12 @@ class ConfigListerTest extends ConfigUpdateUnitTestBase { public function getConfigProviderProvider() { $values = []; foreach ($this->configProviderList as $provider => $info) { - // Info has: [type, install storage item, optional storage item]. + // Info has: [type, install storage items, optional storage items], with + // the first item in each list that should be OK to test with + // getConfigProvider(). // Values needs: [item, [type, provider name]]. - $values[] = [$info[1], [$info[0], $provider]]; - $values[] = [$info[2], [$info[0], $provider]]; + $values[] = [$info[1][0], [$info[0], $provider]]; + $values[] = [$info[2][0], [$info[0], $provider]]; } $values[] = ['not.a.config.item', NULL]; return $values; @@ -280,7 +290,7 @@ class ConfigListerTest extends ConfigUpdateUnitTestBase { public function providerHasConfigProvider() { $values = []; foreach ($this->configProviderList as $provider => $info) { - // Info has: [type, install storage item, optional storage item]. + // Info has: [type, install storage items, optional storage items]. // Values needs: [type, provider name, TRUE] for valid providers, // change the last to FALSE for invalid providers. $values[] = [$info[0], $provider, TRUE];