diff --git a/core/modules/migrate/tests/src/Unit/Plugin/migrate/ConfigurablePluginTraitTest.php b/core/modules/migrate/tests/src/Unit/Plugin/migrate/ConfigurablePluginTraitTest.php index 1c59204365..6c5cb6fd42 100644 --- a/core/modules/migrate/tests/src/Unit/Plugin/migrate/ConfigurablePluginTraitTest.php +++ b/core/modules/migrate/tests/src/Unit/Plugin/migrate/ConfigurablePluginTraitTest.php @@ -14,7 +14,6 @@ class ConfigurablePluginTraitTest extends UnitTestCase { /** * Test a mock ConfigurablePluginTrait. - * */ public function testConfigurableTrait() { @@ -48,6 +47,8 @@ public function testConfigurableTrait() { * * Specifically test the way default and provided configurations are merged. * + * @param array $default_configuration + * The default configuration to use for the trait. * @param array $test_configuration * The configuration to test. * @param array $final_configuration @@ -55,8 +56,8 @@ public function testConfigurableTrait() { * * @dataProvider configurableObjectDataProvider */ - public function testConfigurableObject(array $test_configuration, array $final_configuration) { - $test_object = new ConfigurablePluginTestClass(); + public function testConfigurableObject(array $default_configuration, array $test_configuration, array $final_configuration) { + $test_object = new ConfigurablePluginTestClass($default_configuration); $test_object->setConfiguration($test_configuration); $this->assertArrayEquals($final_configuration, $test_object->getConfiguration()); } @@ -70,6 +71,13 @@ public function testConfigurableObject(array $test_configuration, array $final_c public function configurableObjectDataProvider() { return [ 'Direct Override' => [ + 'default_configuration' => [ + 'default_key_1' => 'default_value_1', + 'default_key_2' => [ + 'default_nested_key_1' => 'default_nested_value_1', + 'default_nested_key_2' => 'default_nested_value_2', + ], + ], 'test_configuration' => [ 'default_key_1' => 'override_value_1', 'default_key_2' => [ @@ -86,6 +94,13 @@ public function configurableObjectDataProvider() { ], ], 'Mixed Override' => [ + 'default_configuration' => [ + 'default_key_1' => 'default_value_1', + 'default_key_2' => [ + 'default_nested_key_1' => 'default_nested_value_1', + 'default_nested_key_2' => 'default_nested_value_2', + ], + ], 'test_configuration' => [ 'override_key_1' => 'config_value_1', 'default_key_2' => [ @@ -103,31 +118,75 @@ public function configurableObjectDataProvider() { 'override_key_1' => 'config_value_1', ], ], + 'indexed_override' => [ + 'default_configuration' => [ + 'config_value_1', + 'config_value_2', + 'config_value_3', + ], + 'test_configuration' => [ + 'override_value_1', + 'override_value_2', + ], + 'final_configuration' => [ + 'override_value_1', + 'override_value_2', + 'config_value_3', + ] + ], + 'indexed_override_complex' => [ + 'default_configuration' => [ + 'config_value_1', + 'config_value_2', + 'config_value_3', + ], + 'test_configuration' => [ + 0 => 'override_value_1', + 2 => 'override_value_3', + ], + 'final_configuration' => [ + 'override_value_1', + 'config_value_2', + 'override_value_3', + ] + ] + ]; } } /** - * A test object using ConfigurablePluginTrait. + * A test class using ConfigurablePluginTrait. */ class ConfigurablePluginTestClass { use ConfigurablePluginTrait; /** - * Test defaults. + * A default configuration for the test class to return. + * + * @var array + */ + protected $defaultConfiguration; + + /** + * ConfigurablePluginTestClass constructor. + * + * @param array $default_configuration + * The default configuration to return. + */ + public function __construct(array $default_configuration) { + $this->defaultConfiguration = $default_configuration; + } + + /** + * Return the provided test defaults. * * @return array * The default configuration. */ public function defaultConfiguration() { - return [ - 'default_key_1' => 'default_value_1', - 'default_key_2' => [ - 'default_nested_key_1' => 'default_nested_value_1', - 'default_nested_key_2' => 'default_nested_value_2', - ], - ]; + return $this->defaultConfiguration; } }