diff --git a/src/Core/Config/Adapter/PreloadConfigAdapter.php b/src/Core/Config/Adapter/PreloadConfigAdapter.php index 7ebd1efcf..d9f7b132d 100644 --- a/src/Core/Config/Adapter/PreloadConfigAdapter.php +++ b/src/Core/Config/Adapter/PreloadConfigAdapter.php @@ -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; } } diff --git a/src/Core/Config/Adapter/PreloadPConfigAdapter.php b/src/Core/Config/Adapter/PreloadPConfigAdapter.php index d2ba971ff..1af526b7c 100644 --- a/src/Core/Config/Adapter/PreloadPConfigAdapter.php +++ b/src/Core/Config/Adapter/PreloadPConfigAdapter.php @@ -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; } } diff --git a/tests/src/Core/Config/Cache/ConfigCacheLoaderTest.php b/tests/src/Core/Config/Cache/ConfigCacheLoaderTest.php index f91f267c7..100c4ab65 100644 --- a/tests/src/Core/Config/Cache/ConfigCacheLoaderTest.php +++ b/tests/src/Core/Config/Cache/ConfigCacheLoaderTest.php @@ -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 diff --git a/tests/src/Core/Config/Cache/ConfigCacheTest.php b/tests/src/Core/Config/Cache/ConfigCacheTest.php index ac9fae540..582007ed8 100644 --- a/tests/src/Core/Config/Cache/ConfigCacheTest.php +++ b/tests/src/Core/Config/Cache/ConfigCacheTest.php @@ -138,22 +138,7 @@ class ConfigCacheTest extends MockedTest { $configCache = new ConfigCache(); - $this->assertEquals('!!', $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')); - } } diff --git a/tests/src/Core/Config/ConfigurationTest.php b/tests/src/Core/Config/ConfigurationTest.php index 2e4fcd4f5..d06b2beb3 100644 --- a/tests/src/Core/Config/ConfigurationTest.php +++ b/tests/src/Core/Config/ConfigurationTest.php @@ -142,7 +142,7 @@ class ConfigurationTest extends MockedTest $this->assertNull($configuration->get('test', 'it')); /// beware that the cache returns '!!' and not null for a non existing value - $this->assertEquals('!!', $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('!!')->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('!!', $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('!!')->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('!!', $configuration->getCache()->get('test', 'it')); + $this->assertNull($configuration->getCache()->get('test', 'it')); $this->assertEmpty($configuration->getCache()->getAll()); } diff --git a/tests/src/Core/Config/PConfigurationTest.php b/tests/src/Core/Config/PConfigurationTest.php index 025994414..68443d05b 100644 --- a/tests/src/Core/Config/PConfigurationTest.php +++ b/tests/src/Core/Config/PConfigurationTest.php @@ -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('!!')->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('!!')->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();