CommandLoaderTest::testLoadsCommands()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 15
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 20
rs 9.7666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gorynych\Tests\Util;
6
7
use Gorynych\Util\CommandLoader;
8
use PHPUnit\Framework\TestCase;
9
use Symfony\Component\Console\Application;
10
use Symfony\Component\Console\Command\Command;
11
use Symfony\Component\DependencyInjection\ContainerBuilder;
12
13
class CommandLoaderTest extends TestCase
14
{
15
    public function testLoadsCommands(): void
16
    {
17
        $containerMock = $this->createMock(ContainerBuilder::class);
18
        $cliMock = $this->createMock(Application::class);
19
        $commandMock = $this->createMock(Command::class);
20
21
        $containerMock
22
            ->expects($this->once())
23
            ->method('findTaggedServiceIds')
24
            ->with(CommandLoader::COMMAND_TAG)
25
            ->willReturn([1 => CommandLoader::COMMAND_TAG]);
26
        $containerMock
27
            ->expects($this->once())
28
            ->method('get')
29
            ->with(1)
30
            ->willReturn($commandMock);
31
32
        $cliMock->expects($this->once())->method('add')->with($commandMock);
33
34
        (new CommandLoader())->load($cliMock, $containerMock);
35
    }
36
}
37