Completed
Push — master ( 04fb86...879f48 )
by Fran
12:22 queued 07:22
created

ConfigLoaderTest::testConfigBasic()   B

Complexity

Conditions 2
Paths 4

Size

Total Lines 24
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 24
rs 8.9713
cc 2
eloc 17
nc 4
nop 0
1
<?php
2
    namespace CloudFrameworkTest\Tool;
3
    use CloudFramework\Tool\ConfigLoader;
4
5
    /**
6
     * Class ConfigLoaderTest
7
     * @package CloudFrameworkTest\Tool
8
     */
9
    class ConfigLoaderTest extends \PHPUnit_Framework_TestCase
10
    {
11
        /**
12
         * Test ConfigLoader basic functions
13
         */
14
        public function testConfigBasic()
15
        {
16
            $config = ConfigLoader::getInstance();
17
            //Try physical structure of the class
18
            try {
19
                $this->assertNotNull($config, 'ConfigLoader is null');
20
                $this->assertInstanceOf('\CloudFramework\Patterns\Singleton', $config, 'ConfigLoader isn\'t an instance of Singleton');
21
                $this->assertInstanceOf('\CloudFramework\Tool\ConfigLoader', $config, 'ConfigLoader must be an instante of ConfigLoader');
22
            } catch (\Exception $e) {
23
                $this->fail('ConfigLoader instatiator fails because: ' . $e->getMessage());
24
            }
25
            //Try to set a config var
26
            $testVar1 = time();
27
            $config->setConf('test', $testVar1);
28
            $this->assertNotNull($config->getConf('test'), 'Variable \'test\' is null');
29
            $this->assertEquals($testVar1, $config->getConf('test'), 'Test variable into ConfigLoader isn\'t the same as initial Test variable');
30
31
            //Try to set the same variable with different values
32
            $testVar2 = 'newValue';
33
            $config->setConf('test', $testVar2);
34
            $this->assertNotNull($config->getConf('test'), 'Variable \'test\' is null');
35
            $this->assertNotEquals($testVar1, $config->getConf('test'), 'Test variable didn\'t change from initial test value');
36
            $this->assertEquals($testVar2, $config->getConf('test'), 'Test variable is different than expected');
37
        }
38
    }