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:
Mark Story 2010-01-21 14:14:26 -05:00
parent ff7e906ba2
commit 513db9a72a
3 changed files with 9 additions and 15 deletions

View file

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

View file

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

View file

@ -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);