BookingControllerFactoryTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 1
cbo 5
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\BookingControllerFactory;
6
use Zend\Mvc\Controller\PluginManager;
7
use Zend\ServiceManager\ServiceManager;
8
use Zend\View\HelperPluginManager;
9
10
/**
11
 * Class BookingControllerFactoryTest
12
 * @package JhFlexiTimeTest\Controller\Factory
13
 * @author Aydin Hassan <[email protected]>
14
 */
15
class BookingControllerFactoryTest extends \PHPUnit_Framework_TestCase
16
{
17
    public function testFactoryProcessesWithoutErrors()
18
    {
19
20
        $bookingService = $this
21
            ->getMockBuilder('JhFlexiTime\Service\BookingService')
22
            ->disableOriginalConstructor()
23
            ->getMock();
24
25
        $timeCalculatorService = $this
26
            ->getMockBuilder('JhFlexiTime\Service\TimeCalculatorService')
27
            ->disableOriginalConstructor()
28
            ->getMock();
29
30
        $formElementManager = new ServiceManager();
31
        $formElementManager->setService('JhFlexiTime\Form\BookingForm', $this->getMock('Zend\Form\FormInterface'));
32
        $userSettingsRepository = $this->getMock('JhFlexiTime\Repository\UserSettingsRepositoryInterface');
33
        $services = [
34
            'JhFlexiTime\Service\BookingService'        => $bookingService,
35
            'JhFlexiTime\Service\TimeCalculatorService' => $timeCalculatorService,
36
            'FormElementManager'                        => $formElementManager,
37
            'JhFlexiTime\Repository\UserSettingsRepository' => $userSettingsRepository,
38
        ];
39
40
        $serviceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface');
41
        $serviceLocator
42
            ->expects($this->any())
43
            ->method('get')
44
            ->will(
45
                $this->returnCallback(
46
                    function ($serviceName) use ($services) {
47
                        return $services[$serviceName];
48
                    }
49
                )
50
            );
51
52
        $controllerPluginManager = new PluginManager();
53
        $controllerPluginManager->setServiceLocator($serviceLocator);
54
55
        $factory = new BookingControllerFactory();
56
        $this->assertInstanceOf(
57
            'JhFlexiTime\Controller\BookingController',
58
            $factory->createService($controllerPluginManager)
59
        );
60
    }
61
}
62