From f5adbd268b0ad6f9e090ebb44dc32a0d4a1fec3c Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 17 Feb 2019 21:41:45 +0100 Subject: [PATCH] Fixing tests --- tests/Util/AppMockTrait.php | 56 +++++++++++-------- tests/Util/DBStructureMockTrait.php | 2 + tests/src/App/ModeTest.php | 4 +- tests/src/BaseObjectTest.php | 3 +- tests/src/Core/Cache/CacheTest.php | 3 +- .../Core/Cache/MemcacheCacheDriverTest.php | 8 +-- .../Core/Cache/MemcachedCacheDriverTest.php | 4 +- tests/src/Core/Cache/RedisCacheDriverTest.php | 8 +-- tests/src/Core/Config/ConfigurationTest.php | 21 +++---- tests/src/Core/Config/PConfigurationTest.php | 19 ++++--- .../AutomaticInstallationConsoleTest.php | 4 +- tests/src/Core/Console/ConfigConsoleTest.php | 28 +++++----- tests/src/Core/Console/ConsoleTest.php | 7 +-- tests/src/Core/Lock/LockTest.php | 3 +- .../Core/Lock/MemcacheCacheLockDriverTest.php | 8 +-- .../Lock/MemcachedCacheLockDriverTest.php | 4 +- .../Core/Lock/RedisCacheLockDriverTest.php | 8 +-- .../src/Core/Lock/SemaphoreLockDriverTest.php | 4 +- 18 files changed, 101 insertions(+), 93 deletions(-) diff --git a/tests/Util/AppMockTrait.php b/tests/Util/AppMockTrait.php index 66b95b04e8..817570dd58 100644 --- a/tests/Util/AppMockTrait.php +++ b/tests/Util/AppMockTrait.php @@ -6,6 +6,7 @@ use Friendica\App; use Friendica\BaseObject; use Friendica\Core\Config; use Friendica\Render\FriendicaSmartyEngine; +use Friendica\Util\Profiler; use Mockery\MockInterface; use org\bovigo\vfs\vfsStreamDirectory; @@ -22,70 +23,81 @@ trait AppMockTrait /** * @var MockInterface|Config\Configuration The mocked Config Cache */ - protected $configCache; + protected $configMock; + + /** + * @var MockInterface|Profiler The mocked profiler + */ + protected $profilerMock; /** * Mock the App * * @param vfsStreamDirectory $root The root directory - * @param MockInterface|Config\Configuration $config The config cache */ - public function mockApp($root, Config\Configuration $config) + public function mockApp($root) { - $this->configCache = $config; + $this->configMock = \Mockery::mock(Config\Cache\IConfigCache::class); + $configAdapterMock = \Mockery::mock(Config\Adapter\IConfigAdapter::class); + // Disable the adapter + $configAdapterMock->shouldReceive('isConnected')->andReturn(false); + + $config = new Config\Configuration($this->configMock, $configAdapterMock); + // Initialize empty Config + Config::init($config); + // Mocking App and most used functions $this->app = \Mockery::mock(App::class); $this->app ->shouldReceive('getBasePath') ->andReturn($root->url()); - $config + $this->configMock + ->shouldReceive('has') + ->andReturn(true); + $this->configMock ->shouldReceive('get') ->with('database', 'hostname') ->andReturn(getenv('MYSQL_HOST')); - $config + $this->configMock ->shouldReceive('get') ->with('database', 'username') ->andReturn(getenv('MYSQL_USERNAME')); - $config + $this->configMock ->shouldReceive('get') ->with('database', 'password') ->andReturn(getenv('MYSQL_PASSWORD')); - $config + $this->configMock ->shouldReceive('get') ->with('database', 'database') ->andReturn(getenv('MYSQL_DATABASE')); - $config + $this->configMock ->shouldReceive('get') ->with('config', 'hostname') ->andReturn('localhost'); - $config + $this->configMock ->shouldReceive('get') - ->with('system', 'theme', NULL, false) + ->with('system', 'theme') ->andReturn('system_theme'); - $config - ->shouldReceive('getConfig') - ->andReturn($config); + + $this->profilerMock = \Mockery::mock(Profiler::class); + $this->profilerMock->shouldReceive('saveTimestamp'); $this->app ->shouldReceive('getConfigCache') - ->andReturn($config); - + ->andReturn($this->configMock); $this->app ->shouldReceive('getTemplateEngine') ->andReturn(new FriendicaSmartyEngine()); $this->app ->shouldReceive('getCurrentTheme') ->andReturn('Smarty3'); - $this->app - ->shouldReceive('saveTimestamp') - ->andReturn(true); $this->app ->shouldReceive('getBaseUrl') ->andReturn('http://friendica.local'); - - // Initialize empty Config - Config::init($config); + $this->app + ->shouldReceive('getProfiler') + ->andReturn($this->profilerMock); BaseObject::setApp($this->app); } diff --git a/tests/Util/DBStructureMockTrait.php b/tests/Util/DBStructureMockTrait.php index 87c120d3f2..92ec412cb7 100644 --- a/tests/Util/DBStructureMockTrait.php +++ b/tests/Util/DBStructureMockTrait.php @@ -2,6 +2,7 @@ namespace Friendica\Test\Util; +use Friendica\Database\DBStructure; use Mockery\MockInterface; /** @@ -16,6 +17,7 @@ trait DBStructureMockTrait /** * Mocking DBStructure::update() + * @see DBStructure::update(); * * @param array $args The arguments for the update call * @param bool $return True, if the connect was successful, otherwise false diff --git a/tests/src/App/ModeTest.php b/tests/src/App/ModeTest.php index 5a5c4c87e6..9059e8bebf 100644 --- a/tests/src/App/ModeTest.php +++ b/tests/src/App/ModeTest.php @@ -90,7 +90,7 @@ class ModeTest extends MockedTest $this->mockConnected(true, 1); $this->mockFetchFirst('SHOW TABLES LIKE \'config\'', true, 1); - $config = \Mockery::mock('Friendica\Core\Config\Configuration'); + $config = \Mockery::mock(Config\Configuration::class); $config ->shouldReceive('get') ->with('system', 'maintenance', null, false) @@ -118,7 +118,7 @@ class ModeTest extends MockedTest $this->mockConnected(true, 1); $this->mockFetchFirst('SHOW TABLES LIKE \'config\'', true, 1); - $config = \Mockery::mock('Friendica\Core\Config\Configuration'); + $config = \Mockery::mock(Config\Configuration::class); $config ->shouldReceive('get') ->with('system', 'maintenance', null, false) diff --git a/tests/src/BaseObjectTest.php b/tests/src/BaseObjectTest.php index 39741eb9e1..3341503915 100644 --- a/tests/src/BaseObjectTest.php +++ b/tests/src/BaseObjectTest.php @@ -31,8 +31,7 @@ class BaseObjectTest extends TestCase { $baseObject = new BaseObject(); $this->setUpVfsDir(); - $configMock = \Mockery::mock('Friendica\Core\Config\Configuration'); - $this->mockApp($this->root, $configMock); + $this->mockApp($this->root); $this->assertNull($baseObject->setApp($this->app)); $this->assertEquals($this->app, $baseObject->getApp()); diff --git a/tests/src/Core/Cache/CacheTest.php b/tests/src/Core/Cache/CacheTest.php index 961ac9e1b4..ef97f5a172 100644 --- a/tests/src/Core/Cache/CacheTest.php +++ b/tests/src/Core/Cache/CacheTest.php @@ -67,8 +67,7 @@ abstract class CacheTest extends MockedTest protected function setUp() { $this->setUpVfsDir(); - $configMock = \Mockery::mock('Friendica\Core\Config\Configuration'); - $this->mockApp($this->root, $configMock); + $this->mockApp($this->root); $this->app ->shouldReceive('getHostname') ->andReturn('friendica.local'); diff --git a/tests/src/Core/Cache/MemcacheCacheDriverTest.php b/tests/src/Core/Cache/MemcacheCacheDriverTest.php index 5017b6967e..f9df9eaba0 100644 --- a/tests/src/Core/Cache/MemcacheCacheDriverTest.php +++ b/tests/src/Core/Cache/MemcacheCacheDriverTest.php @@ -12,14 +12,14 @@ class MemcacheCacheDriverTest extends MemoryCacheTest { protected function getInstance() { - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('system', 'memcache_host', NULL, false) + ->with('system', 'memcache_host') ->andReturn('localhost'); - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('system', 'memcache_port', NULL, false) + ->with('system', 'memcache_port') ->andReturn(11211); $this->cache = CacheDriverFactory::create('memcache'); diff --git a/tests/src/Core/Cache/MemcachedCacheDriverTest.php b/tests/src/Core/Cache/MemcachedCacheDriverTest.php index 7c68353593..4e16ef947f 100644 --- a/tests/src/Core/Cache/MemcachedCacheDriverTest.php +++ b/tests/src/Core/Cache/MemcachedCacheDriverTest.php @@ -12,9 +12,9 @@ class MemcachedCacheDriverTest extends MemoryCacheTest { protected function getInstance() { - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('system', 'memcached_hosts', NULL, false) + ->with('system', 'memcached_hosts') ->andReturn([0 => 'localhost, 11211']); $this->cache = CacheDriverFactory::create('memcached'); diff --git a/tests/src/Core/Cache/RedisCacheDriverTest.php b/tests/src/Core/Cache/RedisCacheDriverTest.php index d36e6b826e..20fe7eb53f 100644 --- a/tests/src/Core/Cache/RedisCacheDriverTest.php +++ b/tests/src/Core/Cache/RedisCacheDriverTest.php @@ -12,14 +12,14 @@ class RedisCacheDriverTest extends MemoryCacheTest { protected function getInstance() { - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('system', 'redis_host', NULL, false) + ->with('system', 'redis_host') ->andReturn('localhost'); - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('system', 'redis_port', NULL, false) + ->with('system', 'redis_port') ->andReturn(null); $this->cache = CacheDriverFactory::create('redis'); diff --git a/tests/src/Core/Config/ConfigurationTest.php b/tests/src/Core/Config/ConfigurationTest.php index 0437f1e7ad..2e4fcd4f58 100644 --- a/tests/src/Core/Config/ConfigurationTest.php +++ b/tests/src/Core/Config/ConfigurationTest.php @@ -2,6 +2,7 @@ namespace Friendica\Test\Core\Config; +use Friendica\Core\Config\Adapter\IConfigAdapter; use Friendica\Core\Config\Cache\ConfigCache; use Friendica\Core\Config\Cache\IConfigCache; use Friendica\Core\Config\Configuration; @@ -29,7 +30,7 @@ class ConfigurationTest extends MockedTest public function testSetUp() { $configCache = new ConfigCache(); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IConfigAdapter'); + $configAdapter = \Mockery::mock(IConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(false)->once(); $configuration = new Configuration($configCache, $configAdapter); @@ -43,7 +44,7 @@ class ConfigurationTest extends MockedTest public function testCacheLoad() { $configCache = new ConfigCache(); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IConfigAdapter'); + $configAdapter = \Mockery::mock(IConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(true)->times(3); // constructor loading $configAdapter->shouldReceive('load')->andReturn([])->once(); @@ -64,7 +65,7 @@ class ConfigurationTest extends MockedTest public function testCacheLoadDouble() { $configCache = new ConfigCache(); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IConfigAdapter'); + $configAdapter = \Mockery::mock(IConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(true)->times(5); // constructor loading $configAdapter->shouldReceive('load')->andReturn([])->once(); @@ -93,7 +94,7 @@ class ConfigurationTest extends MockedTest public function testSetGetWithoutDB($data) { $configCache = new ConfigCache(); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IConfigAdapter'); + $configAdapter = \Mockery::mock(IConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(false)->times(3); $configuration = new Configuration($configCache, $configAdapter); @@ -111,7 +112,7 @@ class ConfigurationTest extends MockedTest public function testSetGetWithDB($data) { $configCache = new ConfigCache(); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IConfigAdapter'); + $configAdapter = \Mockery::mock(IConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(true)->times(3); // constructor loading $configAdapter->shouldReceive('load')->andReturn([])->once(); @@ -132,7 +133,7 @@ class ConfigurationTest extends MockedTest public function testGetWrongWithoutDB() { $configCache = new ConfigCache(); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IConfigAdapter'); + $configAdapter = \Mockery::mock(IConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(false)->times(4); $configuration = new Configuration($configCache, $configAdapter); @@ -157,7 +158,7 @@ class ConfigurationTest extends MockedTest public function testGetWithRefresh($data) { $configCache = new ConfigCache(['test' => ['it' => 'now']]); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IConfigAdapter'); + $configAdapter = \Mockery::mock(IConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(true)->times(4); // constructor loading $configAdapter->shouldReceive('load')->andReturn([])->once(); @@ -188,7 +189,7 @@ class ConfigurationTest extends MockedTest public function testGetWithoutLoaded($data) { $configCache = new ConfigCache(['test' => ['it' => 'now']]); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IConfigAdapter'); + $configAdapter = \Mockery::mock(IConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(true)->times(4); // constructor loading $configAdapter->shouldReceive('load')->andReturn([])->once(); @@ -223,7 +224,7 @@ class ConfigurationTest extends MockedTest public function testDeleteWithoutDB($data) { $configCache = new ConfigCache(['test' => ['it' => $data]]); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IConfigAdapter'); + $configAdapter = \Mockery::mock(IConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(false)->times(4); $configuration = new Configuration($configCache, $configAdapter); @@ -244,7 +245,7 @@ class ConfigurationTest extends MockedTest public function testDeleteWithDB() { $configCache = new ConfigCache(['test' => ['it' => 'now', 'quarter' => 'true']]); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IConfigAdapter'); + $configAdapter = \Mockery::mock(IConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(true)->times(6); // constructor loading $configAdapter->shouldReceive('load')->andReturn([])->once(); diff --git a/tests/src/Core/Config/PConfigurationTest.php b/tests/src/Core/Config/PConfigurationTest.php index 8ecc9bdf37..0259944147 100644 --- a/tests/src/Core/Config/PConfigurationTest.php +++ b/tests/src/Core/Config/PConfigurationTest.php @@ -2,6 +2,7 @@ namespace Friendica\Test\Core\Config; +use Friendica\Core\Config\Adapter\IPConfigAdapter; use Friendica\Core\Config\Cache\ConfigCache; use Friendica\Core\Config\PConfiguration; use Friendica\Test\MockedTest; @@ -29,7 +30,7 @@ class PConfigurationTest extends MockedTest { $uid = 234; $configCache = new ConfigCache(); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter'); + $configAdapter = \Mockery::mock(IPConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(true)->twice(); // expected loading $configAdapter->shouldReceive('load') @@ -51,7 +52,7 @@ class PConfigurationTest extends MockedTest { $uid = 234; $configCache = new ConfigCache(); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter'); + $configAdapter = \Mockery::mock(IPConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(true)->times(4); // expected loading $configAdapter->shouldReceive('load')->with($uid, 'testing')->andReturn(['testing' => ['test' => 'it']])->once(); @@ -77,7 +78,7 @@ class PConfigurationTest extends MockedTest { $uid = 234; $configCache = new ConfigCache(); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter'); + $configAdapter = \Mockery::mock(IPConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(false)->times(2); $configuration = new PConfiguration($configCache, $configAdapter); @@ -95,7 +96,7 @@ class PConfigurationTest extends MockedTest { $uid = 234; $configCache = new ConfigCache(); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter'); + $configAdapter = \Mockery::mock(IPConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(true)->times(2); $configAdapter->shouldReceive('isLoaded')->with($uid, 'test', 'it')->andReturn(true)->once(); $configAdapter->shouldReceive('set')->with($uid, 'test', 'it', $data)->andReturn(true)->once(); @@ -114,7 +115,7 @@ class PConfigurationTest extends MockedTest { $uid = 234; $configCache = new ConfigCache(); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter'); + $configAdapter = \Mockery::mock(IPConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(false)->times(3); $configuration = new PConfiguration($configCache, $configAdapter); @@ -137,7 +138,7 @@ class PConfigurationTest extends MockedTest { $uid = 234; $configCache = new ConfigCache(); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter'); + $configAdapter = \Mockery::mock(IPConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(true)->times(4); $configAdapter->shouldReceive('isLoaded')->with($uid, 'test', 'it')->andReturn(false)->once(); $configAdapter->shouldReceive('get')->with($uid, 'test', 'it')->andReturn('now')->once(); @@ -168,7 +169,7 @@ class PConfigurationTest extends MockedTest { $uid = 234; $configCache = new ConfigCache(); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter'); + $configAdapter = \Mockery::mock(IPConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(true)->times(3); $configAdapter->shouldReceive('isLoaded')->with($uid, 'test', 'it')->andReturn(false)->once(); @@ -199,7 +200,7 @@ class PConfigurationTest extends MockedTest { $uid = 234; $configCache = new ConfigCache(); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter'); + $configAdapter = \Mockery::mock(IPConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(false)->times(4); $configuration = new PConfiguration($configCache, $configAdapter); @@ -218,7 +219,7 @@ class PConfigurationTest extends MockedTest { $uid = 234; $configCache = new ConfigCache(); - $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter'); + $configAdapter = \Mockery::mock(IPConfigAdapter::class); $configAdapter->shouldReceive('isConnected')->andReturn(true)->times(6); $configAdapter->shouldReceive('set')->with($uid, 'test', 'it', 'now')->andReturn(false)->once(); $configAdapter->shouldReceive('isLoaded')->with($uid, 'test', 'it')->andReturn(true)->once(); diff --git a/tests/src/Core/Console/AutomaticInstallationConsoleTest.php b/tests/src/Core/Console/AutomaticInstallationConsoleTest.php index ce3dac02cc..73b6835fb5 100644 --- a/tests/src/Core/Console/AutomaticInstallationConsoleTest.php +++ b/tests/src/Core/Console/AutomaticInstallationConsoleTest.php @@ -52,9 +52,9 @@ class AutomaticInstallationConsoleTest extends ConsoleTest $this->db_user = getenv('MYSQL_USERNAME') . getenv('MYSQL_USER'); $this->db_pass = getenv('MYSQL_PASSWORD'); - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('config', 'php_path', NULL, false) + ->with('config', 'php_path') ->andReturn(false); $this->mockL10nT(); diff --git a/tests/src/Core/Console/ConfigConsoleTest.php b/tests/src/Core/Console/ConfigConsoleTest.php index 5b7d14906c..579b28e026 100644 --- a/tests/src/Core/Console/ConfigConsoleTest.php +++ b/tests/src/Core/Console/ConfigConsoleTest.php @@ -32,14 +32,14 @@ class ConfigConsoleTest extends ConsoleTest } function testSetGetKeyValue() { - $this->configCache + $this->configMock ->shouldReceive('set') ->with('config', 'test', 'now') ->andReturn(true) ->once(); - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('config', 'test', NULL, false) + ->with('config', 'test') ->andReturn('now') ->twice(); @@ -50,9 +50,9 @@ class ConfigConsoleTest extends ConsoleTest $txt = $this->dumpExecute($console); $this->assertEquals("config.test <= now\n", $txt); - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('config', 'test', null, false) + ->with('config', 'test') ->andReturn('now') ->once(); @@ -62,9 +62,9 @@ class ConfigConsoleTest extends ConsoleTest $txt = $this->dumpExecute($console); $this->assertEquals("config.test => now\n", $txt); - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('config', 'test', null, false) + ->with('config', 'test') ->andReturn(null) ->once(); @@ -77,9 +77,9 @@ class ConfigConsoleTest extends ConsoleTest function testSetArrayValue() { $testArray = [1, 2, 3]; - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('config', 'test', null, false) + ->with('config', 'test') ->andReturn($testArray) ->once(); @@ -105,9 +105,9 @@ class ConfigConsoleTest extends ConsoleTest } function testVerbose() { - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('test', 'it', null, false) + ->with('test', 'it') ->andReturn('now') ->once(); $console = new Config($this->consoleArgv); @@ -133,14 +133,14 @@ CONF; } function testUnableToSet() { - $this->configCache + $this->configMock ->shouldReceive('set') ->with('test', 'it', 'now') ->andReturn(false) ->once(); - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('test', 'it', NULL, false) + ->with('test', 'it') ->andReturn(NULL) ->once(); $console = new Config(); diff --git a/tests/src/Core/Console/ConsoleTest.php b/tests/src/Core/Console/ConsoleTest.php index f733175d34..4f7acc9c42 100644 --- a/tests/src/Core/Console/ConsoleTest.php +++ b/tests/src/Core/Console/ConsoleTest.php @@ -3,12 +3,10 @@ namespace Friendica\Test\src\Core\Console; use Asika\SimpleConsole\Console; -use Friendica\Core\Config\Configuration; use Friendica\Test\MockedTest; use Friendica\Test\Util\AppMockTrait; use Friendica\Test\Util\Intercept; use Friendica\Test\Util\VFSTrait; -use Friendica\Util\Profiler; abstract class ConsoleTest extends MockedTest { @@ -31,10 +29,7 @@ abstract class ConsoleTest extends MockedTest Intercept::setUp(); $this->setUpVfsDir(); - $configMock = \Mockery::mock(Configuration::class); - $this->mockApp($this->root, $configMock); - $profileMock = \Mockery::mock(Profiler::class); - $this->app->shouldReceive('getProfiler')->andReturn($profileMock); + $this->mockApp($this->root); } /** diff --git a/tests/src/Core/Lock/LockTest.php b/tests/src/Core/Lock/LockTest.php index c1378aa164..6dc170e514 100644 --- a/tests/src/Core/Lock/LockTest.php +++ b/tests/src/Core/Lock/LockTest.php @@ -27,8 +27,7 @@ abstract class LockTest extends MockedTest { // Reusable App object $this->setUpVfsDir(); - $configMock = \Mockery::mock('Friendica\Core\Config\Configuration'); - $this->mockApp($this->root, $configMock); + $this->mockApp($this->root); $this->app ->shouldReceive('getHostname') ->andReturn('friendica.local'); diff --git a/tests/src/Core/Lock/MemcacheCacheLockDriverTest.php b/tests/src/Core/Lock/MemcacheCacheLockDriverTest.php index 0e118c5dd7..ad20f5bfdb 100644 --- a/tests/src/Core/Lock/MemcacheCacheLockDriverTest.php +++ b/tests/src/Core/Lock/MemcacheCacheLockDriverTest.php @@ -13,14 +13,14 @@ class MemcacheCacheLockDriverTest extends LockTest { protected function getInstance() { - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('system', 'memcache_host', NULL, false) + ->with('system', 'memcache_host') ->andReturn('localhost'); - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('system', 'memcache_port', NULL, false) + ->with('system', 'memcache_port') ->andReturn(11211); return new CacheLockDriver(CacheDriverFactory::create('memcache')); diff --git a/tests/src/Core/Lock/MemcachedCacheLockDriverTest.php b/tests/src/Core/Lock/MemcachedCacheLockDriverTest.php index fe490a38cf..a5bdeaedb8 100644 --- a/tests/src/Core/Lock/MemcachedCacheLockDriverTest.php +++ b/tests/src/Core/Lock/MemcachedCacheLockDriverTest.php @@ -13,9 +13,9 @@ class MemcachedCacheLockDriverTest extends LockTest { protected function getInstance() { - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('system', 'memcached_hosts', NULL, false) + ->with('system', 'memcached_hosts') ->andReturn([0 => 'localhost, 11211']); return new CacheLockDriver(CacheDriverFactory::create('memcached')); diff --git a/tests/src/Core/Lock/RedisCacheLockDriverTest.php b/tests/src/Core/Lock/RedisCacheLockDriverTest.php index f5d0a648fb..5f047bc664 100644 --- a/tests/src/Core/Lock/RedisCacheLockDriverTest.php +++ b/tests/src/Core/Lock/RedisCacheLockDriverTest.php @@ -13,14 +13,14 @@ class RedisCacheLockDriverTest extends LockTest { protected function getInstance() { - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('system', 'redis_host', NULL, false) + ->with('system', 'redis_host') ->andReturn('localhost'); - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('system', 'redis_port', NULL, false) + ->with('system', 'redis_port') ->andReturn(null); return new CacheLockDriver(CacheDriverFactory::create('redis')); diff --git a/tests/src/Core/Lock/SemaphoreLockDriverTest.php b/tests/src/Core/Lock/SemaphoreLockDriverTest.php index bf422f2f88..a37fbffbed 100644 --- a/tests/src/Core/Lock/SemaphoreLockDriverTest.php +++ b/tests/src/Core/Lock/SemaphoreLockDriverTest.php @@ -12,9 +12,9 @@ class SemaphoreLockDriverTest extends LockTest $this->app->shouldReceive('getHostname')->andReturn('friendica.local'); - $this->configCache + $this->configMock ->shouldReceive('get') - ->with('system', 'temppath', NULL, false) + ->with('system', 'temppath') ->andReturn('/tmp/'); } -- 2.39.5