Passed
Push — master ( 376d34...7bf0e1 )
by Alexander
04:51 queued 02:18
created

DebugContainerCommandTest::createContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
rs 10
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