mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Fix return values in Cache.
The documentation indicates that false/or the value will be returnned. Using both null and false to indicate failure is confusing. Use only false to indicate failure. It might be better in the future to use exceptions for trying to read/write on missing cache configs.
This commit is contained in:
parent
992a1554e1
commit
7f68699fcd
2 changed files with 17 additions and 4 deletions
|
@ -285,7 +285,7 @@ class Cache {
|
|||
$settings = self::settings($config);
|
||||
|
||||
if (empty($settings)) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
if (!self::isInitialized($config)) {
|
||||
return false;
|
||||
|
@ -335,7 +335,7 @@ class Cache {
|
|||
$settings = self::settings($config);
|
||||
|
||||
if (empty($settings)) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
if (!self::isInitialized($config)) {
|
||||
return false;
|
||||
|
@ -360,7 +360,7 @@ class Cache {
|
|||
$settings = self::settings($config);
|
||||
|
||||
if (empty($settings)) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
if (!self::isInitialized($config)) {
|
||||
return false;
|
||||
|
@ -422,7 +422,7 @@ class Cache {
|
|||
$settings = self::settings($config);
|
||||
|
||||
if (empty($settings)) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
if (!self::isInitialized($config)) {
|
||||
return false;
|
||||
|
|
|
@ -126,6 +126,19 @@ class CacheTest extends CakeTestCase {
|
|||
$read = Cache::read('Test', 'invalid');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test reading from a config that is undefined.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testReadNonExistingConfig() {
|
||||
$this->assertFalse(Cache::read('key', 'totally fake'));
|
||||
$this->assertFalse(Cache::write('key', 'value', 'totally fake'));
|
||||
$this->assertFalse(Cache::increment('key', 'value', 'totally fake'));
|
||||
$this->assertFalse(Cache::decrement('key', 'value', 'totally fake'));
|
||||
}
|
||||
|
||||
/**
|
||||
* test that trying to configure classes that don't extend CacheEngine fail.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue