Skip to content

Commit

Permalink
Add additional tests for making load().
Browse files Browse the repository at this point in the history
Add tests for not overwriting keys when loading data.
  • Loading branch information
markstory committed May 16, 2014
1 parent b359b24 commit 3d96505
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions tests/TestCase/Core/ConfigureTest.php
@@ -1,9 +1,5 @@
<?php
/**
* ConfigureTest file
*
* Holds several tests
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit 3d96505

Please sign in to comment.