]> git.mxchange.org Git - friendica.git/commitdiff
fixing tests and preload config
authorPhilipp Holzer <admin@philipp.info>
Fri, 22 Feb 2019 23:09:57 +0000 (00:09 +0100)
committerPhilipp Holzer <admin@philipp.info>
Fri, 22 Feb 2019 23:09:57 +0000 (00:09 +0100)
src/Core/Config/Adapter/PreloadConfigAdapter.php
src/Core/Config/Adapter/PreloadPConfigAdapter.php
tests/src/Core/Config/Cache/ConfigCacheLoaderTest.php
tests/src/Core/Config/Cache/ConfigCacheTest.php
tests/src/Core/Config/ConfigurationTest.php
tests/src/Core/Config/PConfigurationTest.php

index 7ebd1efcf8917fecd4642fa89461966b182faaed..d9f7b132d33b3224f83f9534dd0962ccfbbc5e73 100644 (file)
@@ -33,7 +33,7 @@ class PreloadConfigAdapter extends AbstractDbaConfigAdapter implements IConfigAd
                $configs = DBA::select('config', ['cat', 'v', 'k']);
                while ($config = DBA::fetch($configs)) {
                        $value = $config['v'];
-                       if (isset($value) && $value !== '') {
+                       if (isset($value)) {
                                $return[$config['cat']][$config['k']] = $value;
                        }
                }
@@ -58,7 +58,7 @@ class PreloadConfigAdapter extends AbstractDbaConfigAdapter implements IConfigAd
                        // manage array value
                        $value = (preg_match("|^a:[0-9]+:{.*}$|s", $config['v']) ? unserialize($config['v']) : $config['v']);
 
-                       if (isset($value) && $value !== '') {
+                       if (isset($value)) {
                                return $value;
                        }
                }
index d2ba971ff6a9cb82cd60ec284d028a0011a0a34f..1af526b7c19c40644cad8db10b9dfd662bfa1f04 100644 (file)
@@ -50,7 +50,7 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
                $pconfigs = DBA::select('pconfig', ['cat', 'v', 'k'], ['uid' => $uid]);
                while ($pconfig = DBA::fetch($pconfigs)) {
                        $value = $pconfig['v'];
-                       if (isset($value) && $value !== '') {
+                       if (isset($value)) {
                                $return[$pconfig['cat']][$pconfig['k']] = $value;
                        }
                }
@@ -79,7 +79,7 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
                        // manage array value
                        $value = (preg_match("|^a:[0-9]+:{.*}$|s", $config['v']) ? unserialize($config['v']) : $config['v']);
 
-                       if (isset($value) && $value !== '') {
+                       if (isset($value)) {
                                return $value;
                        }
                }
index f91f267c71b9b52f5f1058bd0aec0312c8917c75..100c4ab65da5b19a16dc04ae15ddb2c96844ba37 100644 (file)
@@ -19,19 +19,6 @@ class ConfigCacheLoaderTest extends MockedTest
                $this->setUpVfsDir();
        }
 
-       /**
-        * Test the loadConfigFiles() method with default values
-        */
-       public function testLoadConfigFiles()
-       {
-               $configCacheLoader = new ConfigCacheLoader($this->root->url());
-               $configCache = new ConfigCache();
-
-               $configCacheLoader->loadConfigFiles($configCache);
-
-               $this->assertEquals($this->root->url(), $configCache->get('system', 'basepath'));
-       }
-
        /**
         * Test the loadConfigFiles() method with a wrong local.config.php
         * @expectedException \Exception
index ac9fae540b8c45ab89eb0c977d28408b21955f6b..582007ed86c03c7e3de502d5682d1c744bcae16a 100644 (file)
@@ -138,22 +138,7 @@ class ConfigCacheTest extends MockedTest
        {
                $configCache = new ConfigCache();
 
-               $this->assertEquals('!<unset>!', $configCache->get('something', 'value'));
-       }
-
-       /**
-        * Test the has() method
-        */
-       public function testHas()
-       {
-               $configCache = new ConfigCache();
-
-               $this->assertFalse($configCache->has('system', 'test'));
-               $this->assertFalse($configCache->has('system'));
-
-               $configCache->set('system', 'test', 'it');
-               $this->assertTrue($configCache->has('system', 'test'));
-               $this->assertTrue($configCache->has('system'));
+               $this->assertNull($configCache->get('something', 'value'));
        }
 
        /**
@@ -171,8 +156,6 @@ class ConfigCacheTest extends MockedTest
                        ],
                ]);
 
-               $this->assertTrue($configCache->has('system'));
-
                $this->assertEquals([
                        'key1' => 'value1',
                        'key2' => 'value2',
@@ -233,8 +216,6 @@ class ConfigCacheTest extends MockedTest
                        ],
                ]);
 
-               $this->assertTrue($configCache->hasP($uid,'system'));
-
                $this->assertEquals([
                        'key1' => 'value1',
                        'key2' => 'value2',
@@ -264,20 +245,4 @@ class ConfigCacheTest extends MockedTest
 
                $this->assertEmpty($configCache->getAll());
        }
-
-       /**
-        * Test the hasP() method
-        */
-       public function testHasP()
-       {
-               $configCache = new ConfigCache();
-               $uid = 345;
-
-               $this->assertFalse($configCache->hasP($uid, 'system', 'test'));
-               $this->assertFalse($configCache->hasP($uid, 'system'));
-
-               $configCache->setP($uid, 'system', 'test', 'it');
-               $this->assertTrue($configCache->hasP($uid, 'system', 'test'));
-               $this->assertTrue($configCache->hasP($uid, 'system'));
-       }
 }
index 2e4fcd4f58db9d90a8bcb0671eb24cb9a1469e9d..d06b2beb3dda2d3ee3c15aebe4f2189c92a88616 100644 (file)
@@ -142,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'));
@@ -165,7 +165,7 @@ class ConfigurationTest extends MockedTest
                $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);
 
@@ -179,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'));
        }
 
        /**
@@ -195,7 +195,7 @@ class ConfigurationTest extends MockedTest
                $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();
@@ -234,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());
        }
index 0259944147a1c7670b15ab18cc3468fc1041eaca..68443d05b4e1d5f12ef93c44a948e001c3677253 100644 (file)
@@ -145,7 +145,7 @@ class PConfigurationTest extends MockedTest
                $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);
 
@@ -173,7 +173,7 @@ class PConfigurationTest extends MockedTest
                $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();