BookingFormFactoryTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B testFactoryProcessesWithoutErrors() 0 31 1
1
<?php
2
3
namespace JhFlexiTimeTest\Form\Factory;
4
5
use JhFlexiTime\Form\Factory\BookingFormFactory;
6
use Zend\Form\FormElementManager;
7
8
/**
9
 * Class BookingFormFactoryTest
10
 * @package JhFlexiTimeTest\Form\Factory
11
 * @author Aydin Hassan <[email protected]>
12
 */
13
class BookingFormFactoryTest extends \PHPUnit_Framework_TestCase
14
{
15
    public function testFactoryProcessesWithoutErrors()
16
    {
17
        $authService = $this->getMock('\Zend\Authentication\AuthenticationServiceInterface');
18
        $authService
19
            ->expects($this->once())
20
            ->method('getIdentity')
21
            ->will($this->returnValue($this->getMock('ZfcUser\Entity\UserInterface')));
22
23
        $services = [
24
            'JhFlexiTime\ObjectManager' => $this->getMock('Doctrine\Common\Persistence\ObjectManager'),
25
            'zfcuser_auth_service'      => $authService,
26
        ];
27
28
        $serviceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface');
29
        $serviceLocator
30
            ->expects($this->any())
31
            ->method('get')
32
            ->will(
33
                $this->returnCallback(
34
                    function ($serviceName) use ($services) {
35
                        return $services[$serviceName];
36
                    }
37
                )
38
            );
39
40
        $formElementManager = new FormElementManager();
41
        $formElementManager->setServiceLocator($serviceLocator);
42
43
        $factory = new BookingFormFactory();
44
        $this->assertInstanceOf('JhFlexiTime\Form\BookingForm', $factory->createService($formElementManager));
45
    }
46
}
47