diff --git a/src/Core/ObjectRegistry.php b/src/Core/ObjectRegistry.php index e09b3ad32d2..5964f1aa836 100644 --- a/src/Core/ObjectRegistry.php +++ b/src/Core/ObjectRegistry.php @@ -122,11 +122,11 @@ protected function _checkDuplicate($name, $config) { $fail = false; foreach ($config as $key => $value) { - if (isset($existingConfig[$key]) && $existingConfig[$key] !== $value) { + if (!array_key_exists($key, $existingConfig)) { $fail = true; break; } - if (!array_key_exists($key, $existingConfig)) { + if (isset($existingConfig[$key]) && $existingConfig[$key] !== $value) { $fail = true; break; } diff --git a/tests/TestCase/View/HelperRegistryTest.php b/tests/TestCase/View/HelperRegistryTest.php index dc830142986..8e03fef5bd6 100644 --- a/tests/TestCase/View/HelperRegistryTest.php +++ b/tests/TestCase/View/HelperRegistryTest.php @@ -251,10 +251,23 @@ public function testLoadMultipleTimesAlreadyConfigured() { $this->addToAssertionCount(1); } +/** + * Loading a helper overriding defaults to default value + * should "just work" + * + * @return void + */ + public function testLoadMultipleTimesDefaultConfigValuesWorks() { + $this->Helpers->load('Number', ['engine' => 'Cake\I18n\Number']); + $this->Helpers->load('Number'); + $this->addToAssertionCount(1); + } + /** * Loading a helper with different config, should throw an exception * * @expectedException RuntimeException + * @expectedExceptionMessage The "Html" alias has already been loaded with the following * @return void */ public function testLoadMultipleTimesDifferentConfigured() { @@ -266,6 +279,7 @@ public function testLoadMultipleTimesDifferentConfigured() { * Loading a helper with different config, should throw an exception * * @expectedException RuntimeException + * @expectedExceptionMessage The "Html" alias has already been loaded with the following * @return void */ public function testLoadMultipleTimesDifferentConfigValues() {