BookingRestControllerFactoryTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B testFactoryProcessesWithoutErrors() 0 44 1
1
<?php
2
3
namespace JhFlexiTimeTest\Controller\Factory;
4
5
use JhFlexiTime\Controller\Factory\BookingRestControllerFactory;
6
use Zend\Mvc\Controller\PluginManager;
7
8
/**
9
 * Class BookingRestControllerFactoryTest
10
 * @package JhFlexiTimeTest\Controller\Factory
11
 * @author Aydin Hassan <[email protected]>
12
 */
13
class BookingRestControllerFactoryTest extends \PHPUnit_Framework_TestCase
14
{
15
    public function testFactoryProcessesWithoutErrors()
16
    {
17
18
        $bookingService = $this
19
            ->getMockBuilder('JhFlexiTime\Service\BookingService')
20
            ->disableOriginalConstructor()
21
            ->getMock();
22
23
        $timecalculatorService = $this
24
            ->getMockBuilder('JhFlexiTime\Service\TimeCalculatorService')
25
            ->disableOriginalConstructor()
26
            ->getMock();
27
28
        $userRepository         = $this->getMock('JhUser\Repository\UserRepositoryInterface');
29
        $userSettingsRepository = $this->getMock('JhFlexiTime\Repository\UserSettingsRepositoryInterface');
30
31
        $services = [
32
            'JhFlexiTime\Service\BookingService'            => $bookingService,
33
            'JhFlexiTime\Service\TimeCalculatorService'     => $timecalculatorService,
34
            'JhUser\Repository\UserRepository'              => $userRepository,
35
            'JhFlexiTime\Repository\UserSettingsRepository' => $userSettingsRepository,
36
        ];
37
38
        $serviceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface');
39
        $serviceLocator
40
            ->expects($this->any())
41
            ->method('get')
42
            ->will(
43
                $this->returnCallback(
44
                    function ($serviceName) use ($services) {
45
                        return $services[$serviceName];
46
                    }
47
                )
48
            );
49
50
        $controllerPluginManager = new PluginManager();
51
        $controllerPluginManager->setServiceLocator($serviceLocator);
52
53
        $factory = new BookingRestControllerFactory();
54
        $this->assertInstanceOf(
55
            'JhFlexiTime\Controller\BookingRestController',
56
            $factory->createService($controllerPluginManager)
57
        );
58
    }
59
}
60