$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;
}
}
// 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;
}
}
$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;
}
}
// 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;
}
}
$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
{
$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'));
}
/**
],
]);
- $this->assertTrue($configCache->has('system'));
-
$this->assertEquals([
'key1' => 'value1',
'key2' => 'value2',
],
]);
- $this->assertTrue($configCache->hasP($uid,'system'));
-
$this->assertEquals([
'key1' => 'value1',
'key2' => 'value2',
$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'));
- }
}
$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'));
$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);
// 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'));
}
/**
$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();
$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());
}
$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);
$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();