Passed
Push — master ( bace86...bb4cad )
by Dmitriy
05:30 queued 02:57
created

DebugServiceProviderTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testRegister() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Tests\Unit;
6
7
use PHPUnit\Framework\TestCase;
8
use Psr\EventDispatcher\EventDispatcherInterface;
9
use Psr\EventDispatcher\ListenerProviderInterface;
10
use Psr\Log\LoggerInterface;
11
use Psr\Log\NullLogger;
12
use Yiisoft\Definitions\Exception\InvalidConfigException;
13
use Yiisoft\Di\Container;
14
use Yiisoft\Di\ContainerConfig;
15
use Yiisoft\EventDispatcher\Dispatcher\Dispatcher;
16
use Yiisoft\EventDispatcher\Provider\Provider;
17
use Yiisoft\Yii\Debug\DebugServiceProvider;
18
use Yiisoft\Yii\Debug\Collector\EventDispatcherInterfaceProxy;
19
use Yiisoft\Yii\Debug\Collector\LoggerInterfaceProxy;
20
21
final class DebugServiceProviderTest extends TestCase
22
{
23
    /**
24
     * @throws InvalidConfigException
25
     *
26
     * @covers \Yiisoft\Yii\Debug\DebugServiceProvider::getDefinitions()
27
     * @covers \Yiisoft\Yii\Debug\DebugServiceProvider::getExtensions()
28
     */
29
    public function testRegister(): void
30
    {
31
        $config = ContainerConfig::create()
32
            ->withDefinitions([
33
                LoggerInterface::class => NullLogger::class,
34
                EventDispatcherInterface::class => Dispatcher::class,
35
                ListenerProviderInterface::class => Provider::class,
36
            ])
37
            ->withProviders([
38
                new DebugServiceProvider(),
39
            ]);
40
        $container = new Container($config);
41
42
        $this->assertInstanceOf(LoggerInterfaceProxy::class, $container->get(LoggerInterface::class));
43
        $this->assertInstanceOf(EventDispatcherInterfaceProxy::class, $container->get(EventDispatcherInterface::class));
44
    }
45
}
46