testGetListCanBeAccessed()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace JhFlexiTimeTest\Controller;
4
5
use JhFlexiTime\Controller\BookingAdminController;
6
use JhFlexiTime\Controller\BookingController;
7
8
use JhFlexiTime\DateTime\DateTime;
9
use JhFlexiTime\Entity\UserSettings;
10
use JhFlexiTime\Repository\UserSettingsRepositoryInterface;
11
use Zend\Http\Request;
12
use Zend\Http\Response;
13
use Zend\Mvc\MvcEvent;
14
use Zend\Mvc\Router\RouteMatch;
15
use Zend\Mvc\Router\Http\TreeRouteStack as HttpRouter;
16
use JhFlexiTimeTest\Util\ServiceManagerFactory;
17
use JhFlexiTime\Entity\Booking;
18
use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;
19
20
/**
21
 * Class BookingAdminControllerTest
22
 * @package JhFlexiTimeTest\Controller
23
 * @author Aydin Hassan <[email protected]>
24
 */
25
class BookingAdminControllerTest extends AbstractHttpControllerTestCase
26
{
27
28
    protected $controller;
29
    protected $routeMatch;
30
    protected $event;
31
    protected $request;
32
    protected $response;
33
    protected $user;
34
    protected $bookingService;
35
    protected $timeCalculatorService;
36
37
    /**
38
     * @var UserSettingsRepositoryInterface
39
     */
40
    protected $userSettingsRepository;
41
42
    public function setUp()
43
    {
44
        $this->userSettingsRepository
45
            = $this->getMock('JhFlexiTime\Repository\UserSettingsRepositoryInterface');
46
47
        $this->controller = new BookingAdminController();
48
49
        $this->request      = new Request();
50
        $this->routeMatch   = new RouteMatch([]);
51
        $this->event        = new MvcEvent();
52
53
        $serviceManager     = ServiceManagerFactory::getServiceManager();
54
        $config             = $serviceManager->get('Config');
55
        $routerConfig       = isset($config['router']) ? $config['router'] : [];
56
        $router             = HttpRouter::factory($routerConfig);
57
        $this->event->setRouter($router);
58
        $this->event->setRouteMatch($this->routeMatch);
59
        $this->controller->setEvent($this->event);
60
    }
61
62
63
    public function testGetListCanBeAccessed()
64
    {
65
        $this->routeMatch->setParam('action', 'index');
66
67
        $result   = $this->controller->dispatch($this->request);
68
        $response = $this->controller->getResponse();
69
70
        $this->assertEquals(200, $response->getStatusCode());
71
        $this->assertNull($result);
72
    }
73
}
74