UserSettingsRepositoryFactoryTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 37
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testFactoryReturnsRepositoryFromObjectManager() 0 34 1
1
<?php
2
3
namespace JhFlexiTimeTest\Repository\Factory;
4
5
use JhFlexiTime\Repository\Factory\UserSettingsRepositoryFactory;
6
7
/**
8
 * Class UserSettingsRepositoryFactoryTest
9
 * @package JhFlexiTimeTest\Repository\Factory
10
 * @author Aydin Hassan <[email protected]>
11
 */
12
class UserSettingsRepositoryFactoryTest extends \PHPUnit_Framework_TestCase
13
{
14
    public function testFactoryReturnsRepositoryFromObjectManager()
15
    {
16
        $objectManager    = $this->getMock('Doctrine\Common\Persistence\ObjectManager');
17
        $objectRepository = $this->getMock('Doctrine\Common\Persistence\ObjectRepository');
18
        $serviceLocator   = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface');
19
20
        $objectManager
21
            ->expects($this->any())
22
            ->method('getRepository')
23
            ->with($this->equalTo('JhFlexiTime\Entity\UserSettings'))
24
            ->will($this->returnValue($objectRepository));
25
26
        $services = [
27
            'JhFlexiTime\ObjectManager' => $objectManager,
28
        ];
29
30
        $serviceLocator
31
            ->expects($this->any())
32
            ->method('get')
33
            ->will(
34
                $this->returnCallback(
35
                    function ($serviceName) use ($services) {
36
                        return $services[$serviceName];
37
                    }
38
                )
39
            );
40
41
42
        $factory = new UserSettingsRepositoryFactory();
43
        $this->assertInstanceOf(
44
            'JhFlexiTime\Repository\UserSettingsRepository',
45
            $factory->createService($serviceLocator)
46
        );
47
    }
48
}
49