]> git.immae.eu Git - github/shaarli/Shaarli.git/blob - tests/config/ConfigManagerTest.php
Introduce a configuration manager (not plugged yet)
[github/shaarli/Shaarli.git] / tests / config / ConfigManagerTest.php
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 }