ErrorHandlerManagerTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 12 1
A callablesAreReturned() 0 5 1
A nonCallablesThrowException() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AcelayaTest\ExpressiveErrorHandler\ErrorHandler;
6
7
use Acelaya\ExpressiveErrorHandler\ErrorHandler\ErrorResponseGeneratorManager;
8
use Closure;
9
use PHPUnit\Framework\TestCase;
10
use stdClass;
11
use Zend\ServiceManager\Exception\InvalidServiceException;
12
use Zend\ServiceManager\ServiceManager;
13
14
class ErrorHandlerManagerTest extends TestCase
15
{
16
    /** @var ErrorResponseGeneratorManager */
17
    protected $pluginManager;
18
19
    public function setUp(): void
20
    {
21
        $this->pluginManager = new ErrorResponseGeneratorManager(new ServiceManager(), [
22
            'services' => [
23
                'foo' => function () {
24
                },
25
            ],
26
            'invokables' => [
27
                'invalid' => stdClass::class,
28
            ],
29
        ]);
30
    }
31
32
    /**
33
     * @test
34
     */
35
    public function callablesAreReturned(): void
36
    {
37
        $instance = $this->pluginManager->get('foo');
38
        $this->assertInstanceOf(Closure::class, $instance);
39
    }
40
41
    /**
42
     * @test
43
     */
44
    public function nonCallablesThrowException()
45
    {
46
        $this->expectException(InvalidServiceException::class);
47
        $this->pluginManager->get('invalid');
48
    }
49
}
50