|
7 | 7 | use Illuminate\Foundation\Auth\User;
|
8 | 8 | use Illuminate\Http\Resources\Json\JsonResource;
|
9 | 9 | use Illuminate\Support\Collection;
|
| 10 | +use Illuminate\Testing\Fluent\AssertableJson; |
10 | 11 | use Inertia\Inertia;
|
11 | 12 | use Inertia\Testing\Assert;
|
12 | 13 | use Inertia\Tests\TestCase;
|
|
15 | 16 |
|
16 | 17 | class AssertTest extends TestCase
|
17 | 18 | {
|
18 |
| - /** @test */ |
19 |
| - public function the_view_is_served_by_inertia(): void |
| 19 | + public function setUp(): void |
20 | 20 | {
|
21 |
| - $response = $this->makeMockRequest( |
22 |
| - Inertia::render('foo') |
23 |
| - ); |
| 21 | + parent::setUp(); |
24 | 22 |
|
25 |
| - $response->assertInertia(); |
26 |
| - } |
27 |
| - |
28 |
| - /** @test */ |
29 |
| - public function the_view_is_not_served_by_inertia(): void |
30 |
| - { |
31 |
| - $response = $this->makeMockRequest(view('welcome')); |
32 |
| - $response->assertOk(); // Make sure we can render the built-in Orchestra 'welcome' view.. |
33 |
| - |
34 |
| - $this->expectException(AssertionFailedError::class); |
35 |
| - $this->expectExceptionMessage('Not a valid Inertia response.'); |
36 |
| - |
37 |
| - $response->assertInertia(); |
38 |
| - } |
39 |
| - |
40 |
| - /** @test */ |
41 |
| - public function the_component_matches(): void |
42 |
| - { |
43 |
| - $response = $this->makeMockRequest( |
44 |
| - Inertia::render('foo') |
45 |
| - ); |
46 |
| - |
47 |
| - $response->assertInertia(function (Assert $inertia) { |
48 |
| - $inertia->component('foo'); |
49 |
| - }); |
50 |
| - } |
51 |
| - |
52 |
| - /** @test */ |
53 |
| - public function the_component_does_not_match(): void |
54 |
| - { |
55 |
| - $response = $this->makeMockRequest( |
56 |
| - Inertia::render('foo') |
57 |
| - ); |
58 |
| - |
59 |
| - $this->expectException(AssertionFailedError::class); |
60 |
| - $this->expectExceptionMessage('Unexpected Inertia page component.'); |
61 |
| - |
62 |
| - $response->assertInertia(function (Assert $inertia) { |
63 |
| - $inertia->component('bar'); |
64 |
| - }); |
65 |
| - } |
66 |
| - |
67 |
| - /** @test */ |
68 |
| - public function the_component_exists_on_the_filesystem(): void |
69 |
| - { |
70 |
| - $response = $this->makeMockRequest( |
71 |
| - Inertia::render('Stubs/ExamplePage') |
72 |
| - ); |
73 |
| - |
74 |
| - config()->set('inertia.testing.ensure_pages_exist', true); |
75 |
| - $response->assertInertia(function (Assert $inertia) { |
76 |
| - $inertia->component('Stubs/ExamplePage'); |
77 |
| - }); |
78 |
| - } |
79 |
| - |
80 |
| - /** @test */ |
81 |
| - public function the_component_does_not_exist_on_the_filesystem(): void |
82 |
| - { |
83 |
| - $response = $this->makeMockRequest( |
84 |
| - Inertia::render('foo') |
85 |
| - ); |
86 |
| - |
87 |
| - config()->set('inertia.testing.ensure_pages_exist', true); |
88 |
| - $this->expectException(AssertionFailedError::class); |
89 |
| - $this->expectExceptionMessage('Inertia page component file [foo] does not exist.'); |
90 |
| - |
91 |
| - $response->assertInertia(function (Assert $inertia) { |
92 |
| - $inertia->component('foo'); |
93 |
| - }); |
94 |
| - } |
95 |
| - |
96 |
| - /** @test */ |
97 |
| - public function it_can_force_enable_the_component_file_existence(): void |
98 |
| - { |
99 |
| - $response = $this->makeMockRequest( |
100 |
| - Inertia::render('foo') |
101 |
| - ); |
102 |
| - |
103 |
| - config()->set('inertia.testing.ensure_pages_exist', false); |
104 |
| - $this->expectException(AssertionFailedError::class); |
105 |
| - $this->expectExceptionMessage('Inertia page component file [foo] does not exist.'); |
106 |
| - |
107 |
| - $response->assertInertia(function (Assert $inertia) { |
108 |
| - $inertia->component('foo', true); |
109 |
| - }); |
110 |
| - } |
111 |
| - |
112 |
| - /** @test */ |
113 |
| - public function it_can_force_disable_the_component_file_existence_check(): void |
114 |
| - { |
115 |
| - $response = $this->makeMockRequest( |
116 |
| - Inertia::render('foo') |
117 |
| - ); |
118 |
| - |
119 |
| - config()->set('inertia.testing.ensure_pages_exist', true); |
120 |
| - |
121 |
| - $response->assertInertia(function (Assert $inertia) { |
122 |
| - $inertia->component('foo', false); |
123 |
| - }); |
124 |
| - } |
125 |
| - |
126 |
| - /** @test */ |
127 |
| - public function the_component_does_not_exist_on_the_filesystem_when_it_does_not_exist_relative_to_any_of_the_given_paths(): void |
128 |
| - { |
129 |
| - $response = $this->makeMockRequest( |
130 |
| - Inertia::render('fixtures/ExamplePage') |
131 |
| - ); |
132 |
| - |
133 |
| - config()->set('inertia.testing.ensure_pages_exist', true); |
134 |
| - config()->set('inertia.testing.page_paths', [realpath(__DIR__)]); |
135 |
| - $this->expectException(AssertionFailedError::class); |
136 |
| - $this->expectExceptionMessage('Inertia page component file [fixtures/ExamplePage] does not exist.'); |
137 |
| - |
138 |
| - $response->assertInertia(function (Assert $inertia) { |
139 |
| - $inertia->component('fixtures/ExamplePage'); |
140 |
| - }); |
141 |
| - } |
142 |
| - |
143 |
| - /** @test */ |
144 |
| - public function the_component_does_not_exist_on_the_filesystem_when_it_does_not_have_one_of_the_configured_extensions(): void |
145 |
| - { |
146 |
| - $response = $this->makeMockRequest( |
147 |
| - Inertia::render('fixtures/ExamplePage') |
148 |
| - ); |
149 |
| - |
150 |
| - config()->set('inertia.testing.ensure_pages_exist', true); |
151 |
| - config()->set('inertia.testing.page_extensions', ['bin', 'exe', 'svg']); |
152 |
| - $this->expectException(AssertionFailedError::class); |
153 |
| - $this->expectExceptionMessage('Inertia page component file [fixtures/ExamplePage] does not exist.'); |
154 |
| - |
155 |
| - $response->assertInertia(function (Assert $inertia) { |
156 |
| - $inertia->component('fixtures/ExamplePage'); |
157 |
| - }); |
| 23 | + if (class_exists(AssertableJson::class)) { |
| 24 | + $this->markTestSkipped("These tests are not applicable on Laravel 8.32 or newer, as Laravel's built-in AssertableJson is used instead."); |
| 25 | + } |
158 | 26 | }
|
159 | 27 |
|
160 | 28 | /** @test */
|
@@ -1202,64 +1070,6 @@ public function it_cannot_count_multiple_props_at_once_when_at_least_one_is_miss
|
1202 | 1070 | });
|
1203 | 1071 | }
|
1204 | 1072 |
|
1205 |
| - /** @test */ |
1206 |
| - public function the_page_url_matches(): void |
1207 |
| - { |
1208 |
| - $response = $this->makeMockRequest( |
1209 |
| - Inertia::render('foo') |
1210 |
| - ); |
1211 |
| - |
1212 |
| - $response->assertInertia(function (Assert $inertia) { |
1213 |
| - $inertia->url('/example-url'); |
1214 |
| - }); |
1215 |
| - } |
1216 |
| - |
1217 |
| - /** @test */ |
1218 |
| - public function the_page_url_does_not_match(): void |
1219 |
| - { |
1220 |
| - $response = $this->makeMockRequest( |
1221 |
| - Inertia::render('foo') |
1222 |
| - ); |
1223 |
| - |
1224 |
| - $this->expectException(AssertionFailedError::class); |
1225 |
| - $this->expectExceptionMessage('Unexpected Inertia page url.'); |
1226 |
| - |
1227 |
| - $response->assertInertia(function (Assert $inertia) { |
1228 |
| - $inertia->url('/invalid-page'); |
1229 |
| - }); |
1230 |
| - } |
1231 |
| - |
1232 |
| - /** @test */ |
1233 |
| - public function the_asset_version_matches(): void |
1234 |
| - { |
1235 |
| - Inertia::version('example-version'); |
1236 |
| - |
1237 |
| - $response = $this->makeMockRequest( |
1238 |
| - Inertia::render('foo') |
1239 |
| - ); |
1240 |
| - |
1241 |
| - $response->assertInertia(function (Assert $inertia) { |
1242 |
| - $inertia->version('example-version'); |
1243 |
| - }); |
1244 |
| - } |
1245 |
| - |
1246 |
| - /** @test */ |
1247 |
| - public function the_asset_version_does_not_match(): void |
1248 |
| - { |
1249 |
| - Inertia::version('example-version'); |
1250 |
| - |
1251 |
| - $response = $this->makeMockRequest( |
1252 |
| - Inertia::render('foo') |
1253 |
| - ); |
1254 |
| - |
1255 |
| - $this->expectException(AssertionFailedError::class); |
1256 |
| - $this->expectExceptionMessage('Unexpected Inertia asset version.'); |
1257 |
| - |
1258 |
| - $response->assertInertia(function (Assert $inertia) { |
1259 |
| - $inertia->version('different-version'); |
1260 |
| - }); |
1261 |
| - } |
1262 |
| - |
1263 | 1073 | /** @test */
|
1264 | 1074 | public function it_is_macroable(): void
|
1265 | 1075 | {
|
|
0 commit comments