|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace Yiisoft\Cache\Tests\Memcached; |
|
5
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
use Psr\SimpleCache\CacheInterface; |
|
8
|
|
|
use Yiisoft\Cache\Memcached; |
|
9
|
|
|
use Yiisoft\Cache\MemcachedServer; |
|
10
|
|
|
use Yiisoft\Cache\Tests\BaseTest; |
|
11
|
|
|
|
|
12
|
|
|
class MemcachedTest extends BaseTest |
|
13
|
|
|
{ |
|
14
|
|
|
public static function setUpBeforeClass(): void |
|
15
|
|
|
{ |
|
16
|
|
|
if (!extension_loaded('memcached')) { |
|
17
|
|
|
self::markTestSkipped('Required extension "memcached" is not loaded'); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
// check whether memcached is running and skip tests if not. |
|
21
|
|
|
if (!@stream_socket_client('127.0.0.1:11211', $errorNumber, $errorDescription, 0.5)) { |
|
22
|
|
|
self::markTestSkipped('No memcached server running at ' . '127.0.0.1:11211' . ' : ' . $errorNumber . ' - ' . $errorDescription); |
|
23
|
|
|
} |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
protected function createCacheInstance(): CacheInterface |
|
27
|
|
|
{ |
|
28
|
|
|
$cache = new Memcached(); |
|
29
|
|
|
$cache->addServer(new MemcachedServer('127.0.0.1')); |
|
30
|
|
|
return $cache; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function testDeleteMultipleReturnsFalse(): void |
|
34
|
|
|
{ |
|
35
|
|
|
$cache = new Memcached(); |
|
36
|
|
|
|
|
37
|
|
|
$memcachedStub = $this->createMock(\Memcached::class); |
|
38
|
|
|
$memcachedStub->method('deleteMulti')->willReturn([false]); |
|
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
$this->setInaccessibleProperty($cache, 'cache', $memcachedStub); |
|
41
|
|
|
|
|
42
|
|
|
$this->assertFalse($cache->deleteMultiple(['a', 'b'])); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function testExpire(): void |
|
46
|
|
|
{ |
|
47
|
|
|
if (getenv('TRAVIS') === 'true') { |
|
48
|
|
|
$this->markTestSkipped('Can not reliably test memcached expiry on travis-ci.'); |
|
49
|
|
|
} |
|
50
|
|
|
// TODO |
|
51
|
|
|
$this->assertTrue(true); |
|
52
|
|
|
//parent::testExpire(); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.