Skip to content

Commit

Permalink
Merge pull request #5557 from cakephp/2.7-configure-backport
Browse files Browse the repository at this point in the history
Backport of 3.0 Configure corrections.
  • Loading branch information
Mark S committed Jan 4, 2015
2 parents 848e913 + a947958 commit b76fbd8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
10 changes: 5 additions & 5 deletions lib/Cake/Core/Configure.php
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
22 changes: 18 additions & 4 deletions lib/Cake/Test/Case/Core/ConfigureTest.php
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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'));

Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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));
}

/**
Expand Down

0 comments on commit b76fbd8

Please sign in to comment.