Passed
Push — master ( 724f51...d895e0 )
by Alexander
02:14
created

HelloCommandCest::testExecute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 12
nc 1
nop 1
dl 0
loc 23
c 0
b 0
f 0
cc 1
rs 9.8666
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