ConfigLoaderTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 30
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testConfigBasic() 0 24 2
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
    }