BookingOptionsFactoryTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
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\BookingOptionsFactory;
6
use Zend\ServiceManager\ServiceManager;
7
8
/**
9
 * Class BookingOptionsFactoryTest
10
 * @package JhFlexiTime\Options\OptionsTest\Factory
11
 * @author Aydin Hassan <[email protected]>
12
 */
13
class BookingOptionsFactoryTest extends \PHPUnit_Framework_TestCase
14
{
15
    /**
16
     * Test options injects from config files
17
     */
18
    public function testFactoryReturnsInjectedOptions()
19
    {
20
        $config = ['min_start_time' => '10:00'];
21
22
        $locator = new ServiceManager();
23
        $locator->setService('Config', ['flexi' => ['booking_options' => $config]]);
24
25
        $factory = new BookingOptionsFactory();
26
        $this->assertEquals('10:00', $factory->createService($locator)->getMinStartTime());
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' => ['booking_options' => $config]]);
38
39
        $factory = new BookingOptionsFactory();
40
        $this->assertFalse($factory->createService($locator)->getMinStartTime());
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 BookingOptionsFactory();
54
        $this->assertFalse($factory->createService($locator)->getMinStartTime());
55
    }
56
}
57