| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace GacelaTest\Feature\Framework\UsingGacelaFileFromCustomEnv; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Gacela\Framework\Bootstrap\GacelaConfig; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Gacela\Framework\Gacela; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use PHPUnit\Framework\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | final class FeatureTest extends TestCase | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 12 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  |     public function tearDown(): void | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |         # Remove the APP_ENV | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |         putenv('APP_ENV'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     public function test_load_gacela_default_file(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         $this->bootstrapGacela(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         $facade = new LocalConfig\Facade(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         self::assertSame( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |                 'default_key' => 'from:default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |                 'key' => 'from:default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |             $facade->doSomething(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     public function test_load_gacela_dev_file(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         putenv('APP_ENV=dev'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $this->bootstrapGacela(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $facade = new LocalConfig\Facade(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         self::assertSame( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |                 'default_key' => 'from:default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |                 'key' => 'from:dev', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |             $facade->doSomething(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     public function test_load_gacela_prod_file(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         putenv('APP_ENV=prod'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $this->bootstrapGacela(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $facade = new LocalConfig\Facade(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         self::assertSame( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |                 'default_key' => 'from:default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |                 'key' => 'from:prod', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |             $facade->doSomething(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     public function test_load_gacela_default_file_if_custom_does_not_exists(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         putenv('APP_ENV=custom'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         $this->bootstrapGacela(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         $facade = new LocalConfig\Facade(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         self::assertSame( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |                 'default_key' => 'from:default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |                 'key' => 'from:default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |             $facade->doSomething(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     private function bootstrapGacela(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         Gacela::bootstrap(__DIR__, static function (GacelaConfig $config): void { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |             $config->resetInMemoryCache(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 91 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 92 |  |  |  |