Passed
Pull Request — master (#27)
by Iakov
04:00
created

GetReflectionFromRequestStepTest::testExecute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Kami\ApiCoreBundle\Tests\RequestProcessor\Step\Common;
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();
20
        $step->setRequest($request);
21
        $step->setPreviousResponse(new ProcessorResponse($request, []));
22
23
        $response = $step->execute();
24
        $this->assertInstanceOf(ProcessorResponse::class, $response);
25
        $this->assertInstanceOf(\ReflectionClass::class, $response->getData()['reflection']);
26
    }
27
28
    public function testExecuteFailure()
29
    {
30
        $request = new Request();
31
        $request->attributes->set('_entity', 'Not\Existing\Class');
32
        $step = new GetReflectionFromRequestStep();
33
        $step->setPreviousResponse(new ProcessorResponse($request, []));
34
        $step->setRequest($request);
35
        $this->expectException(NotFoundHttpException::class);
36
        $step->execute();
37
    }
38
39
    public function testRequiresBefore()
40
    {
41
        $step = new GetReflectionFromRequestStep();
42
        $this->assertEquals([], $step->requiresBefore());
43
    }
44
}
45