|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace GacelaTest\Feature\Console\ListModules; |
|
6
|
|
|
|
|
7
|
|
|
use Gacela\Console\Infrastructure\ConsoleBootstrap; |
|
8
|
|
|
use Gacela\Framework\Gacela; |
|
9
|
|
|
use PHPUnit\Framework\TestCase; |
|
10
|
|
|
use Symfony\Component\Console\Input\StringInput; |
|
11
|
|
|
use Symfony\Component\Console\Output\BufferedOutput; |
|
12
|
|
|
|
|
13
|
|
|
final class ListModulesCommandTest extends TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
public function test_list_modules(): void |
|
16
|
|
|
{ |
|
17
|
|
|
Gacela::bootstrap(__DIR__); |
|
18
|
|
|
|
|
19
|
|
|
$input = new StringInput('list:modules'); |
|
20
|
|
|
$output = new BufferedOutput(); |
|
21
|
|
|
|
|
22
|
|
|
$bootstrap = new ConsoleBootstrap(); |
|
23
|
|
|
$bootstrap->setAutoExit(false); |
|
24
|
|
|
$bootstrap->run($input, $output); |
|
25
|
|
|
|
|
26
|
|
|
$out = $output->fetch(); |
|
27
|
|
|
|
|
28
|
|
|
self::assertMatchesRegularExpression('#TestModule1.*ListModules\\\TestModule1#', $out); |
|
29
|
|
|
self::assertMatchesRegularExpression('#TestModule2.*ListModules\\\TestModule2#', $out); |
|
30
|
|
|
self::assertMatchesRegularExpression('#TestModule3.*ListModules\\\LevelUp\\\TestModule3#', $out); |
|
31
|
|
|
self::assertStringNotContainsString('vendor', $out); |
|
32
|
|
|
self::assertStringNotContainsString('ToBeIgnored', $out); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function test_list_modules_all(): void |
|
36
|
|
|
{ |
|
37
|
|
|
Gacela::bootstrap(__DIR__); |
|
38
|
|
|
|
|
39
|
|
|
$input = new StringInput('list:modules --all'); |
|
40
|
|
|
$output = new BufferedOutput(); |
|
41
|
|
|
|
|
42
|
|
|
$bootstrap = new ConsoleBootstrap(); |
|
43
|
|
|
$bootstrap->setAutoExit(false); |
|
44
|
|
|
$bootstrap->run($input, $output); |
|
45
|
|
|
|
|
46
|
|
|
$out = $output->fetch(); |
|
47
|
|
|
|
|
48
|
|
|
self::assertMatchesRegularExpression('#TestModule1.*ListModules\\\TestModule1#', $out); |
|
49
|
|
|
self::assertMatchesRegularExpression('#TestModule2.*ListModules\\\TestModule2#', $out); |
|
50
|
|
|
self::assertMatchesRegularExpression('#TestModule3.*ListModules\\\LevelUp\\\TestModule3#', $out); |
|
51
|
|
|
self::assertStringNotContainsString('vendor', $out); |
|
52
|
|
|
self::assertStringNotContainsString('ToBeIgnored', $out); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|