|
59 | 59 | $this->makeFilePath('/app/Http/Resources/ResourcesDataDataResource.php'), |
60 | 60 | $this->makeFilePath('/app/Http/Resources/ResourceRootResource.php'), |
61 | 61 |
|
| 62 | + $this->makeFilePath('/app/Http/Controllers/Controller11.php'), |
| 63 | + $this->makeFilePath('/app/Http/Controllers/Controller2.php'), |
| 64 | + $this->makeFilePath('/app/Http/Controllers/FooItemsController.php'), |
| 65 | + $this->makeFilePath('/app/Http/Controllers/FoosController.php'), |
62 | 66 | $this->makeFilePath('/app/Http/Controllers/PoliciesController.php'), |
63 | 67 | $this->makeFilePath('/app/Http/Tests/PoliciesComponentTest.php'), |
64 | 68 | $this->makeFilePath('/app/Http/Policies/PoliciesControllerPolicy.php'), |
|
120 | 124 | 'WithoutResponsesController function parameter' |
121 | 125 | ); |
122 | 126 | }); |
| 127 | + |
| 128 | + |
| 129 | +test('namespace sorting', function () { |
| 130 | + /** @var TestCase $this */ |
| 131 | + $mapping = Config::get('openapi-server-generator.api_docs_mappings'); |
| 132 | + $mappingValue = current($mapping); |
| 133 | + $mapping = [$this->makeFilePath(__DIR__ . '/resources/index.yaml') => $mappingValue]; |
| 134 | + Config::set('openapi-server-generator.api_docs_mappings', $mapping); |
| 135 | + |
| 136 | + $filesystem = $this->mock(Filesystem::class); |
| 137 | + $filesystem->shouldReceive('exists')->andReturn(false); |
| 138 | + $filesystem->shouldReceive('get')->withArgs(function ($path) { |
| 139 | + return (bool)strstr($path, '.template'); |
| 140 | + })->andReturnUsing(function ($path) { |
| 141 | + return file_get_contents($path); |
| 142 | + }); |
| 143 | + $filesystem->shouldReceive('cleanDirectory', 'ensureDirectoryExists'); |
| 144 | + $routes = ''; |
| 145 | + $filesystem->shouldReceive('put')->withArgs(function ($path, $content) use (&$routes, &$rr) { |
| 146 | + if (str_contains($path, 'routes.php')) { |
| 147 | + $routes = $content; |
| 148 | + } |
| 149 | + |
| 150 | + return true; |
| 151 | + }); |
| 152 | + |
| 153 | + artisan(GenerateServer::class, ['-e' => 'routes']); |
| 154 | + |
| 155 | + assertStringContainsString( |
| 156 | + "use App\Http\Controllers\Controller11;\n". |
| 157 | + "use App\Http\Controllers\Controller2;\n". |
| 158 | + "use App\Http\Controllers\FooItemsController;\n". |
| 159 | + "use App\Http\Controllers\FoosController;\n", |
| 160 | + $routes |
| 161 | + ); |
| 162 | +}); |
0 commit comments