diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-06-09 20:04:02 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-06-11 09:30:56 +0200 |
commit | 278d9ee2836df7d805845077f26f8cecd16f0f4f (patch) | |
tree | 9155cab8890074e83b54efaa649bfa74885d3ab5 /tests/config | |
parent | 7f179985b497053c59338667fe49c390aa626ab7 (diff) | |
download | Shaarli-278d9ee2836df7d805845077f26f8cecd16f0f4f.tar.gz Shaarli-278d9ee2836df7d805845077f26f8cecd16f0f4f.tar.zst Shaarli-278d9ee2836df7d805845077f26f8cecd16f0f4f.zip |
ConfigManager no longer uses singleton pattern
Diffstat (limited to 'tests/config')
-rw-r--r-- | tests/config/ConfigManagerTest.php | 28 |
1 files changed, 13 insertions, 15 deletions
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 | |||
15 | 15 | ||
16 | public function setUp() | 16 | public function setUp() |
17 | { | 17 | { |
18 | ConfigManager::$CONFIG_FILE = 'tests/utils/config/configJson'; | 18 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
19 | $this->conf = ConfigManager::reset(); | ||
20 | } | 19 | } |
21 | 20 | ||
22 | /** | 21 | /** |
@@ -54,10 +53,10 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase | |||
54 | $this->conf->set('paramArray', array('foo' => 'bar')); | 53 | $this->conf->set('paramArray', array('foo' => 'bar')); |
55 | $this->conf->set('paramNull', null); | 54 | $this->conf->set('paramNull', null); |
56 | 55 | ||
57 | ConfigManager::$CONFIG_FILE = 'tests/utils/config/configTmp'; | 56 | $this->conf->setConfigFile('tests/utils/config/configTmp'); |
58 | $this->conf->write(true); | 57 | $this->conf->write(true); |
59 | $this->conf->reload(); | 58 | $this->conf->reload(); |
60 | unlink($this->conf->getConfigFile()); | 59 | unlink($this->conf->getConfigFileExt()); |
61 | 60 | ||
62 | $this->assertEquals(42, $this->conf->get('paramInt')); | 61 | $this->assertEquals(42, $this->conf->get('paramInt')); |
63 | $this->assertEquals('value1', $this->conf->get('paramString')); | 62 | $this->assertEquals('value1', $this->conf->get('paramString')); |
@@ -73,10 +72,10 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase | |||
73 | { | 72 | { |
74 | $this->conf->set('foo.bar.key.stuff', 'testSetWriteGetNested'); | 73 | $this->conf->set('foo.bar.key.stuff', 'testSetWriteGetNested'); |
75 | 74 | ||
76 | ConfigManager::$CONFIG_FILE = 'tests/utils/config/configTmp'; | 75 | $this->conf->setConfigFile('tests/utils/config/configTmp'); |
77 | $this->conf->write(true); | 76 | $this->conf->write(true); |
78 | $this->conf->reload(); | 77 | $this->conf->reload(); |
79 | unlink($this->conf->getConfigFile()); | 78 | unlink($this->conf->getConfigFileExt()); |
80 | 79 | ||
81 | $this->assertEquals('testSetWriteGetNested', $this->conf->get('foo.bar.key.stuff')); | 80 | $this->assertEquals('testSetWriteGetNested', $this->conf->get('foo.bar.key.stuff')); |
82 | } | 81 | } |
@@ -110,8 +109,8 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase | |||
110 | */ | 109 | */ |
111 | public function testWriteMissingParameter() | 110 | public function testWriteMissingParameter() |
112 | { | 111 | { |
113 | ConfigManager::$CONFIG_FILE = 'tests/utils/config/configTmp'; | 112 | $this->conf->setConfigFile('tests/utils/config/configTmp'); |
114 | $this->assertFalse(file_exists($this->conf->getConfigFile())); | 113 | $this->assertFalse(file_exists($this->conf->getConfigFileExt())); |
115 | $this->conf->reload(); | 114 | $this->conf->reload(); |
116 | 115 | ||
117 | $this->conf->write(true); | 116 | $this->conf->write(true); |
@@ -151,10 +150,9 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase | |||
151 | */ | 150 | */ |
152 | public function testReset() | 151 | public function testReset() |
153 | { | 152 | { |
154 | $conf = $this->conf; | 153 | $confIO = $this->conf->getConfigIO(); |
155 | $this->assertTrue($conf === ConfigManager::getInstance()); | 154 | $this->conf->reset(); |
156 | $this->assertFalse($conf === $this->conf->reset()); | 155 | $this->assertFalse($confIO === $this->conf->getConfigIO()); |
157 | $this->assertFalse($conf === ConfigManager::getInstance()); | ||
158 | } | 156 | } |
159 | 157 | ||
160 | /** | 158 | /** |
@@ -162,11 +160,11 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase | |||
162 | */ | 160 | */ |
163 | public function testReload() | 161 | public function testReload() |
164 | { | 162 | { |
165 | ConfigManager::$CONFIG_FILE = 'tests/utils/config/configTmp'; | 163 | $this->conf->setConfigFile('tests/utils/config/configTmp'); |
166 | $newConf = ConfigJson::getPhpHeaders() . '{ "key": "value" }'; | 164 | $newConf = ConfigJson::getPhpHeaders() . '{ "key": "value" }'; |
167 | file_put_contents($this->conf->getConfigFile(), $newConf); | 165 | file_put_contents($this->conf->getConfigFileExt(), $newConf); |
168 | $this->conf->reload(); | 166 | $this->conf->reload(); |
169 | unlink($this->conf->getConfigFile()); | 167 | unlink($this->conf->getConfigFileExt()); |
170 | // Previous conf no longer exists, and new values have been loaded. | 168 | // Previous conf no longer exists, and new values have been loaded. |
171 | $this->assertFalse($this->conf->exists('credentials.login')); | 169 | $this->assertFalse($this->conf->exists('credentials.login')); |
172 | $this->assertEquals('value', $this->conf->get('key')); | 170 | $this->assertEquals('value', $this->conf->get('key')); |