Completed
Pull Request — master (#9)
by Iakov
03:57
created

GetReflectionFromRequestStepTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testExecuteFailure() 0 7 1
A testRequiresBefore() 0 5 1
A testExecute() 0 8 1
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, []));
0 ignored issues
show
Unused Code introduced by
The call to Kami\ApiCoreBundle\Reque...uestStep::__construct() has too many arguments starting with $request. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        $step = /** @scrutinizer ignore-call */ new GetReflectionFromRequestStep($request, new ProcessorResponse($request, []));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
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, []));
0 ignored issues
show
Unused Code introduced by
The call to Kami\ApiCoreBundle\Reque...uestStep::__construct() has too many arguments starting with $request. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
        $step = /** @scrutinizer ignore-call */ new GetReflectionFromRequestStep($request, new ProcessorResponse($request, []));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
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, []));
0 ignored issues
show
Unused Code introduced by
The call to Kami\ApiCoreBundle\Reque...uestStep::__construct() has too many arguments starting with $request. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
        $step = /** @scrutinizer ignore-call */ new GetReflectionFromRequestStep($request, new ProcessorResponse($request, []));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
38
        $this->assertEquals([], $step->requiresBefore());
39
    }
40
}
41