55use Illuminate \Filesystem \Filesystem ;
66use Illuminate \Support \Facades \Config ;
77use function Pest \Laravel \artisan ;
8- use function PHPUnit \Framework \assertEquals ;
8+ use function PHPUnit \Framework \assertEqualsCanonicalizing ;
99
10- function makeFilePath (string $ path ): string
11- {
12- return str_replace ('/ ' , DIRECTORY_SEPARATOR , $ path );
13- }
1410test ("Command GenerateServer success " , function () {
1511 /** @var TestCase $this */
1612 $ mapping = Config::get ('openapi-server-generator.api_docs_mappings ' );
1713 $ mappingValue = current ($ mapping );
18- $ mapping = [makeFilePath (__DIR__ . '/resources/index.yaml ' ) => $ mappingValue ];
14+ $ mapping = [$ this -> makeFilePath (__DIR__ . '/resources/index.yaml ' ) => $ mappingValue ];
1915 Config::set ('openapi-server-generator.api_docs_mappings ' , $ mapping );
2016
2117 $ filesystem = $ this ->mock (Filesystem::class);
@@ -26,34 +22,31 @@ function makeFilePath(string $path): string
2622 return file_get_contents ($ path );
2723 });
2824 $ filesystem ->shouldReceive ('cleanDirectory ' , 'ensureDirectoryExists ' );
29- $ appRoot = realpath (makeFilePath (__DIR__ . '/../vendor/orchestra/testbench-core/laravel/ ' ));
25+ $ appRoot = realpath ($ this -> makeFilePath (__DIR__ . '/../vendor/orchestra/testbench-core/laravel/ ' ));
3026 $ putFiles = [];
3127 $ filesystem ->shouldReceive ('put ' )->withArgs (function ($ path , $ content ) use (&$ putFiles , $ appRoot ) {
32- $ putFiles [] = makeFilePath (str_replace ($ appRoot , '' , $ path ));
28+ $ putFiles [] = $ this -> makeFilePath (str_replace ($ appRoot , '' , $ path ));
3329
3430 return true ;
3531 });
3632
3733 artisan (GenerateServer::class);
3834
39- $ needFiles = [
40- makeFilePath ('/app/Http/ApiV1/OpenApiGenerated/routes.php ' ),
35+ assertEqualsCanonicalizing ( [
36+ $ this -> makeFilePath ('/app/Http/ApiV1/OpenApiGenerated/routes.php ' ),
4137
42- makeFilePath ('/app/Http/Controllers/ResourcesController.php ' ),
43- makeFilePath ('/app/Http/Requests/TestFullGenerateRequest.php ' ),
44- makeFilePath ('/app/Http/Tests/ResourcesComponentTest.php ' ),
45- makeFilePath ('/app/Http/Requests/TestFooRenameRequest.php ' ),
38+ $ this -> makeFilePath ('/app/Http/Controllers/ResourcesController.php ' ),
39+ $ this -> makeFilePath ('/app/Http/Requests/TestFullGenerateRequest.php ' ),
40+ $ this -> makeFilePath ('/app/Http/Tests/ResourcesComponentTest.php ' ),
41+ $ this -> makeFilePath ('/app/Http/Requests/TestFooRenameRequest.php ' ),
4642
47- makeFilePath ('/app/Http/Controllers/WithoutResponsesController.php ' ),
43+ $ this -> makeFilePath ('/app/Http/Controllers/WithoutResponsesController.php ' ),
4844
49- makeFilePath ('/WithoutNamespaceController.php ' ),
50- makeFilePath ('/WithoutNamespaceRequest.php ' ),
51- makeFilePath ('/WithoutNamespaceComponentTest.php ' ),
45+ $ this -> makeFilePath ('/WithoutNamespaceController.php ' ),
46+ $ this -> makeFilePath ('/WithoutNamespaceRequest.php ' ),
47+ $ this -> makeFilePath ('/WithoutNamespaceComponentTest.php ' ),
5248
53- makeFilePath ('/app/Http/ApiV1/OpenApiGenerated/Enums/TestIntegerEnum.php ' ),
54- makeFilePath ('/app/Http/ApiV1/OpenApiGenerated/Enums/TestStringEnum.php ' ),
55- ];
56- sort ($ needFiles );
57- sort ($ putFiles );
58- assertEquals ($ needFiles , $ putFiles );
49+ $ this ->makeFilePath ('/app/Http/ApiV1/OpenApiGenerated/Enums/TestIntegerEnum.php ' ),
50+ $ this ->makeFilePath ('/app/Http/ApiV1/OpenApiGenerated/Enums/TestStringEnum.php ' ),
51+ ], $ putFiles );
5952});
0 commit comments