HelloCommandCest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 25
c 0
b 0
f 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testExecute() 0 23 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Tests\Cli;
6
7
use App\Tests\Support\ApplicationDataProvider;
8
use App\Tests\Support\UnitTester;
9
use Symfony\Component\Console\Application;
10
use Symfony\Component\Console\CommandLoader\ContainerCommandLoader;
11
use Symfony\Component\Console\Tester\CommandTester;
12
use Yiisoft\Yii\Console\ExitCode;
13
14
final class HelloCommandCest
15
{
16
    public function testExecute(UnitTester $I): void
17
    {
18
        $app = new Application();
19
        $params = ApplicationDataProvider::getConsoleConfig()->get('params-console');
20
21
        $loader = new ContainerCommandLoader(
22
            ApplicationDataProvider::getConsoleContainer(),
23
            $params['yiisoft/yii-console']['commands']
24
        );
25
26
        $app->setCommandLoader($loader);
27
28
        $command = $app->find('hello');
29
30
        $commandCreate = new CommandTester($command);
31
32
        $commandCreate->setInputs(['yes']);
33
34
        $I->assertSame(ExitCode::OK, $commandCreate->execute([]));
35
36
        $output = $commandCreate->getDisplay(true);
37
38
        $I->assertStringContainsString('Hello!', $output);
39
    }
40
}
41