改进Query类的lazyWrite方法 改进缓存单元测试 核心去除redis缓存驱动

This commit is contained in:
thinkphp
2016-07-25 13:37:45 +08:00
parent e5dd77ea26
commit e74907f5c9
6 changed files with 41 additions and 634 deletions

View File

@@ -62,6 +62,28 @@ abstract class cacheTestCase extends \PHPUnit_Framework_TestCase
$this->assertTrue($cache->set('array_test', ['array_test' => 'array_test']));
}
/**
* 测试缓存自增
* @return mixed
* @access public
*/
public function testInc()
{
$cache = $this->getCacheInstance();
$this->assertEquals(14, $cache->inc('number_test', 3));
}
/**
* 测试缓存自减
* @return mixed
* @access public
*/
public function testDec()
{
$cache = $this->getCacheInstance();
$this->assertEquals(8, $cache->dec('number_test', 6));
}
/**
* 测试缓存读取,包括测试字符串、整数、数组和对象
* @return mixed

View File

@@ -1,66 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
/**
* Redis缓存驱动测试
* @author 7IN0SAN9 <me@7in0.me>
*/
namespace tests\thinkphp\library\think\cache\driver;
class redisTest extends cacheTestCase
{
private $_cacheInstance = null;
protected function setUp()
{
if (!extension_loaded("redis")) {
$this->markTestSkipped("Redis没有安装已跳过测试");
}
\think\Cache::connect(array('type' => 'redis', 'expire' => 2));
}
protected function getCacheInstance()
{
if (null === $this->_cacheInstance) {
$this->_cacheInstance = new \think\cache\driver\Redis(['length' => 3]);
}
return $this->_cacheInstance;
}
public function testGet()
{
$cache = $this->prepare();
$this->assertEquals('string_test', $cache->get('string_test'));
$this->assertEquals(11, $cache->get('number_test'));
$result = $cache->get('array_test');
$this->assertEquals('array_test', $result['array_test']);
}
public function testStoreSpecialValues()
{
$redis = new \think\cache\driver\Redis(['length' => 3]);
$redis->set('key', 'value');
$redis->get('key');
$redis->handler()->setnx('key', 'value');
$value = $redis->handler()->get('key');
$this->assertEquals('value', $value);
$redis->handler()->hset('hash', 'key', 'value');
$value = $redis->handler()->hget('hash', 'key');
$this->assertEquals('value', $value);
}
public function testExpire()
{
}
}

View File

@@ -1,72 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace tests\thinkphp\library\think\cache\driver;
/**
* Redisd缓存驱动测试
* @author 尘缘 <130775@qq.com>
*/
class redisdTest extends cacheTestCase
{
private $_cacheInstance = null;
protected function setUp()
{
if (!extension_loaded("redis")) {
$this->markTestSkipped("Redis没有安装已跳过测试");
}
\think\Cache::connect(array('type' => 'redis', 'expire' => 2));
}
protected function getCacheInstance()
{
if (null === $this->_cacheInstance) {
$this->_cacheInstance = new \think\cache\driver\Redisd();
}
return $this->_cacheInstance;
}
public function testGet()
{
$cache = $this->prepare();
$this->assertEquals('string_test', $cache->get('string_test'));
$this->assertEquals(11, $cache->get('number_test'));
$result = $cache->get('array_test');
$this->assertEquals('array_test', $result['array_test']);
}
public function testStoreSpecialValues()
{
$redis = $this->getCacheInstance();
$redis->master(true);
$redis->handler()->setnx('key', 'value');
$value = $redis->handler()->get('key');
$this->assertEquals('value', $value);
$redis->master(true)->set('key', 'val');
$value = $redis->master(false)->get('key');
$this->assertEquals('val', $value);
$redis->handler(true)->hset('hash', 'key', 'value');
$value = $redis->handler(false)->hget('hash', 'key');
$this->assertEquals('value', $value);
}
public function testExpire()
{
}
public function testQueue()
{
}
}