diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-05-18 21:43:59 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-06-11 09:30:56 +0200 |
commit | 59404d7909b21682ec0782778452a8a70e38b25e (patch) | |
tree | 52bbe0b390ecd37f80128d1f8b4f80c3834734a8 /tests/config/ConfigManagerTest.php | |
parent | 823a363c3b2e10008a607c8b69c1a3d4e9b44ea1 (diff) | |
download | Shaarli-59404d7909b21682ec0782778452a8a70e38b25e.tar.gz Shaarli-59404d7909b21682ec0782778452a8a70e38b25e.tar.zst Shaarli-59404d7909b21682ec0782778452a8a70e38b25e.zip |
Introduce a configuration manager (not plugged yet)
Diffstat (limited to 'tests/config/ConfigManagerTest.php')
-rw-r--r-- | tests/config/ConfigManagerTest.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/config/ConfigManagerTest.php b/tests/config/ConfigManagerTest.php new file mode 100644 index 00000000..1b6358f3 --- /dev/null +++ b/tests/config/ConfigManagerTest.php | |||
@@ -0,0 +1,48 @@ | |||
1 | <?php | ||
2 | |||
3 | /** | ||
4 | * Unit tests for Class ConfigManagerTest | ||
5 | * | ||
6 | * Note: it only test the manager with ConfigJson, | ||
7 | * ConfigPhp is only a workaround to handle the transition to JSON type. | ||
8 | */ | ||
9 | class ConfigManagerTest extends \PHPUnit_Framework_TestCase | ||
10 | { | ||
11 | /** | ||
12 | * @var ConfigManager | ||
13 | */ | ||
14 | protected $conf; | ||
15 | |||
16 | public function setUp() | ||
17 | { | ||
18 | ConfigManager::$CONFIG_FILE = 'tests/config/config'; | ||
19 | $this->conf = ConfigManager::getInstance(); | ||
20 | } | ||
21 | |||
22 | public function tearDown() | ||
23 | { | ||
24 | @unlink($this->conf->getConfigFile()); | ||
25 | } | ||
26 | |||
27 | public function testSetWriteGet() | ||
28 | { | ||
29 | // This won't work with ConfigPhp. | ||
30 | $this->markTestIncomplete(); | ||
31 | |||
32 | $this->conf->set('paramInt', 42); | ||
33 | $this->conf->set('paramString', 'value1'); | ||
34 | $this->conf->set('paramBool', false); | ||
35 | $this->conf->set('paramArray', array('foo' => 'bar')); | ||
36 | $this->conf->set('paramNull', null); | ||
37 | |||
38 | $this->conf->write(true); | ||
39 | $this->conf->reload(); | ||
40 | |||
41 | $this->assertEquals(42, $this->conf->get('paramInt')); | ||
42 | $this->assertEquals('value1', $this->conf->get('paramString')); | ||
43 | $this->assertFalse($this->conf->get('paramBool')); | ||
44 | $this->assertEquals(array('foo' => 'bar'), $this->conf->get('paramArray')); | ||
45 | $this->assertEquals(null, $this->conf->get('paramNull')); | ||
46 | } | ||
47 | |||
48 | } \ No newline at end of file | ||