CommandLoaderTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testLoadsCommands() 0 20 1
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