mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-02 05:02:48 +08:00
Merge branch 'master' of https://github.com/top-think/think
This commit is contained in:
@@ -25,7 +25,7 @@ class fileTest extends cacheTestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
\think\Cache::connect(array('type' => 'File', 'expire' => 2));
|
||||
\think\Cache::connect(['type' => 'File', 'path'=> CACHE_PATH]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,21 +34,26 @@ class fileTest extends cacheTestCase
|
||||
protected function getCacheInstance()
|
||||
{
|
||||
if (null === $this->_cacheInstance) {
|
||||
$this->_cacheInstance = new \think\cache\driver\File([
|
||||
'expire'=>2,
|
||||
'path'=> CACHE_PATH,
|
||||
]);
|
||||
$this->_cacheInstance = new \think\cache\driver\File();
|
||||
}
|
||||
return $this->_cacheInstance;
|
||||
}
|
||||
|
||||
// 待调整后测试
|
||||
// rewrite testQueue
|
||||
public function testQueue()
|
||||
{
|
||||
$cache = $this->prepare();
|
||||
$this->assertTrue($cache->set('1', '1'));
|
||||
$this->assertTrue($cache->set('2', '2'));
|
||||
$this->assertTrue($cache->set('3', '3'));
|
||||
$this->assertEquals(1, $cache->get('1'));
|
||||
$this->assertTrue($cache->set('4', '4'));
|
||||
$this->assertTrue($cache->set('1', false));
|
||||
$this->assertFalse($cache->get('1'));
|
||||
}
|
||||
|
||||
// skip testExpire
|
||||
public function testExpire()
|
||||
{
|
||||
}
|
||||
|
||||
public function testQueue()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
49
tests/thinkphp/library/think/cache/driver/memcacheTest.php
vendored
Normal file
49
tests/thinkphp/library/think/cache/driver/memcacheTest.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Memcache缓存驱动测试
|
||||
* @author 刘志淳 <chun@engineer.com>
|
||||
*/
|
||||
|
||||
namespace tests\thinkphp\library\think\cache\driver;
|
||||
|
||||
class memcacheTest extends cacheTestCase
|
||||
{
|
||||
private $_cacheInstance = null;
|
||||
|
||||
/**
|
||||
* 基境缓存类型
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
if (!extension_loaded('memcache')) {
|
||||
$this->markTestSkipped("Memcache没有安装,已跳过测试!");
|
||||
}
|
||||
\think\Cache::connect(['type' => 'memcache', 'expire' => 2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ApcCache
|
||||
*/
|
||||
protected function getCacheInstance()
|
||||
{
|
||||
if (null === $this->_cacheInstance) {
|
||||
$this->_cacheInstance = new \think\cache\driver\Memcache(['length' => 3]);
|
||||
}
|
||||
return $this->_cacheInstance;
|
||||
}
|
||||
|
||||
// skip testExpire
|
||||
public function testExpire()
|
||||
{
|
||||
}
|
||||
}
|
||||
70
tests/thinkphp/library/think/cache/driver/testTest.php
vendored
Normal file
70
tests/thinkphp/library/think/cache/driver/testTest.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Test缓存驱动测试
|
||||
* @author 刘志淳 <chun@engineer.com>
|
||||
*/
|
||||
|
||||
namespace tests\thinkphp\library\think\cache\driver;
|
||||
|
||||
use think\Cache;
|
||||
|
||||
class testTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* 测试缓存读取
|
||||
* @return mixed
|
||||
* @access public
|
||||
*/
|
||||
public function testGet()
|
||||
{
|
||||
$cache = Cache::connect(['type' => 'Test']);
|
||||
|
||||
$this->assertFalse($cache->get('test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试缓存设置
|
||||
* @return mixed
|
||||
* @access public
|
||||
*/
|
||||
public function testSet()
|
||||
{
|
||||
$cache = Cache::connect(['type' => 'Test']);
|
||||
|
||||
$this->assertTrue($cache->set('test', 'test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除缓存测试
|
||||
* @return mixed
|
||||
* @access public
|
||||
*/
|
||||
public function testRm()
|
||||
{
|
||||
$cache = Cache::connect(['type' => 'Test']);
|
||||
|
||||
$this->assertTrue($cache->rm('test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空缓存测试
|
||||
* @return mixed
|
||||
* @access public
|
||||
*/
|
||||
public function testClear()
|
||||
{
|
||||
$cache = Cache::connect(['type' => 'Test']);
|
||||
|
||||
$this->assertTrue($cache->clear());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user