2018-07-07 17:46:16 +00:00
|
|
|
<?php
|
2020-02-09 14:45:36 +00:00
|
|
|
/**
|
|
|
|
* @copyright Copyright (C) 2020, Friendica
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2018-07-07 17:46:16 +00:00
|
|
|
|
|
|
|
namespace Friendica\Test\src\Core\Cache;
|
|
|
|
|
2020-10-18 18:31:57 +00:00
|
|
|
use Exception;
|
2019-08-04 08:26:53 +00:00
|
|
|
use Friendica\Core\Cache\MemcachedCache;
|
2020-01-19 20:29:36 +00:00
|
|
|
use Friendica\Core\Config\IConfig;
|
2020-10-18 18:31:57 +00:00
|
|
|
use Mockery;
|
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()
|
|
|
|
{
|
2020-10-18 18:31:57 +00:00
|
|
|
$configMock = Mockery::mock(IConfig::class);
|
2019-08-03 18:48:56 +00:00
|
|
|
|
2019-09-16 12:47:49 +00:00
|
|
|
$host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
|
2020-08-19 12:09:16 +00:00
|
|
|
$port = $_SERVER['MEMCACHED_PORT'] ?? '11211';
|
2019-09-16 12:47:49 +00:00
|
|
|
|
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')
|
2020-08-19 12:09:16 +00:00
|
|
|
->andReturn([0 => $host . ', ' . $port]);
|
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);
|
2020-10-18 18:31:57 +00:00
|
|
|
} catch (Exception $exception) {
|
|
|
|
static::markTestSkipped('Memcached is not available');
|
2019-09-16 12:47:49 +00:00
|
|
|
}
|
2018-07-18 19:04:18 +00:00
|
|
|
return $this->cache;
|
2018-07-07 17:46:16 +00:00
|
|
|
}
|
|
|
|
|
2020-10-18 18:31:57 +00:00
|
|
|
protected function tearDown()
|
2018-07-07 17:46:16 +00:00
|
|
|
{
|
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)
|
|
|
|
{
|
2020-10-18 18:31:57 +00:00
|
|
|
static::markTestIncomplete('Race condition because of too fast getAllKeys() which uses a workaround');
|
2019-09-24 15:52:38 +00:00
|
|
|
}
|
2018-07-07 17:46:16 +00:00
|
|
|
}
|