ModuleOptionsFactoryTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 4
dl 0
loc 44
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testFactoryReturnsInjectedOptions() 0 10 1
A testFactoryReturnsDefaultOptionsWithEmptyConfig() 0 10 1
A testFactoryReturnsDefaultOptionsWithNoConfig() 0 10 1
1
<?php
2
3
namespace JhFlexiTimeTest\Options\Factory;
4
5
use JhFlexiTime\Options\Factory\ModuleOptionsFactory;
6
use Zend\ServiceManager\ServiceManager;
7
8
/**
9
 * Class ModuleOptionsFactoryTest
10
 * @package JhFlexiTime\Options\OptionsTest\Factory
11
 * @author Aydin Hassan <[email protected]>
12
 */
13
class ModuleOptionsFactoryTest extends \PHPUnit_Framework_TestCase
14
{
15
    /**
16
     * Test options injects from config files
17
     */
18
    public function testFactoryReturnsInjectedOptions()
19
    {
20
        $config = ['lunch_duration' => 2];
21
22
        $locator = new ServiceManager();
23
        $locator->setService('Config', ['flexi' => ['policy_options' => $config]]);
24
25
        $factory = new ModuleOptionsFactory();
26
        $this->assertEquals(2, $factory->createService($locator)->getLunchDuration());
27
    }
28
29
    /**
30
     * Test options returns defaults when no config set
31
     */
32
    public function testFactoryReturnsDefaultOptionsWithEmptyConfig()
33
    {
34
        $config = [];
35
36
        $locator = new ServiceManager();
37
        $locator->setService('Config', ['flexi' => ['policy_options' => $config]]);
38
39
        $factory = new ModuleOptionsFactory();
40
        $this->assertEquals(1, $factory->createService($locator)->getLunchDuration());
41
    }
42
43
    /**
44
     * Test options returns defaults when no global config
45
     */
46
    public function testFactoryReturnsDefaultOptionsWithNoConfig()
47
    {
48
        $config = [];
49
50
        $locator = new ServiceManager();
51
        $locator->setService('Config', $config);
52
53
        $factory = new ModuleOptionsFactory();
54
        $this->assertEquals(1, $factory->createService($locator)->getLunchDuration());
55
    }
56
}
57