| 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 MakeModuleCommandTest extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     private const ENTRY_POINT = __DIR__ . '/../../../'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |      * @dataProvider createModulesProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     public function test_make_module(string $fileName, string $shortName): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         DirectoryUtil::removeDir(self::ENTRY_POINT . 'src/TestModule'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         $command = sprintf('%sgacela make:module %s Gacela/TestModule', self::ENTRY_POINT, $shortName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         exec($command, $output); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         self::assertSame("> Path 'src/TestModule/{$fileName}Facade.php' created successfully", $output[0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         self::assertSame("> Path 'src/TestModule/{$fileName}Factory.php' created successfully", $output[1]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         self::assertSame("> Path 'src/TestModule/{$fileName}Config.php' created successfully", $output[2]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         self::assertSame("> Path 'src/TestModule/{$fileName}DependencyProvider.php' created successfully", $output[3]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         self::assertSame("Module 'TestModule' created successfully", $output[4]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         self::assertFileExists(self::ENTRY_POINT . "src/TestModule/{$fileName}Facade.php"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         self::assertFileExists(self::ENTRY_POINT . "src/TestModule/{$fileName}Factory.php"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         self::assertFileExists(self::ENTRY_POINT . "src/TestModule/{$fileName}Config.php"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         self::assertFileExists(self::ENTRY_POINT . "src/TestModule/{$fileName}DependencyProvider.php"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         DirectoryUtil::removeDir(self::ENTRY_POINT . 'src/TestModule'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         self::assertDirectoryDoesNotExist(self::ENTRY_POINT . 'src/TestModule'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |     public function createModulesProvider(): iterable | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |         yield 'module' => ['TestModule', '']; | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |         yield 'module -s' => ['', '-s']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 44 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 45 |  |  |  |