1 | <?php |
||||||
2 | |||||||
3 | namespace Nip\Dispatcher\Tests\Commands; |
||||||
4 | |||||||
5 | use Nip\Dispatcher\Commands\Command; |
||||||
6 | use Nip\Dispatcher\Tests\AbstractTest; |
||||||
7 | use Nip\Http\Response\Response; |
||||||
8 | use Nip\Request; |
||||||
9 | |||||||
10 | /** |
||||||
11 | * Class CommandTest |
||||||
12 | * @package Nip\Dispatcher\Tests\Commands |
||||||
13 | */ |
||||||
14 | class CommandTest extends AbstractTest |
||||||
15 | { |
||||||
16 | public function testGetSetRequest() |
||||||
17 | { |
||||||
18 | $command = new Command(); |
||||||
19 | self::assertEquals(null, $command->getRequest()); |
||||||
20 | self::assertFalse($command->hasRequest()); |
||||||
21 | |||||||
22 | $request = new Request(); |
||||||
0 ignored issues
–
show
Deprecated Code
introduced
by
![]() |
|||||||
23 | $command->setRequest($request); |
||||||
24 | |||||||
25 | self::assertTrue($command->hasRequest()); |
||||||
26 | self::assertEquals($request, $command->getRequest()); |
||||||
27 | } |
||||||
28 | |||||||
29 | public function testGetSetResponse() |
||||||
30 | { |
||||||
31 | $command = new Command(); |
||||||
32 | self::assertEquals(null, $command->getReturn()); |
||||||
0 ignored issues
–
show
Are you sure the usage of
$command->getReturn() targeting Nip\Dispatcher\Commands\Command::getReturn() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
33 | self::assertFalse($command->hasReturn()); |
||||||
34 | |||||||
35 | $response = new Response(); |
||||||
36 | $command->setReturn($response); |
||||||
37 | self::assertTrue($command->hasReturn()); |
||||||
38 | self::assertEquals($response, $command->getReturn()); |
||||||
0 ignored issues
–
show
Are you sure the usage of
$command->getReturn() targeting Nip\Dispatcher\Commands\Command::getReturn() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
39 | } |
||||||
40 | |||||||
41 | /** |
||||||
42 | * @throws \Exception |
||||||
43 | */ |
||||||
44 | public function testActionGetParamWithActionStringSet() |
||||||
45 | { |
||||||
46 | $command = new Command(); |
||||||
47 | $command->setAction('Module@Controller::action'); |
||||||
48 | self::assertEquals('Module@Controller::action', $command->getAction()); |
||||||
49 | |||||||
50 | self::expectException(\Exception::class); |
||||||
0 ignored issues
–
show
The method
PHPUnit\Framework\TestCase::expectException() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
51 | $command->getActionParam('name'); |
||||||
52 | } |
||||||
53 | |||||||
54 | /** |
||||||
55 | * @throws \Exception |
||||||
56 | */ |
||||||
57 | public function testActionGetParamWithActionEmpty() |
||||||
58 | { |
||||||
59 | $command = new Command(); |
||||||
60 | |||||||
61 | self::assertNull($command->getActionParam('name')); |
||||||
62 | } |
||||||
63 | |||||||
64 | /** |
||||||
65 | * @throws \Exception |
||||||
66 | */ |
||||||
67 | public function testActionSetParamWithActionStringSet() |
||||||
68 | { |
||||||
69 | $command = new Command(); |
||||||
70 | $command->setAction('Module@Controller::action'); |
||||||
71 | |||||||
72 | self::expectException(\Exception::class); |
||||||
0 ignored issues
–
show
The method
PHPUnit\Framework\TestCase::expectException() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
73 | $command->setActionParam('name', 'value'); |
||||||
74 | } |
||||||
75 | |||||||
76 | /** |
||||||
77 | * @throws \Exception |
||||||
78 | */ |
||||||
79 | public function testActionSetParamWithActionEmpty() |
||||||
80 | { |
||||||
81 | $command = new Command(); |
||||||
82 | |||||||
83 | self::assertNull($command->getActionParam('name')); |
||||||
84 | |||||||
85 | $command->setActionParam('name', 'value'); |
||||||
86 | self::assertEquals('value', $command->getActionParam('name')); |
||||||
87 | self::assertEquals(['name' => 'value'], $command->getAction()); |
||||||
88 | } |
||||||
89 | } |
||||||
90 |