testFactoryProcessesWithoutErrors()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 31
rs 8.8571
cc 1
eloc 21
nc 1
nop 0
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