@@ -54,7 +54,7 @@ public function testCanRenderComponentAsHtml(): void
54
54
55
55
$ this ->browser ()
56
56
->throwExceptions ()
57
- ->get ('/_components/component1? ' . http_build_query ( $ dehydrated ))
57
+ ->get ('/_components/component1?data= ' . urlencode ( json_encode ( $ dehydrated) ))
58
58
->assertSuccessful ()
59
59
->assertHeaderContains ('Content-Type ' , 'html ' )
60
60
->assertContains ('Prop1: ' .$ entity ->id )
@@ -80,16 +80,17 @@ public function testCanExecuteComponentAction(): void
80
80
81
81
$ this ->browser ()
82
82
->throwExceptions ()
83
- ->get ('/_components/component2? ' . http_build_query ( $ dehydrated ))
83
+ ->get ('/_components/component2?data= ' . urlencode ( json_encode ( $ dehydrated) ))
84
84
->assertSuccessful ()
85
85
->assertHeaderContains ('Content-Type ' , 'html ' )
86
86
->assertContains ('Count: 1 ' )
87
87
->use (function (HtmlResponse $ response ) use (&$ token ) {
88
88
// get a valid token to use for actions
89
89
$ token = $ response ->crawler ()->filter ('div ' )->first ()->attr ('data-live-csrf-value ' );
90
90
})
91
- ->post ('/_components/component2/increase? ' . http_build_query ( $ dehydrated ) , [
91
+ ->post ('/_components/component2/increase ' , [
92
92
'headers ' => ['X-CSRF-TOKEN ' => $ token ],
93
+ 'body ' => json_encode ($ dehydrated ),
93
94
])
94
95
->assertSuccessful ()
95
96
->assertHeaderContains ('Content-Type ' , 'html ' )
@@ -168,7 +169,7 @@ public function testBeforeReRenderHookOnlyExecutedDuringAjax(): void
168
169
->visit ('/render-template/template1 ' )
169
170
->assertSuccessful ()
170
171
->assertSee ('BeforeReRenderCalled: No ' )
171
- ->get ('/_components/component2? ' . http_build_query ( $ dehydrated ))
172
+ ->get ('/_components/component2?data= ' . urlencode ( json_encode ( $ dehydrated) ))
172
173
->assertSuccessful ()
173
174
->assertSee ('BeforeReRenderCalled: Yes ' )
174
175
;
@@ -190,25 +191,27 @@ public function testCanRedirectFromComponentAction(): void
190
191
191
192
$ this ->browser ()
192
193
->throwExceptions ()
193
- ->get ('/_components/component2? ' . http_build_query ( $ dehydrated ))
194
+ ->get ('/_components/component2?data= ' . urlencode ( json_encode ( $ dehydrated) ))
194
195
->assertSuccessful ()
195
196
->use (function (HtmlResponse $ response ) use (&$ token ) {
196
197
// get a valid token to use for actions
197
198
$ token = $ response ->crawler ()->filter ('div ' )->first ()->attr ('data-live-csrf-value ' );
198
199
})
199
200
->interceptRedirects ()
200
201
// with no custom header, it redirects like a normal browser
201
- ->post ('/_components/component2/redirect? ' . http_build_query ( $ dehydrated ) , [
202
+ ->post ('/_components/component2/redirect ' , [
202
203
'headers ' => ['X-CSRF-TOKEN ' => $ token ],
204
+ 'body ' => json_encode ($ dehydrated ),
203
205
])
204
206
->assertRedirectedTo ('/ ' )
205
207
206
208
// with custom header, a special 204 is returned
207
- ->post ('/_components/component2/redirect? ' . http_build_query ( $ dehydrated ) , [
209
+ ->post ('/_components/component2/redirect ' , [
208
210
'headers ' => [
209
211
'Accept ' => 'application/vnd.live-component+html ' ,
210
212
'X-CSRF-TOKEN ' => $ token ,
211
213
],
214
+ 'body ' => json_encode ($ dehydrated ),
212
215
])
213
216
->assertStatus (204 )
214
217
->assertHeaderEquals ('Location ' , '/ ' )
@@ -229,13 +232,10 @@ public function testInjectsLiveArgs(): void
229
232
$ dehydrated = $ hydrator ->dehydrate ($ component );
230
233
$ token = null ;
231
234
232
- $ dehydratedWithArgs = array_merge ($ dehydrated , [
233
- 'args ' => http_build_query (['arg1 ' => 'hello ' , 'arg2 ' => 666 , 'custom ' => '33.3 ' ]),
234
- ]);
235
-
235
+ $ argsQueryParams = http_build_query (['args ' => http_build_query (['arg1 ' => 'hello ' , 'arg2 ' => 666 , 'custom ' => '33.3 ' ])]);
236
236
$ this ->browser ()
237
237
->throwExceptions ()
238
- ->get ('/_components/component6? ' . http_build_query ( $ dehydrated ))
238
+ ->get ('/_components/component6?data= ' . urlencode ( json_encode ( $ dehydrated )). ' & ' . $ argsQueryParams )
239
239
->assertSuccessful ()
240
240
->assertHeaderContains ('Content-Type ' , 'html ' )
241
241
->assertContains ('Arg1: not provided ' )
@@ -245,8 +245,9 @@ public function testInjectsLiveArgs(): void
245
245
// get a valid token to use for actions
246
246
$ token = $ response ->crawler ()->filter ('div ' )->first ()->attr ('data-live-csrf-value ' );
247
247
})
248
- ->post ('/_components/component6/inject? ' .http_build_query ( $ dehydratedWithArgs ) , [
248
+ ->post ('/_components/component6/inject? ' .$ argsQueryParams , [
249
249
'headers ' => ['X-CSRF-TOKEN ' => $ token ],
250
+ 'body ' => json_encode ($ dehydrated ),
250
251
])
251
252
->assertSuccessful ()
252
253
->assertHeaderContains ('Content-Type ' , 'html ' )
0 commit comments