You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
12 years ago
|
<?php
|
||
|
namespace yiiunit\framework\caching;
|
||
11 years ago
|
|
||
12 years ago
|
use yii\caching\MemCache;
|
||
|
|
||
|
/**
|
||
12 years ago
|
* Class for testing memcached cache backend
|
||
11 years ago
|
* @group memcached
|
||
|
* @group caching
|
||
12 years ago
|
*/
|
||
12 years ago
|
class MemCachedTest extends CacheTestCase
|
||
12 years ago
|
{
|
||
11 years ago
|
private $_cacheInstance = null;
|
||
12 years ago
|
|
||
11 years ago
|
/**
|
||
|
* @return MemCache
|
||
|
*/
|
||
|
protected function getCacheInstance()
|
||
|
{
|
||
|
if (!extension_loaded("memcached")) {
|
||
|
$this->markTestSkipped("memcached not installed. Skipping.");
|
||
|
}
|
||
12 years ago
|
|
||
10 years ago
|
// check whether memcached is running and skip tests if not.
|
||
|
if (!@stream_socket_client('127.0.0.1:11211', $errorNumber, $errorDescription, 0.5)) {
|
||
|
$this->markTestSkipped('No redis server running at ' . '127.0.0.1:11211' . ' : ' . $errorNumber . ' - ' . $errorDescription);
|
||
|
}
|
||
|
|
||
11 years ago
|
if ($this->_cacheInstance === null) {
|
||
|
$this->_cacheInstance = new MemCache(['useMemcached' => true]);
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
return $this->_cacheInstance;
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
public function testExpire()
|
||
|
{
|
||
|
if (getenv('TRAVIS') == 'true') {
|
||
|
$this->markTestSkipped('Can not reliably test memcached expiry on travis-ci.');
|
||
|
}
|
||
|
parent::testExpire();
|
||
|
}
|
||
|
|
||
|
public function testExpireAdd()
|
||
|
{
|
||
|
if (getenv('TRAVIS') == 'true') {
|
||
|
$this->markTestSkipped('Can not reliably test memcached expiry on travis-ci.');
|
||
|
}
|
||
|
parent::testExpireAdd();
|
||
|
}
|
||
12 years ago
|
}
|