mirror of
https://github.com/friendica/friendica
synced 2025-05-14 23:44:10 +02:00
Fixing tests
This commit is contained in:
parent
5e5c39b0e1
commit
f5adbd268b
18 changed files with 101 additions and 93 deletions
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue