]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Core/Config/PConfigurationTest.php
Merge pull request #7376 from annando/contact-update
[friendica.git] / tests / src / Core / Config / PConfigurationTest.php
index 8ecc9bdf379f092ff38ba0a3f87103ae71cf3bf9..f2f1857a69b9667daed508d061f05b26bcd92a12 100644 (file)
@@ -1,8 +1,9 @@
 <?php
 
-namespace Friendica\Test\Core\Config;
+namespace Friendica\Test\src\Core\Config;
 
-use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\Core\Config\Adapter\IPConfigAdapter;
+use Friendica\Core\Config\Cache\PConfigCache;
 use Friendica\Core\Config\PConfiguration;
 use Friendica\Test\MockedTest;
 
@@ -28,8 +29,8 @@ class PConfigurationTest extends MockedTest
        public function testCacheLoad()
        {
                $uid = 234;
-               $configCache = new ConfigCache();
-               $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter');
+               $configCache = new PConfigCache();
+               $configAdapter = \Mockery::mock(IPConfigAdapter::class);
                $configAdapter->shouldReceive('isConnected')->andReturn(true)->twice();
                // expected loading
                $configAdapter->shouldReceive('load')
@@ -50,8 +51,8 @@ class PConfigurationTest extends MockedTest
        public function testCacheLoadDouble()
        {
                $uid = 234;
-               $configCache = new ConfigCache();
-               $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter');
+               $configCache = new PConfigCache();
+               $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();
@@ -76,8 +77,8 @@ class PConfigurationTest extends MockedTest
        public function testSetGetWithoutDB($data)
        {
                $uid = 234;
-               $configCache = new ConfigCache();
-               $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter');
+               $configCache = new PConfigCache();
+               $configAdapter = \Mockery::mock(IPConfigAdapter::class);
                $configAdapter->shouldReceive('isConnected')->andReturn(false)->times(2);
 
                $configuration = new PConfiguration($configCache, $configAdapter);
@@ -94,8 +95,8 @@ class PConfigurationTest extends MockedTest
        public function testSetGetWithDB($data)
        {
                $uid = 234;
-               $configCache = new ConfigCache();
-               $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter');
+               $configCache = new PConfigCache();
+               $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();
@@ -113,8 +114,8 @@ class PConfigurationTest extends MockedTest
        public function testGetWrongWithoutDB()
        {
                $uid = 234;
-               $configCache = new ConfigCache();
-               $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter');
+               $configCache = new PConfigCache();
+               $configAdapter = \Mockery::mock(IPConfigAdapter::class);
                $configAdapter->shouldReceive('isConnected')->andReturn(false)->times(3);
 
                $configuration = new PConfiguration($configCache, $configAdapter);
@@ -136,15 +137,15 @@ class PConfigurationTest extends MockedTest
        public function testGetWithRefresh($data)
        {
                $uid = 234;
-               $configCache = new ConfigCache();
-               $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter');
+               $configCache = new PConfigCache();
+               $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();
                $configAdapter->shouldReceive('isLoaded')->with($uid, 'test', 'it')->andReturn(true)->twice();
                $configAdapter->shouldReceive('get')->with($uid, 'test', 'it')->andReturn($data)->once();
                $configAdapter->shouldReceive('isLoaded')->with($uid, 'test', 'not')->andReturn(false)->once();
-               $configAdapter->shouldReceive('get')->with($uid, 'test', 'not')->andReturn('!<unset>!')->once();
+               $configAdapter->shouldReceive('get')->with($uid, 'test', 'not')->andReturn(null)->once();
 
                $configuration = new PConfiguration($configCache, $configAdapter);
 
@@ -167,12 +168,12 @@ class PConfigurationTest extends MockedTest
        public function testGetWithoutLoaded($data)
        {
                $uid = 234;
-               $configCache = new ConfigCache();
-               $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter');
+               $configCache = new PConfigCache();
+               $configAdapter = \Mockery::mock(IPConfigAdapter::class);
                $configAdapter->shouldReceive('isConnected')->andReturn(true)->times(3);
 
                $configAdapter->shouldReceive('isLoaded')->with($uid, 'test', 'it')->andReturn(false)->once();
-               $configAdapter->shouldReceive('get')->with($uid, 'test', 'it')->andReturn('!<unset>!')->once();
+               $configAdapter->shouldReceive('get')->with($uid, 'test', 'it')->andReturn(null)->once();
 
                $configAdapter->shouldReceive('isLoaded')->with($uid, 'test', 'it')->andReturn(false)->once();
                $configAdapter->shouldReceive('get')->with($uid, 'test', 'it')->andReturn($data)->once();
@@ -198,8 +199,8 @@ class PConfigurationTest extends MockedTest
        public function testDeleteWithoutDB($data)
        {
                $uid = 234;
-               $configCache = new ConfigCache();
-               $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter');
+               $configCache = new PConfigCache();
+               $configAdapter = \Mockery::mock(IPConfigAdapter::class);
                $configAdapter->shouldReceive('isConnected')->andReturn(false)->times(4);
 
                $configuration = new PConfiguration($configCache, $configAdapter);
@@ -217,8 +218,8 @@ class PConfigurationTest extends MockedTest
        public function testDeleteWithDB()
        {
                $uid = 234;
-               $configCache = new ConfigCache();
-               $configAdapter = \Mockery::mock('Friendica\Core\Config\Adapter\IPConfigAdapter');
+               $configCache = new PConfigCache();
+               $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();