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