Passed
Branch master (14d907)
by Simon
02:11
created

AccessDeniedToRouteEventTest::testHasResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Sil\RouteSecurityBundle\Tests\Event;
4
5
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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