mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
在setUp()方法中检测扩展
This commit is contained in:
@@ -24,6 +24,11 @@ class apcTest extends cacheTestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
if (!extension_loaded("apc")) {
|
||||
$this->markTestSkipped("APC没有安装,已跳过测试!");
|
||||
} elseif ('cli' === PHP_SAPI && !ini_get('apc.enable_cli')) {
|
||||
$this->markTestSkipped("APC模块没有开启,已跳过测试!");
|
||||
}
|
||||
\think\Cache::connect(array('type' => 'apc', 'expire' => 2));
|
||||
}
|
||||
/**
|
||||
@@ -31,11 +36,6 @@ class apcTest extends cacheTestCase
|
||||
*/
|
||||
protected function getCacheInstance()
|
||||
{
|
||||
if (!extension_loaded("apc")) {
|
||||
$this->markTestSkipped("APC没有安装,已跳过测试!");
|
||||
} elseif ('cli' === PHP_SAPI && !ini_get('apc.enable_cli')) {
|
||||
$this->markTestSkipped("APC模块没有开启,已跳过测试!");
|
||||
}
|
||||
if (null === $this->_cacheInstance) {
|
||||
$this->_cacheInstance = new \think\cache\driver\Apc();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,9 @@ class memcachedTest extends cacheTestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
if (!extension_loaded("memcached") && !extension_loaded('memcache')) {
|
||||
$this->markTestSkipped("Memcached或Memcache没有安装,已跳过测试!");
|
||||
}
|
||||
\think\Cache::connect(array('type' => 'memcached', 'expire' => 2));
|
||||
}
|
||||
/**
|
||||
@@ -31,9 +34,6 @@ class memcachedTest extends cacheTestCase
|
||||
*/
|
||||
protected function getCacheInstance()
|
||||
{
|
||||
if (!extension_loaded("memcached")) {
|
||||
$this->markTestSkipped("Memcached没有安装,已跳过测试!");
|
||||
}
|
||||
if (null === $this->_cacheInstance) {
|
||||
$this->_cacheInstance = new \think\cache\driver\Memcached();
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ class redisTest extends cacheTestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (!extension_loaded("redis")) {
|
||||
$this->markTestSkipped("Redis没有安装,已跳过测试!");
|
||||
}
|
||||
\think\Cache::connect(array('type' => 'redis', 'expire' => 2));
|
||||
}
|
||||
|
||||
protected function getCacheInstance()
|
||||
{
|
||||
if (!extension_loaded("redis")) {
|
||||
$this->markTestSkipped("Redis没有安装,已跳过测试!");
|
||||
}
|
||||
if (null === $this->_cacheInstance) {
|
||||
$this->_cacheInstance = new \think\cache\driver\Redis();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user