1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yiisoft\Yii\Debug\Tests\Unit\Command; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
use Psr\Container\ContainerInterface; |
9
|
|
|
use Psr\Log\LoggerInterface; |
10
|
|
|
use Psr\Log\NullLogger; |
11
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
12
|
|
|
use Yiisoft\Config\Config; |
13
|
|
|
use Yiisoft\Config\ConfigInterface; |
14
|
|
|
use Yiisoft\Config\ConfigPaths; |
15
|
|
|
use Yiisoft\Di\Container; |
16
|
|
|
use Yiisoft\Di\ContainerConfig; |
17
|
|
|
use Yiisoft\Yii\Debug\Command\DebugContainerCommand; |
18
|
|
|
use Yiisoft\Yii\Debug\Debugger; |
19
|
|
|
use Yiisoft\Yii\Debug\DebuggerIdGenerator; |
20
|
|
|
use Yiisoft\Yii\Debug\Storage\StorageInterface; |
21
|
|
|
|
22
|
|
|
final class DebugContainerCommandTest extends TestCase |
23
|
|
|
{ |
24
|
|
|
public function testCommand() |
25
|
|
|
{ |
26
|
|
|
$container = $this->createContainer(); |
27
|
|
|
$idGenerator = new DebuggerIdGenerator(); |
28
|
|
|
$storage = $this->createMock(StorageInterface::class); |
29
|
|
|
$storage->expects($this->never())->method('clear'); |
30
|
|
|
$debugger = new Debugger($idGenerator, $storage, []); |
31
|
|
|
|
32
|
|
|
$command = new DebugContainerCommand($container, $debugger); |
33
|
|
|
|
34
|
|
|
$commandTester = new CommandTester($command); |
35
|
|
|
|
36
|
|
|
$commandTester->execute([]); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
private function createContainer(): ContainerInterface |
40
|
|
|
{ |
41
|
|
|
$config = ContainerConfig::create() |
42
|
|
|
->withDefinitions([ |
43
|
|
|
LoggerInterface::class => NullLogger::class, |
44
|
|
|
ConfigInterface::class => [ |
45
|
|
|
'class' => Config::class, |
46
|
|
|
'__construct()' => [ |
47
|
|
|
new ConfigPaths(dirname(__DIR__, 2) . '/Support/Application/config'), |
48
|
|
|
], |
49
|
|
|
], |
50
|
|
|
]); |
51
|
|
|
return new Container($config); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|