X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fconfig%2FConfigManagerTest.php;h=436e3d673850245ecd16c027716df25e94edc5ca;hb=8406a4b670957b7d0450f6ea5e4f2e61c7114e8f;hp=9ff0f473bbf373470e10400b125ecfafda3cbcad;hpb=da10377b3c263d96a46cf9101c202554343d2cd0;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/config/ConfigManagerTest.php b/tests/config/ConfigManagerTest.php index 9ff0f473..436e3d67 100644 --- a/tests/config/ConfigManagerTest.php +++ b/tests/config/ConfigManagerTest.php @@ -15,8 +15,7 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase public function setUp() { - ConfigManager::$CONFIG_FILE = 'tests/utils/config/configJson'; - $this->conf = ConfigManager::reset(); + $this->conf = new ConfigManager('tests/utils/config/configJson'); } /** @@ -54,10 +53,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 +72,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')); } @@ -110,8 +109,8 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase */ 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); @@ -151,10 +150,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,11 +160,11 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase */ public function testReload() { - ConfigManager::$CONFIG_FILE = 'tests/utils/config/configTmp'; + $this->conf->setConfigFile('tests/utils/config/configTmp'); $newConf = ConfigJson::getPhpHeaders() . '{ "key": "value" }'; - file_put_contents($this->conf->getConfigFile(), $newConf); + 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('credentials.login')); $this->assertEquals('value', $this->conf->get('key'));