|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace GacelaTest\Feature\CodeGenerator; |
|
6
|
|
|
|
|
7
|
|
|
use GacelaTest\Feature\CodeGenerator\Util\DirectoryUtil; |
|
8
|
|
|
use PHPUnit\Framework\TestCase; |
|
9
|
|
|
|
|
10
|
|
|
final class MakeModuleCommandTest extends TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
private const ENTRY_POINT = __DIR__ . '/../../../'; |
|
13
|
|
|
|
|
14
|
|
|
public static function tearDownAfterClass(): void |
|
15
|
|
|
{ |
|
16
|
|
|
DirectoryUtil::removeDir(self::ENTRY_POINT . 'src/TestModule'); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function setUp(): void |
|
20
|
|
|
{ |
|
21
|
|
|
DirectoryUtil::removeDir(self::ENTRY_POINT . 'src/TestModule'); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @dataProvider createModulesProvider |
|
26
|
|
|
*/ |
|
27
|
|
|
public function test_make_module(string $fileName, string $shortName): void |
|
28
|
|
|
{ |
|
29
|
|
|
$command = sprintf('%sgacela make:module %s Gacela/TestModule', self::ENTRY_POINT, $shortName); |
|
30
|
|
|
exec($command, $output); |
|
31
|
|
|
|
|
32
|
|
|
self::assertSame("> Path 'src/TestModule/{$fileName}Facade.php' created successfully", $output[0]); |
|
33
|
|
|
self::assertSame("> Path 'src/TestModule/{$fileName}Factory.php' created successfully", $output[1]); |
|
34
|
|
|
self::assertSame("> Path 'src/TestModule/{$fileName}Config.php' created successfully", $output[2]); |
|
35
|
|
|
self::assertSame("> Path 'src/TestModule/{$fileName}DependencyProvider.php' created successfully", $output[3]); |
|
36
|
|
|
self::assertSame("Module 'TestModule' created successfully", $output[4]); |
|
37
|
|
|
|
|
38
|
|
|
self::assertFileExists(self::ENTRY_POINT . "src/TestModule/{$fileName}Facade.php"); |
|
39
|
|
|
self::assertFileExists(self::ENTRY_POINT . "src/TestModule/{$fileName}Factory.php"); |
|
40
|
|
|
self::assertFileExists(self::ENTRY_POINT . "src/TestModule/{$fileName}Config.php"); |
|
41
|
|
|
self::assertFileExists(self::ENTRY_POINT . "src/TestModule/{$fileName}DependencyProvider.php"); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function createModulesProvider(): iterable |
|
45
|
|
|
{ |
|
46
|
|
|
yield 'module' => ['TestModule', '']; |
|
47
|
|
|
yield 'module -s' => ['', '-s']; |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|