aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/config/ConfigManagerTest.php
blob: 1b6358f307882b6465ccdeb71f62daafbd41b0a4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

/**
 * Unit tests for Class ConfigManagerTest
 *
 * Note: it only test the manager with ConfigJson,
 *  ConfigPhp is only a workaround to handle the transition to JSON type.
 */
class ConfigManagerTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var ConfigManager
     */
    protected $conf;

    public function setUp()
    {
        ConfigManager::$CONFIG_FILE = 'tests/config/config';
        $this->conf = ConfigManager::getInstance();
    }

    public function tearDown()
    {
        @unlink($this->conf->getConfigFile());
    }

    public function testSetWriteGet()
    {
        // This won't work with ConfigPhp.
        $this->markTestIncomplete();

        $this->conf->set('paramInt', 42);
        $this->conf->set('paramString', 'value1');
        $this->conf->set('paramBool', false);
        $this->conf->set('paramArray', array('foo' => 'bar'));
        $this->conf->set('paramNull', null);

        $this->conf->write(true);
        $this->conf->reload();

        $this->assertEquals(42, $this->conf->get('paramInt'));
        $this->assertEquals('value1', $this->conf->get('paramString'));
        $this->assertFalse($this->conf->get('paramBool'));
        $this->assertEquals(array('foo' => 'bar'), $this->conf->get('paramArray'));
        $this->assertEquals(null, $this->conf->get('paramNull'));
    }
    
}