diff --git a/src/FeaturesManager.php b/src/FeaturesManager.php index 721d33a..1125425 100644 --- a/src/FeaturesManager.php +++ b/src/FeaturesManager.php @@ -498,7 +498,7 @@ class FeaturesManager implements FeaturesManagerInterface { $already_in_package = in_array($item_name, $package->getConfig()); if (($force || (!$already_assigned && $assignable && !$excluded_from_package)) && !$already_in_package) { // Add the item to the package's config array. - $package['config'][] = $item_name; + $package->appendConfig($item_name); // Mark the item as already assigned. $config_collection[$item_name]->setPackage($package_name); // For configuration in the InstallStorage::CONFIG_INSTALL_DIRECTORY diff --git a/src/Package.php b/src/Package.php index 752141b..3f8e46a 100644 --- a/src/Package.php +++ b/src/Package.php @@ -175,6 +175,19 @@ class Package { } /** + * Append a new filename. + * + * @param string $config + * + * @return $this + */ + public function appendConfig($config) { + $this->config[] = $config; + $this->config = array_unique($this->config); + return $this; + } + + /** * @return string */ public function getBundle() { diff --git a/tests/src/Unit/FeaturesManagerTest.php b/tests/src/Unit/FeaturesManagerTest.php index 5e9c101..57549ab 100644 --- a/tests/src/Unit/FeaturesManagerTest.php +++ b/tests/src/Unit/FeaturesManagerTest.php @@ -347,6 +347,24 @@ class FeaturesManagerTest extends UnitTestCase { } /** + * @covers ::assignConfigPackage + */ + public function testAssignConfigPackage() { + $config_collection = [ + 'test_config' => new ConfigurationItem('test_config', []), + 'test_config2' => new ConfigurationItem('test_config2', []), + ]; + $this->featuresManager->setConfigCollection($config_collection); + + $package = new Package('test_package'); + $this->featuresManager->setPackage($package); + + $this->featuresManager->assignConfigPackage('test_package', ['test_config', 'test_config2']); + + $this->assertEquals(['test_config', 'test_config2'], $this->featuresManager->getPackage('test_package')->getConfig()); + } + + /** * @covers ::initPackageFromExtension * @covers ::getPackageObject */