mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Removing repeated checks, as they've been refactored into Cache::increment() and Cache::decrement().
Adding skipIf()'s to ApcEngineTest in case apc_inc, and apc_dec are not available.
This commit is contained in:
parent
ff7e906ba2
commit
513db9a72a
3 changed files with 9 additions and 15 deletions
6
cake/libs/cache/apc.php
vendored
6
cake/libs/cache/apc.php
vendored
|
@ -84,9 +84,6 @@ class ApcEngine extends CacheEngine {
|
|||
* @access public
|
||||
*/
|
||||
function increment($key, $offset = 1) {
|
||||
if (!is_integer($offset) || $offset < 0) {
|
||||
return false;
|
||||
}
|
||||
return apc_inc($key, $offset);
|
||||
}
|
||||
|
||||
|
@ -100,9 +97,6 @@ class ApcEngine extends CacheEngine {
|
|||
* @access public
|
||||
*/
|
||||
function decrement($key, $offset = 1) {
|
||||
if (!is_integer($offset) || $offset < 0) {
|
||||
return false;
|
||||
}
|
||||
return apc_dec($key, $offset);
|
||||
}
|
||||
|
||||
|
|
6
cake/libs/cache/xcache.php
vendored
6
cake/libs/cache/xcache.php
vendored
|
@ -101,9 +101,6 @@ class XcacheEngine extends CacheEngine {
|
|||
* @access public
|
||||
*/
|
||||
function increment($key, $offset = 1) {
|
||||
if (!is_integer($offset) || $offset < 0) {
|
||||
return false;
|
||||
}
|
||||
return xcache_inc($key, $offset);
|
||||
}
|
||||
|
||||
|
@ -118,9 +115,6 @@ class XcacheEngine extends CacheEngine {
|
|||
* @access public
|
||||
*/
|
||||
function decrement($key, $offset = 1) {
|
||||
if (!is_integer($offset) || $offset < 0) {
|
||||
return false;
|
||||
}
|
||||
return xcache_dec($key, $offset);
|
||||
}
|
||||
/**
|
||||
|
|
12
cake/tests/cases/libs/cache/apc.test.php
vendored
12
cake/tests/cases/libs/cache/apc.test.php
vendored
|
@ -27,7 +27,7 @@ if (!class_exists('Cache')) {
|
|||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.cache
|
||||
*/
|
||||
class ApcEngineTest extends UnitTestCase {
|
||||
class ApcEngineTest extends CakeTestCase {
|
||||
|
||||
/**
|
||||
* skip method
|
||||
|
@ -147,7 +147,10 @@ class ApcEngineTest extends UnitTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function testDecrement() {
|
||||
function testDecrement() {
|
||||
if ($this->skipIf(!function_exists('apc_dec'), 'No apc_dec() function, cannot test decrement() %s')) {
|
||||
return;
|
||||
}
|
||||
$result = Cache::write('test_decrement', 5);
|
||||
$this->assertTrue($result);
|
||||
|
||||
|
@ -171,7 +174,10 @@ class ApcEngineTest extends UnitTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function testIncrement() {
|
||||
function testIncrement() {
|
||||
if ($this->skipIf(!function_exists('apc_inc'), 'No apc_inc() function, cannot test increment() %s')) {
|
||||
return;
|
||||
}
|
||||
$result = Cache::write('test_increment', 5);
|
||||
$this->assertTrue($result);
|
||||
|
||||
|
|
Loading…
Reference in a new issue