Passed
Pull Request — master (#137)
by Zhukov
02:37
created

ActionCallerTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Yiisoft\Yii\Web\Tests\Middleware;
4
5
use Nyholm\Psr7\Response;
6
use Psr\Http\Message\ResponseInterface;
7
use Psr\Http\Message\ServerRequestInterface;
8
use Psr\Http\Server\RequestHandlerInterface;
9
use Yiisoft\Di\Container;
10
use Yiisoft\Yii\Web\Middleware\ActionCaller;
11
use PHPUnit\Framework\TestCase;
12
13
class ActionCallerTest extends TestCase
14
{
15
    /** @var ServerRequestInterface  */
16
    private $request;
17
18
    /** @var RequestHandlerInterface  */
19
    private $handler;
20
21
    protected function setUp()
22
    {
23
        $this->request = $this->createMock(ServerRequestInterface::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock(Psr\Ht...equestInterface::class) of type PHPUnit\Framework\MockObject\MockObject is incompatible with the declared type Psr\Http\Message\ServerRequestInterface of property $request.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
24
        $this->handler = $this->createMock(RequestHandlerInterface::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock(Psr\Ht...andlerInterface::class) of type PHPUnit\Framework\MockObject\MockObject is incompatible with the declared type Psr\Http\Server\RequestHandlerInterface of property $handler.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
25
    }
26
27
    public function testProcess()
28
    {
29
        $container = new Container([self::class => $this]);
30
31
        $caller = new ActionCaller(self::class, 'process', $container);
32
33
        $response = $caller->process($this->request, $this->handler);
34
        self::assertEquals(204, $response->getStatusCode());
35
    }
36
37
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
38
    {
39
        $this->assertSame($this->request, $request);
40
        $this->assertSame($this->handler, $handler);
41
42
        return new Response(204);
43
    }
44
}
45