修正Cache类和改进单元测试

This commit is contained in:
thinkphp
2016-07-31 09:43:09 +08:00
parent b2275a1d87
commit 609d3c76a7
2 changed files with 11 additions and 4 deletions

View File

@@ -118,7 +118,7 @@ class Cache
* @param int $expire 有效时间 0为永久
* @return false|int
*/
public function inc($name, $step = 1, $expire = null)
public static function inc($name, $step = 1, $expire = null)
{
self::init();
self::$writeTimes++;
@@ -133,7 +133,7 @@ class Cache
* @param int $expire 有效时间 0为永久
* @return false|int
*/
public function dec($name, $step = 1, $expire = null)
public static function dec($name, $step = 1, $expire = null)
{
self::init();
self::$writeTimes++;

View File

@@ -180,9 +180,16 @@ abstract class cacheTestCase extends \PHPUnit_Framework_TestCase
public function testStaticCall()
{
$this->assertTrue(Cache::set('a', 'a'));
$this->assertEquals('a', Cache::get('a'));
$this->assertTrue(Cache::set('a', 1));
$this->assertEquals(1, Cache::get('a'));
$this->assertEquals(2, Cache::inc('a'));
$this->assertEquals(4, Cache::inc('a', 2));
$this->assertEquals(4, Cache::get('a'));
$this->assertEquals(3, Cache::dec('a'));
$this->assertEquals(1, Cache::dec('a', 2));
$this->assertEquals(1, Cache::get('a'));
$this->assertNotNull(Cache::rm('a'));
$this->assertNotNull(Cache::clear());
}
}