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
|
|
|
|