Passed
Push — master ( 72a485...d1319e )
by Woody
14:49 queued 05:56
created

()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Northwoods\Middleware;
5
6
use Northwoods\Middleware\Fixture\Handler;
7
use Northwoods\Middleware\Fixture\Middleware;
8
use Nyholm\Psr7\ServerRequest;
9
use PHPUnit\Framework\TestCase;
10
use Psr\Container\ContainerInterface;
11
12
class LazyMiddlewareTest extends TestCase
13
{
14
    /** @var ContainerInterface */
15
    private $container;
0 ignored issues
show
Coding Style introduced by
Private member variable "container" must contain a leading underscore
Loading history...
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
16
17
    public function setUp()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
18
    {
19
        $this->container = new class implements ContainerInterface
20
        {
21
            public function has($id)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
22
            {
23
                return class_exists($id);
24
            }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
25
26
            public function get($id)
27
            {
28
                return new $id();
29
            }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
30
        };
31
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
32
33
    public function testDefersToMiddlewareImplemention(): void
34
    {
35
        $middleware = new LazyMiddleware($this->container, Middleware::class);
36
37
        $handler = new Handler();
38
        $request = new ServerRequest('GET', 'https://example.com/');
39
40
        $response = $middleware->process($request, $handler);
41
42
        $this->assertEquals(200, $response->getStatusCode());
43
        $this->assertEquals(Middleware::class, (string) $response->getBody());
44
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
45
}
46