Browse Source

merge by default

AD7six 12 years ago
parent
commit
7917fd7670

+ 2 - 2
src/Core/InstanceConfigTrait.php

@@ -68,10 +68,10 @@ trait InstanceConfigTrait {
  * @param string|array|null $key the key to get/set, or a complete array of configs
  * @param mixed|null $value the value to set
  * @return mixed|null null for write, or whatever is in the config on read
- * @param bool $merge whether to merge or overwrite existing config
+ * @param bool $merge whether to merge or overwrite existing config defaults to true
  * @throws \Cake\Error\Exception When trying to set a key that is invalid
  */
-	public function config($key = null, $value = null, $merge = false) {
+	public function config($key = null, $value = null, $merge = true) {
 		if (!$this->_configInitialized) {
 			$this->_config = $this->_defaultConfig;
 			$this->_configInitialized = true;

+ 5 - 5
tests/TestCase/Core/InstanceConfigTraitTest.php

@@ -270,7 +270,7 @@ class InstanceConfigTraitTest extends TestCase {
  * @return void
  */
 	public function testMerge() {
-		$this->object->config(['a' => ['nother' => 'value']], null, true);
+		$this->object->config(['a' => ['nother' => 'value']]);
 
 		$this->assertSame(
 			[
@@ -291,7 +291,7 @@ class InstanceConfigTraitTest extends TestCase {
  * @return void
  */
 	public function testMergeDotKey() {
-		$this->object->config('a.nother', 'value', true);
+		$this->object->config('a.nother', 'value');
 
 		$this->assertSame(
 			[
@@ -305,7 +305,7 @@ class InstanceConfigTraitTest extends TestCase {
 			'Should act the same as having passed the equivalent array to the config function'
 		);
 
-		$this->object->config(['a.nextra' => 'value'], null, true);
+		$this->object->config(['a.nextra' => 'value']);
 
 		$this->assertSame(
 			[
@@ -327,7 +327,7 @@ class InstanceConfigTraitTest extends TestCase {
  * @return void
  */
 	public function testSetDefaultsMerge() {
-		$this->object->config(['a' => ['nother' => 'value']], null, true);
+		$this->object->config(['a' => ['nother' => 'value']]);
 
 		$this->assertSame(
 			[
@@ -371,7 +371,7 @@ class InstanceConfigTraitTest extends TestCase {
  * @return void
  */
 	public function testSetMergeNoClobber() {
-		$this->object->config(['a.nested.value' => 'it is possible'], null, true);
+		$this->object->config(['a.nested.value' => 'it is possible']);
 
 		$this->assertSame(
 			[