]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Core/Config/ConfigurationTest.php
- Adding additional legacy .htconfig information
[friendica.git] / tests / src / Core / Config / ConfigurationTest.php
index 0437f1e7adcfc382a3207088e6625f36c1f26e22..b07f9e6302bd0fa1f5ff8c19a5fb3f86a0de8bcd 100644 (file)
@@ -1,7 +1,8 @@
 <?php
 
-namespace Friendica\Test\Core\Config;
+namespace Friendica\Test\src\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);
@@ -141,7 +142,7 @@ class ConfigurationTest extends MockedTest
                $this->assertNull($configuration->get('test', 'it'));
 
                /// beware that the cache returns '!<unset>!' and not null for a non existing value
-               $this->assertEquals('!<unset>!', $configuration->getCache()->get('test', 'it'));
+               $this->assertNull($configuration->getCache()->get('test', 'it'));
 
                // with default value
                $this->assertEquals('default', $configuration->get('test', 'it', 'default'));
@@ -157,14 +158,14 @@ 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();
                $configAdapter->shouldReceive('isLoaded')->with('test', 'it')->andReturn(true)->twice();
                $configAdapter->shouldReceive('get')->with('test', 'it')->andReturn($data)->once();
                $configAdapter->shouldReceive('isLoaded')->with('test', 'not')->andReturn(false)->once();
-               $configAdapter->shouldReceive('get')->with('test', 'not')->andReturn('!<unset>!')->once();
+               $configAdapter->shouldReceive('get')->with('test', 'not')->andReturn(null)->once();
 
                $configuration = new Configuration($configCache, $configAdapter);
 
@@ -178,7 +179,7 @@ class ConfigurationTest extends MockedTest
 
                // without refresh and wrong value and default
                $this->assertEquals('default', $configuration->get('test', 'not', 'default'));
-               $this->assertEquals('!<unset>!', $configuration->getCache()->get('test', 'not'));
+               $this->assertNull($configuration->getCache()->get('test', 'not'));
        }
 
        /**
@@ -188,13 +189,13 @@ 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();
 
                $configAdapter->shouldReceive('isLoaded')->with('test', 'it')->andReturn(false)->once();
-               $configAdapter->shouldReceive('get')->with('test', 'it')->andReturn('!<unset>!')->once();
+               $configAdapter->shouldReceive('get')->with('test', 'it')->andReturn(null)->once();
 
                $configAdapter->shouldReceive('isLoaded')->with('test', 'it')->andReturn(false)->once();
                $configAdapter->shouldReceive('get')->with('test', 'it')->andReturn($data)->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);
@@ -233,7 +234,7 @@ class ConfigurationTest extends MockedTest
 
                $this->assertTrue($configuration->delete('test', 'it'));
                $this->assertNull($configuration->get('test', 'it'));
-               $this->assertEquals('!<unset>!', $configuration->getCache()->get('test', 'it'));
+               $this->assertNull($configuration->getCache()->get('test', 'it'));
 
                $this->assertEmpty($configuration->getCache()->getAll());
        }
@@ -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();