2018-07-07 17:46:16 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace Friendica\Test\src\Core\Cache;
|
|
|
|
|
2019-08-04 08:26:53 +00:00
|
|
|
use Friendica\Core\Cache\MemcachedCache;
|
2019-12-19 19:11:07 +00:00
|
|
|
use Friendica\Core\Config\IConfiguration;
|
2019-08-03 18:48:56 +00:00
|
|
|
use Psr\Log\NullLogger;
|
2018-07-07 17:46:16 +00:00
|
|
|
|
2018-07-18 19:04:18 +00:00
|
|
|
/**
|
|
|
|
* @requires extension memcached
|
2019-09-23 12:31:13 +00:00
|
|
|
* @group MEMCACHED
|
2018-07-18 19:04:18 +00:00
|
|
|
*/
|
2019-08-04 08:26:53 +00:00
|
|
|
class MemcachedCacheTest extends MemoryCacheTest
|
2018-07-07 17:46:16 +00:00
|
|
|
{
|
|
|
|
protected function getInstance()
|
|
|
|
{
|
2019-12-19 19:11:07 +00:00
|
|
|
$configMock = \Mockery::mock(IConfiguration::class);
|
2019-08-03 18:48:56 +00:00
|
|
|
|
2019-09-16 12:47:49 +00:00
|
|
|
$host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
|
|
|
|
|
2019-08-03 18:48:56 +00:00
|
|
|
$configMock
|
2019-02-07 19:44:03 +00:00
|
|
|
->shouldReceive('get')
|
2019-02-17 20:41:45 +00:00
|
|
|
->with('system', 'memcached_hosts')
|
2019-09-16 12:47:49 +00:00
|
|
|
->andReturn([0 => $host . ', 11211']);
|
2019-01-30 19:26:17 +00:00
|
|
|
|
2019-08-03 18:48:56 +00:00
|
|
|
$logger = new NullLogger();
|
|
|
|
|
2019-09-16 12:47:49 +00:00
|
|
|
try {
|
|
|
|
$this->cache = new MemcachedCache($host, $configMock, $logger);
|
|
|
|
} catch (\Exception $exception) {
|
|
|
|
$this->markTestSkipped('Memcached is not available');
|
|
|
|
}
|
2018-07-18 19:04:18 +00:00
|
|
|
return $this->cache;
|
2018-07-07 17:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function tearDown()
|
|
|
|
{
|
2018-07-18 19:04:18 +00:00
|
|
|
$this->cache->clear(false);
|
2018-07-07 17:46:16 +00:00
|
|
|
parent::tearDown();
|
|
|
|
}
|
2019-09-24 15:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @small
|
|
|
|
*
|
|
|
|
* @dataProvider dataSimple
|
|
|
|
*/
|
|
|
|
public function testGetAllKeys($value1, $value2, $value3)
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete('Race condition because of too fast getAllKeys() which uses a workaround');
|
|
|
|
}
|
2018-07-07 17:46:16 +00:00
|
|
|
}
|