Passed
Pull Request — master (#69)
by Jesús
02:44
created

MakeFileCommandTest::tearDownAfterClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GacelaTest\Feature\CodeGenerator;
6
7
use GacelaTest\Feature\Util\DirectoryUtil;
8
use PHPUnit\Framework\TestCase;
9
10
final class MakeFileCommandTest extends TestCase
11
{
12
    private const ENTRY_POINT = __DIR__ . '/../../../';
13
14
    public function setUp(): void
15
    {
16
        DirectoryUtil::removeDir(self::ENTRY_POINT . 'src/TestModule');
17
    }
18
19
    public static function tearDownAfterClass(): void
20
    {
21
        DirectoryUtil::removeDir(self::ENTRY_POINT . 'src/TestModule');
22
    }
23
24
    /**
25
     * @dataProvider createFilesProvider
26
     */
27
    public function test_make_file(string $action, string $fileName, string $shortName): void
28
    {
29
        $command = sprintf('%sgacela make:file %s Gacela/TestModule %s', self::ENTRY_POINT, $shortName, $action);
30
        exec($command, $output);
31
32
        self::assertSame("> Path 'src/TestModule/{$fileName}.php' created successfully", $output[0]);
33
        self::assertFileExists(self::ENTRY_POINT . "src/TestModule/{$fileName}.php");
34
    }
35
36
    public function createFilesProvider(): iterable
37
    {
38
        yield 'facade' => ['facade', 'TestModuleFacade', ''];
39
        yield 'factory' => ['factory', 'TestModuleFactory', ''];
40
        yield 'config' => ['config', 'TestModuleConfig', ''];
41
        yield 'dependency provider' => ['dependency-provider', 'TestModuleDependencyProvider', ''];
42
43
        // Sort name flag
44
        yield 'facade -s' => ['facade', 'Facade', '-s'];
45
        yield 'factory -s' => ['factory', 'Factory', '-s'];
46
        yield 'config -s' => ['config', 'Config', '-s'];
47
        yield 'dependency provider -s' => ['dependency-provider', 'DependencyProvider', '-s'];
48
    }
49
}
50