Changed Configure::write to return true on success. Maked testing result simpler.

This commit is contained in:
predominant 2010-03-04 10:20:15 +11:00
parent 174108df19
commit 382e11ccde
2 changed files with 11 additions and 7 deletions

View file

@ -75,7 +75,7 @@ class Configure extends Object {
* @link http://book.cakephp.org/view/412/write * @link http://book.cakephp.org/view/412/write
* @param array $config Name of var to write * @param array $config Name of var to write
* @param mixed $value Value to set for var * @param mixed $value Value to set for var
* @return void * @return boolean True if write was successful
* @access public * @access public
*/ */
function write($config, $value = null) { function write($config, $value = null) {
@ -133,6 +133,7 @@ class Configure extends Object {
} }
error_reporting($reporting); error_reporting($reporting);
} }
return true;
} }
/** /**

View file

@ -108,16 +108,19 @@ class ConfigureTest extends CakeTestCase {
* @return void * @return void
*/ */
function testWrite() { function testWrite() {
Configure::write('SomeName.someKey', 'myvalue'); $writeResult = Configure::write('SomeName.someKey', 'myvalue');
$this->assertTrue($writeResult);
$result = Configure::read('SomeName.someKey'); $result = Configure::read('SomeName.someKey');
$this->assertEqual($result, 'myvalue'); $this->assertEqual($result, 'myvalue');
Configure::write('SomeName.someKey', null); $writeResult = Configure::write('SomeName.someKey', null);
$this->assertTrue($writeResult);
$result = Configure::read('SomeName.someKey'); $result = Configure::read('SomeName.someKey');
$this->assertEqual($result, null); $this->assertEqual($result, null);
$expected = array('One' => array('Two' => array('Three' => array('Four' => array('Five' => 'cool'))))); $expected = array('One' => array('Two' => array('Three' => array('Four' => array('Five' => 'cool')))));
Configure::write('Key', $expected); $writeResult = Configure::write('Key', $expected);
$this->assertTrue($writeResult);
$result = Configure::read('Key'); $result = Configure::read('Key');
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);
@ -226,7 +229,7 @@ class ConfigureTest extends CakeTestCase {
$this->assertFalse($result); $this->assertFalse($result);
$result = Configure::load('config'); $result = Configure::load('config');
$this->assertTrue($result === null); $this->assertTrue($result);
$result = Configure::load('../../index'); $result = Configure::load('../../index');
$this->assertFalse($result); $this->assertFalse($result);
@ -241,13 +244,13 @@ class ConfigureTest extends CakeTestCase {
function testLoadPlugin() { function testLoadPlugin() {
App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)), true); App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)), true);
$result = Configure::load('test_plugin.load'); $result = Configure::load('test_plugin.load');
$this->assertTrue($result === null); $this->assertTrue($result);
$expected = '/test_app/plugins/test_plugin/config/load.php'; $expected = '/test_app/plugins/test_plugin/config/load.php';
$config = Configure::read('plugin_load'); $config = Configure::read('plugin_load');
$this->assertEqual($config, $expected); $this->assertEqual($config, $expected);
$result = Configure::load('test_plugin.more.load'); $result = Configure::load('test_plugin.more.load');
$this->assertTrue($result === null); $this->assertTrue($result);
$expected = '/test_app/plugins/test_plugin/config/more.load.php'; $expected = '/test_app/plugins/test_plugin/config/more.load.php';
$config = Configure::read('plugin_more_load'); $config = Configure::read('plugin_more_load');
$this->assertEqual($config, $expected); $this->assertEqual($config, $expected);