testGetResponseAsNull()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Sil\RouteSecurityBundle\Tests\Event;
4
5
use PHPUnit\Framework\TestCase;
6
use Sil\RouteSecurityBundle\Event\AccessDeniedToRouteEvent;
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\Response;
9
use Symfony\Component\Security\Core\User\UserInterface;
10
11
class AccessDeniedToRouteEventTest extends TestCase
12
{
13
    private function getFreshEvent()
14
    {
15
        $user = $this->createMock(UserInterface::class);
16
        $request = $this->createMock(Request::class);
17
18
        return new AccessDeniedToRouteEvent($user, $request);
19
    }
20
21
    public function testGetUser()
22
    {
23
        $event = $this->getFreshEvent();
24
        $this->assertInstanceOf(UserInterface::class, $event->getUser());
25
    }
26
27
    public function testGetRequest()
28
    {
29
        $event = $this->getFreshEvent();
30
        $this->assertInstanceOf(Request::class, $event->getRequest());
31
    }
32
33
    public function testGetResponseAsNull()
34
    {
35
        $event = $this->getFreshEvent();
36
        $this->assertNull($event->getResponse());
37
    }
38
39
    public function testGetResponse()
40
    {
41
        $event = $this->getFreshEvent();
42
        $response = $this->createMock(Response::class);
43
        $event->setResponse($response);
44
45
        $this->assertEquals($response, $event->getResponse());
46
    }
47
48
    public function testHasResponse()
49
    {
50
        $event = $this->getFreshEvent();
51
        $this->assertFalse($event->hasResponse());
52
53
        $response = $this->createMock(Response::class);
54
        $event->setResponse($response);
55
        $this->assertTrue($event->hasResponse());
56
    }
57
}
58