diff --git a/tests/TestCase/Core/ConfigureTest.php b/tests/TestCase/Core/ConfigureTest.php index f42517b7b4d..948ff61c562 100644 --- a/tests/TestCase/Core/ConfigureTest.php +++ b/tests/TestCase/Core/ConfigureTest.php @@ -1,9 +1,5 @@ * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) * @@ -303,6 +299,38 @@ public function testLoadNoMerge() { $this->assertNull(Configure::read('Deep.Deeper.Deepest')); } +/** + * Test load() replacing existing data + * + * @return void + */ + public function testLoadWithExistingData() { + Configure::config('test', new PhpConfig(TEST_APP . 'TestApp/Config/')); + Configure::write('my_key', 'value'); + + Configure::load('var_test', 'test'); + $this->assertEquals('value', Configure::read('my_key'), 'Should not overwrite existing data.'); + $this->assertEquals('value', Configure::read('Read'), 'Should load new data.'); + } + +/** + * Test load() merging on top of existing data + * + * @return void + */ + public function testLoadMergeWithExistingData() { + Configure::config('test', new PhpConfig(TEST_APP . 'TestApp/Config/')); + Configure::write('my_key', 'value'); + Configure::write('Read', 'old'); + Configure::write('Deep.old', 'old'); + + Configure::load('var_test', 'test', true); + $this->assertEquals('value', Configure::read('Read'), 'Should load new data.'); + $this->assertEquals('buried', Configure::read('Deep.Deeper.Deepest'), 'Should load new data'); + $this->assertEquals('old', Configure::read('Deep.old'), 'Should not destroy old data.'); + $this->assertEquals('value', Configure::read('my_key'), 'Should not destroy data.'); + } + /** * testLoad method *