X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fconfig%2FConfigManagerTest.php;h=1ec447b23aeab9bfbe31b847e9731cfa780db617;hb=3512f4461722c9a3c7cf6511232bda156bf91970;hp=7390699ce80d5b6eb8546519f4d954da81377f02;hpb=b74b96bfbd0b778ac50fd17f5e107c51435b1678;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/config/ConfigManagerTest.php b/tests/config/ConfigManagerTest.php index 7390699c..1ec447b2 100644 --- a/tests/config/ConfigManagerTest.php +++ b/tests/config/ConfigManagerTest.php @@ -1,4 +1,5 @@ conf = ConfigManager::reset(); + $this->conf = new ConfigManager('tests/utils/config/configJson'); } /** @@ -54,10 +54,10 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase $this->conf->set('paramArray', array('foo' => 'bar')); $this->conf->set('paramNull', null); - ConfigManager::$CONFIG_FILE = 'tests/utils/config/configTmp'; + $this->conf->setConfigFile('tests/utils/config/configTmp'); $this->conf->write(true); $this->conf->reload(); - unlink($this->conf->getConfigFile()); + unlink($this->conf->getConfigFileExt()); $this->assertEquals(42, $this->conf->get('paramInt')); $this->assertEquals('value1', $this->conf->get('paramString')); @@ -73,10 +73,10 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase { $this->conf->set('foo.bar.key.stuff', 'testSetWriteGetNested'); - ConfigManager::$CONFIG_FILE = 'tests/utils/config/configTmp'; + $this->conf->setConfigFile('tests/utils/config/configTmp'); $this->conf->write(true); $this->conf->reload(); - unlink($this->conf->getConfigFile()); + unlink($this->conf->getConfigFileExt()); $this->assertEquals('testSetWriteGetNested', $this->conf->get('foo.bar.key.stuff')); } @@ -84,7 +84,7 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase /** * Set with an empty key. * - * @expectedException Exception + * @expectedException \Exception * @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*# */ public function testSetEmptyKey() @@ -95,7 +95,7 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase /** * Set with an array key. * - * @expectedException Exception + * @expectedException \Exception * @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*# */ public function testSetArrayKey() @@ -106,12 +106,12 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase /** * Try to write the config without mandatory parameter (e.g. 'login'). * - * @expectedException MissingFieldConfigException + * @expectedException Shaarli\Config\Exception\MissingFieldConfigException */ public function testWriteMissingParameter() { - ConfigManager::$CONFIG_FILE = 'tests/utils/config/configTmp'; - $this->assertFalse(file_exists($this->conf->getConfigFile())); + $this->conf->setConfigFile('tests/utils/config/configTmp'); + $this->assertFalse(file_exists($this->conf->getConfigFileExt())); $this->conf->reload(); $this->conf->write(true); @@ -131,7 +131,7 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase */ public function testExistsOk() { - $this->assertTrue($this->conf->exists('login')); + $this->assertTrue($this->conf->exists('credentials.login')); $this->assertTrue($this->conf->exists('config.foo')); } @@ -151,10 +151,9 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase */ public function testReset() { - $conf = $this->conf; - $this->assertTrue($conf === ConfigManager::getInstance()); - $this->assertFalse($conf === $this->conf->reset()); - $this->assertFalse($conf === ConfigManager::getInstance()); + $confIO = $this->conf->getConfigIO(); + $this->conf->reset(); + $this->assertFalse($confIO === $this->conf->getConfigIO()); } /** @@ -162,13 +161,13 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase */ public function testReload() { - ConfigManager::$CONFIG_FILE = 'tests/utils/config/configTmp'; - $newConf = ConfigJson::$PHP_HEADER . '{ "key": "value" }'; - file_put_contents($this->conf->getConfigFile(), $newConf); + $this->conf->setConfigFile('tests/utils/config/configTmp'); + $newConf = ConfigJson::getPhpHeaders() . '{ "key": "value" }'; + file_put_contents($this->conf->getConfigFileExt(), $newConf); $this->conf->reload(); - unlink($this->conf->getConfigFile()); + unlink($this->conf->getConfigFileExt()); // Previous conf no longer exists, and new values have been loaded. - $this->assertFalse($this->conf->exists('login')); + $this->assertFalse($this->conf->exists('credentials.login')); $this->assertEquals('value', $this->conf->get('key')); } }