Passed
Branch request-processor (31ada2)
by Iakov
02:59
created

testRequiresBefore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Kami\ApiCoreBundle\Tests\RequestProcessor\Step;
4
5
use Kami\ApiCoreBundle\RequestProcessor\ProcessorResponse;
6
use Kami\ApiCoreBundle\RequestProcessor\Step\Common\GetReflectionFromRequestStep;
7
use Kami\ApiCoreBundle\Tests\fixtures\Entity;
8
use PHPUnit\Framework\TestCase;
9
use Symfony\Component\HttpFoundation\Request;
10
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
11
12
class GetReflectionFromRequestStepTest extends TestCase
13
{
14
15
    public function testExecute()
16
    {
17
        $request = new Request();
18
        $request->attributes->set('_entity', Entity::class);
19
        $step = new GetReflectionFromRequestStep($request, new ProcessorResponse($request, []));
20
        $response = $step->execute();
21
        $this->assertInstanceOf(ProcessorResponse::class, $response);
22
        $this->assertInstanceOf(\ReflectionClass::class, $response->getData()['reflection']);
23
    }
24
25
    public function testExecuteFailure()
26
    {
27
        $request = new Request();
28
        $request->attributes->set('_entity', 'Not\Existing\Class');
29
        $step = new GetReflectionFromRequestStep($request, new ProcessorResponse($request, []));
30
        $this->expectException(NotFoundHttpException::class);
31
        $step->execute();
32
    }
33
34
    public function testRequiresBefore()
35
    {
36
        $request = new Request();
37
        $step = new GetReflectionFromRequestStep($request, new ProcessorResponse($request, []));
38
        $this->assertEquals([], $step->requiresBefore());
39
    }
40
}
41