MemCachedTest.php 1.06 KB
Newer Older
1 2
<?php
namespace yiiunit\framework\caching;
Alexander Makarov committed
3

4 5 6
use yii\caching\MemCache;

/**
7
 * Class for testing memcached cache backend
8 9
 * @group memcached
 * @group caching
10
 */
Alexander Makarov committed
11
class MemCachedTest extends CacheTestCase
12
{
13
    private $_cacheInstance = null;
14

15 16 17 18 19 20 21 22
    /**
     * @return MemCache
     */
    protected function getCacheInstance()
    {
        if (!extension_loaded("memcached")) {
            $this->markTestSkipped("memcached not installed. Skipping.");
        }
23

24 25 26
        if ($this->_cacheInstance === null) {
            $this->_cacheInstance = new MemCache(['useMemcached' => true]);
        }
27

28 29
        return $this->_cacheInstance;
    }
30

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
    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();
    }
Zander Baldwin committed
46
}