LazyMiddlewareFactoryTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 4

6 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$0 ➔ setUp() 0 16 1
A hp$0 ➔ testCreatesProxyMiddleware() 0 5 1
testCreatesProxyMiddleware() 0 5 ?
A hp$0 ➔ get() 0 3 1
A hp$0 ➔ has() 0 3 1
setUp() 0 16 ?
1
<?php
2
declare(strict_types=1);
3
4
namespace Northwoods\Middleware;
5
6
use Northwoods\Middleware\Fixture\Middleware;
7
use PHPUnit\Framework\TestCase;
8
use Psr\Container\ContainerInterface;
9
use Psr\Http\Server\MiddlewareInterface;
10
11
class LazyMiddlewareFactoryTest extends TestCase
12
{
13
    /** @var LazyMiddlewareFactory */
14
    private $factory;
15
16
    protected function setUp(): void
17
    {
18
        $container = new class implements ContainerInterface
19
        {
20
            public function has($id)
21
            {
22
                return class_exists($id);
23
            }
24
25
            public function get($id)
26
            {
27
                return new $id();
28
            }
29
        };
30
31
        $this->factory = new LazyMiddlewareFactory($container);
32
    }
33
34
    public function testCreatesProxyMiddleware(): void
35
    {
36
        $middleware = $this->factory->defer(Middleware::class);
37
38
        $this->assertInstanceOf(MiddlewareInterface::class, $middleware);
39
    }
40
}
41