mirror of
https://github.com/friendica/friendica
synced 2025-05-04 09:04:11 +02:00
Refactor ConfigMockTrait to mocked ConfigCache
This commit is contained in:
parent
38ac615ba0
commit
cb791024e4
27 changed files with 244 additions and 193 deletions
|
@ -6,10 +6,6 @@ namespace Friendica\Test\src\Core\Lock;
|
|||
use Friendica\Core\Cache\ArrayCache;
|
||||
use Friendica\Core\Lock\CacheLockDriver;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
class ArrayCacheLockDriverTest extends LockTest
|
||||
{
|
||||
protected function getInstance()
|
||||
|
|
|
@ -25,10 +25,6 @@ abstract class LockTest extends MockedTest
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->instance = $this->getInstance();
|
||||
$this->instance->releaseAll();
|
||||
|
||||
// Reusable App object
|
||||
$this->setUpVfsDir();
|
||||
$configMock = \Mockery::mock('Friendica\Core\Config\ConfigCache');
|
||||
|
@ -37,12 +33,9 @@ abstract class LockTest extends MockedTest
|
|||
->shouldReceive('getHostname')
|
||||
->andReturn('friendica.local');
|
||||
|
||||
// Default config
|
||||
$this->mockConfigGet('config', 'hostname', 'localhost');
|
||||
$this->mockConfigGet('system', 'throttle_limit_day', 100);
|
||||
$this->mockConfigGet('system', 'throttle_limit_week', 100);
|
||||
$this->mockConfigGet('system', 'throttle_limit_month', 100);
|
||||
$this->mockConfigGet('system', 'theme', 'system_theme');
|
||||
parent::setUp();
|
||||
$this->instance = $this->getInstance();
|
||||
$this->instance->releaseAll();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
|
|
|
@ -8,15 +8,20 @@ use Friendica\Core\Lock\CacheLockDriver;
|
|||
|
||||
/**
|
||||
* @requires extension Memcache
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
class MemcacheCacheLockDriverTest extends LockTest
|
||||
{
|
||||
protected function getInstance()
|
||||
{
|
||||
$this->mockConfigGet('system', 'memcache_host', 'localhost', 1);
|
||||
$this->mockConfigGet('system', 'memcache_port', 11211, 1);
|
||||
$this->configCache
|
||||
->shouldReceive('get')
|
||||
->with('system', 'memcache_host', NULL)
|
||||
->andReturn('localhost');
|
||||
|
||||
$this->configCache
|
||||
->shouldReceive('get')
|
||||
->with('system', 'memcache_port', NULL)
|
||||
->andReturn(11211);
|
||||
|
||||
return new CacheLockDriver(CacheDriverFactory::create('memcache'));
|
||||
}
|
||||
|
|
|
@ -8,14 +8,15 @@ use Friendica\Core\Lock\CacheLockDriver;
|
|||
|
||||
/**
|
||||
* @requires extension memcached
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
class MemcachedCacheLockDriverTest extends LockTest
|
||||
{
|
||||
protected function getInstance()
|
||||
{
|
||||
$this->mockConfigGet('system', 'memcached_hosts', [0 => 'localhost, 11211']);
|
||||
$this->configCache
|
||||
->shouldReceive('get')
|
||||
->with('system', 'memcached_hosts', NULL)
|
||||
->andReturn([0 => 'localhost, 11211']);
|
||||
|
||||
return new CacheLockDriver(CacheDriverFactory::create('memcached'));
|
||||
}
|
||||
|
|
|
@ -8,15 +8,20 @@ use Friendica\Core\Lock\CacheLockDriver;
|
|||
|
||||
/**
|
||||
* @requires extension redis
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
class RedisCacheLockDriverTest extends LockTest
|
||||
{
|
||||
protected function getInstance()
|
||||
{
|
||||
$this->mockConfigGet('system', 'redis_host', 'localhost', 1);
|
||||
$this->mockConfigGet('system', 'redis_port', null, 1);
|
||||
$this->configCache
|
||||
->shouldReceive('get')
|
||||
->with('system', 'redis_host', NULL)
|
||||
->andReturn('localhost');
|
||||
|
||||
$this->configCache
|
||||
->shouldReceive('get')
|
||||
->with('system', 'redis_port', NULL)
|
||||
->andReturn(null);
|
||||
|
||||
return new CacheLockDriver(CacheDriverFactory::create('redis'));
|
||||
}
|
||||
|
|
|
@ -4,10 +4,6 @@ namespace Friendica\Test\src\Core\Lock;
|
|||
|
||||
use Friendica\Core\Lock\SemaphoreLockDriver;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
class SemaphoreLockDriverTest extends LockTest
|
||||
{
|
||||
public function setUp()
|
||||
|
@ -15,7 +11,11 @@ class SemaphoreLockDriverTest extends LockTest
|
|||
parent::setUp();
|
||||
|
||||
$this->app->shouldReceive('getHostname')->andReturn('friendica.local');
|
||||
$this->mockConfigGet('system', 'temppath', '/tmp/');
|
||||
|
||||
$this->configCache
|
||||
->shouldReceive('get')
|
||||
->with('system', 'temppath', NULL)
|
||||
->andReturn('/tmp/');
|
||||
}
|
||||
|
||||
protected function getInstance()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue