From 7f1a1cae65b35356b3c238ed77716df22a9218d9 Mon Sep 17 00:00:00 2001 From: 7IN0SAN9 Date: Fri, 29 Jan 2016 16:31:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8setUp()=E6=96=B9=E6=B3=95=E4=B8=AD?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E6=89=A9=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/thinkphp/library/think/cache/driver/apcTest.php | 10 +++++----- .../library/think/cache/driver/memcachedTest.php | 6 +++--- .../thinkphp/library/think/cache/driver/redisTest.php | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/thinkphp/library/think/cache/driver/apcTest.php b/tests/thinkphp/library/think/cache/driver/apcTest.php index 0557c412..981f114e 100644 --- a/tests/thinkphp/library/think/cache/driver/apcTest.php +++ b/tests/thinkphp/library/think/cache/driver/apcTest.php @@ -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(); } diff --git a/tests/thinkphp/library/think/cache/driver/memcachedTest.php b/tests/thinkphp/library/think/cache/driver/memcachedTest.php index 95328482..051083c2 100644 --- a/tests/thinkphp/library/think/cache/driver/memcachedTest.php +++ b/tests/thinkphp/library/think/cache/driver/memcachedTest.php @@ -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(); } diff --git a/tests/thinkphp/library/think/cache/driver/redisTest.php b/tests/thinkphp/library/think/cache/driver/redisTest.php index 29a6e301..c40cb68b 100644 --- a/tests/thinkphp/library/think/cache/driver/redisTest.php +++ b/tests/thinkphp/library/think/cache/driver/redisTest.php @@ -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(); }