Permalink
Browse files

Backport of 3.0 Configure corrections.

  • Loading branch information...
dereuromark committed Jan 4, 2015
1 parent 4cd2c8f commit b936a34471f97aa50e6fc1173912e24480db7327
Showing with 23 additions and 9 deletions.
  1. +5 −5 lib/Cake/Core/Configure.php
  2. +18 −4 lib/Cake/Test/Case/Core/ConfigureTest.php
@@ -179,7 +179,7 @@ public static function write($config, $value = null) {
* Configure::read('Name.key'); will return only the value of Configure::Name[key]
* }}}
*
* @param string $var Variable to obtain. Use '.' to access array elements.
* @param string|null $var Variable to obtain. Use '.' to access array elements.
* @return mixed value stored in configure, or null.
* @link http://book.cakephp.org/2.0/en/development/configuration.html#Configure::read
*/
@@ -220,7 +220,7 @@ public static function consume($var) {
* @param string $var Variable name to check for
* @return bool True if variable is there
*/
public static function check($var = null) {
public static function check($var) {
if (empty($var)) {
return false;
}
@@ -240,7 +240,7 @@ public static function check($var = null) {
* @return void
* @link http://book.cakephp.org/2.0/en/development/configuration.html#Configure::delete
*/
public static function delete($var = null) {
public static function delete($var) {
self::$_values = Hash::remove(self::$_values, $var);
}
@@ -265,7 +265,7 @@ public static function config($name, ConfigReaderInterface $reader) {
/**
* Gets the names of the configured reader objects.
*
* @param string $name Name to check. If null returns all configured reader names.
* @param string|null $name Name to check. If null returns all configured reader names.
* @return array Array of the configured reader objects.
*/
public static function configured($name = null) {
@@ -443,7 +443,7 @@ public static function restore($name, $cacheConfig = 'default') {
/**
* Clear all values stored in Configure.
*
* @return bool success.
* @return bool Success.
*/
public static function clear() {
self::$_values = array();
@@ -168,6 +168,19 @@ public function testConsume() {
$this->assertEquals($expected, $result);
}
/**
* testConsumeEmpty
*
* @return void
*/
public function testConsumeEmpty() {
Configure::write('Test', array('key' => 'value', 'key2' => 'value2'));
$result = Configure::consume('');
$this->assertNull($result);
$result = Configure::consume(null);
$this->assertNull($result);
}
/**
* test setting display_errors with debug.
*
@@ -195,7 +208,7 @@ public function testDelete() {
Configure::delete('SomeName.someKey');
$result = Configure::read('SomeName.someKey');
$this->assertTrue($result === null);
$this->assertNull($result);
Configure::write('SomeName', array('someKey' => 'myvalue', 'otherKey' => 'otherValue'));
@@ -208,10 +221,10 @@ public function testDelete() {
Configure::delete('SomeName');
$result = Configure::read('SomeName.someKey');
$this->assertTrue($result === null);
$this->assertNull($result);
$result = Configure::read('SomeName.otherKey');
$this->assertTrue($result === null);
$this->assertNull($result);
}
/**
@@ -265,7 +278,8 @@ public function testCheckKeyWithSpaces() {
* @return void
*/
public function testCheckEmpty() {
$this->assertFalse(Configure::check());
$this->assertFalse(Configure::check(''));
$this->assertFalse(Configure::check(null));
}
/**

0 comments on commit b936a34

Please sign in to comment.