|
10 | 10 |
|
11 | 11 | afterEach(function () { |
12 | 12 | $files = [ |
13 | | - base_path('openapi.json'), |
14 | | - base_path('custom-output.json'), |
| 13 | + public_path('openapi.json'), |
| 14 | + public_path('custom-output.json'), |
15 | 15 | ]; |
16 | 16 |
|
17 | 17 | foreach ($files as $file) { |
|
27 | 27 | ->assertSuccessful() |
28 | 28 | ; |
29 | 29 |
|
30 | | - expect(base_path('openapi.json'))->not->toBeFile(); |
| 30 | + expect(public_path('openapi.json'))->not->toBeFile(); |
31 | 31 | }); |
32 | 32 |
|
33 | 33 | it('generates openapi.json with default output path', function () { |
34 | 34 | registerRoutes(); |
35 | 35 |
|
36 | 36 | $this->artisan('api-toolkit:openapi') |
37 | 37 | ->expectsOutputToContain('endpoint(s)') |
38 | | - ->expectsOutputToContain('OpenAPI spec written to openapi.json') |
| 38 | + ->expectsOutputToContain('OpenAPI spec written to') |
39 | 39 | ->assertSuccessful() |
40 | 40 | ; |
41 | 41 |
|
42 | | - expect(base_path('openapi.json'))->toBeFile(); |
| 42 | + expect(public_path('openapi.json'))->toBeFile(); |
43 | 43 |
|
44 | | - $content = json_decode(file_get_contents(base_path('openapi.json')), true); |
| 44 | + $content = json_decode(file_get_contents(public_path('openapi.json')), true); |
45 | 45 | expect($content['openapi'])->toBe('3.1.0'); |
46 | 46 | }); |
47 | 47 |
|
48 | 48 | it('generates to custom output path', function () { |
49 | 49 | registerRoutes(); |
50 | 50 |
|
51 | | - $this->artisan('api-toolkit:openapi', ['--output' => 'custom-output.json']) |
52 | | - ->expectsOutputToContain('OpenAPI spec written to custom-output.json') |
| 51 | + $customPath = public_path('custom-output.json'); |
| 52 | + |
| 53 | + $this->artisan('api-toolkit:openapi', ['--output' => $customPath]) |
| 54 | + ->expectsOutputToContain('OpenAPI spec written to') |
53 | 55 | ->assertSuccessful() |
54 | 56 | ; |
55 | 57 |
|
56 | | - expect(base_path('custom-output.json'))->toBeFile(); |
| 58 | + expect($customPath)->toBeFile(); |
57 | 59 |
|
58 | | - $content = json_decode(file_get_contents(base_path('custom-output.json')), true); |
| 60 | + $content = json_decode(file_get_contents($customPath), true); |
59 | 61 | expect($content['openapi'])->toBe('3.1.0'); |
60 | 62 | }); |
61 | 63 |
|
|
66 | 68 | ->assertSuccessful() |
67 | 69 | ; |
68 | 70 |
|
69 | | - $raw = file_get_contents(base_path('openapi.json')); |
| 71 | + $raw = file_get_contents(public_path('openapi.json')); |
70 | 72 | expect($raw)->toContain("\n"); |
71 | 73 | expect($raw)->toContain(' '); |
72 | 74 | }); |
|
78 | 80 | ->assertSuccessful() |
79 | 81 | ; |
80 | 82 |
|
81 | | - $raw = file_get_contents(base_path('openapi.json')); |
| 83 | + $raw = file_get_contents(public_path('openapi.json')); |
82 | 84 | expect($raw)->not->toContain("\n"); |
83 | 85 | }); |
84 | 86 |
|
|
100 | 102 | ->assertSuccessful() |
101 | 103 | ; |
102 | 104 |
|
103 | | - $content = json_decode(file_get_contents(base_path('openapi.json')), true); |
| 105 | + $content = json_decode(file_get_contents(public_path('openapi.json')), true); |
104 | 106 | expect($content['info']['title'])->toBe('My Custom API'); |
105 | 107 | expect($content['info']['version'])->toBe('2.5.0'); |
106 | 108 | expect($content['info']['description'])->toBe('Custom description'); |
|
119 | 121 | ->assertSuccessful() |
120 | 122 | ; |
121 | 123 |
|
122 | | - $content = json_decode(file_get_contents(base_path('openapi.json')), true); |
| 124 | + $content = json_decode(file_get_contents(public_path('openapi.json')), true); |
123 | 125 | expect($content['info']['title'])->toBe('Fallback App'); |
124 | 126 | }); |
125 | 127 |
|
|
0 commit comments