|
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\Container\ContainerInterface; |
|
9
|
|
|
use Psr\EventDispatcher\EventDispatcherInterface; |
|
10
|
|
|
use Psr\EventDispatcher\ListenerProviderInterface; |
|
11
|
|
|
use Psr\Log\LoggerInterface; |
|
12
|
|
|
use Psr\Log\NullLogger; |
|
13
|
|
|
use Yiisoft\Definitions\Exception\InvalidConfigException; |
|
14
|
|
|
use Yiisoft\Di\Container; |
|
15
|
|
|
use Yiisoft\Di\ContainerConfig; |
|
16
|
|
|
use Yiisoft\EventDispatcher\Dispatcher\Dispatcher; |
|
17
|
|
|
use Yiisoft\EventDispatcher\Provider\Provider; |
|
18
|
|
|
use Yiisoft\Yii\Debug\Collector\ContainerInterfaceProxy; |
|
19
|
|
|
use Yiisoft\Yii\Debug\ProxyServiceProvider; |
|
20
|
|
|
|
|
21
|
|
|
final class ProxyServiceProviderTest extends TestCase |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @throws InvalidConfigException |
|
25
|
|
|
* |
|
26
|
|
|
* @covers \Yiisoft\Yii\Debug\ProxyServiceProvider::getDefinitions() |
|
27
|
|
|
* @covers \Yiisoft\Yii\Debug\ProxyServiceProvider::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([new ProxyServiceProvider()]); |
|
38
|
|
|
$container = new Container($config); |
|
39
|
|
|
|
|
40
|
|
|
$this->assertInstanceOf(ContainerInterfaceProxy::class, $container->get(ContainerInterface::class)); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|