@@ -219,61 +219,73 @@ public function testSetLocaleRenderLocalizedComponent(): void
219
219
$ this ->assertStringContainsString ('Locale: de ' , $ testComponent ->render ());
220
220
}
221
221
222
- public function testComponentEmitsExpectedEventWithExpectedEventData (): void
222
+ public function testComponentEmitsExpectedEventData (): void
223
223
{
224
224
$ testComponent = $ this ->createLiveComponent ('component_with_emit ' );
225
225
226
226
$ testComponent ->call ('actionThatEmits ' );
227
227
228
- $ this ->assertComponentEmitEvent ($ testComponent , 'event1 ' , [
228
+ $ this ->assertComponentEmitEvent ($ testComponent , 'event1 ' )-> withData ( [
229
229
'foo ' => 'bar ' ,
230
+ 'bar ' => 'foo ' ,
230
231
]);
231
232
}
232
233
233
- public function testComponentDoesNotEmitUnexpectedEvent (): void
234
+ public function testComponentEmitsExpectedEventDataFails (): void
234
235
{
235
236
$ testComponent = $ this ->createLiveComponent ('component_with_emit ' );
236
237
237
238
$ testComponent ->call ('actionThatEmits ' );
238
239
239
- $ this ->assertComponentNotEmitEvent ($ testComponent , 'event2 ' );
240
+ $ this ->expectException (AssertionFailedError::class);
241
+ $ this ->expectExceptionMessage ('The expected event "event1" data does not match ' );
242
+ $ this ->assertComponentEmitEvent ($ testComponent , 'event1 ' )->withData ([
243
+ 'foo ' => 'bar ' ,
244
+ ]);
240
245
}
241
246
242
- public function testComponentDoesNotEmitUnexpectedEventFails (): void
247
+ public function testComponentEmitsExpectedPartialEventData (): void
243
248
{
244
249
$ testComponent = $ this ->createLiveComponent ('component_with_emit ' );
245
250
246
251
$ testComponent ->call ('actionThatEmits ' );
247
252
248
- $ this ->expectException (AssertionFailedError::class);
249
- $ this ->expectExceptionMessage ('The component "component_with_emit" did not emit event "event1". ' );
250
- $ this ->assertComponentNotEmitEvent ($ testComponent , 'event1 ' );
253
+ $ this ->assertComponentEmitEvent ($ testComponent , 'event1 ' )->withDataSubset ([
254
+ 'foo ' => 'bar ' ,
255
+ ]);
256
+ }
257
+
258
+ public function testComponentDoesNotEmitUnexpectedEvent (): void
259
+ {
260
+ $ testComponent = $ this ->createLiveComponent ('component_with_emit ' );
261
+
262
+ $ testComponent ->call ('actionThatEmits ' );
263
+
264
+ $ this ->assertComponentNotEmitEvent ($ testComponent , 'event2 ' );
251
265
}
252
266
253
- public function testComponentEmitsEventWithNotFoundExpectedDataFails (): void
267
+ public function testComponentDoesNotEmitUnexpectedEventFails (): void
254
268
{
255
269
$ testComponent = $ this ->createLiveComponent ('component_with_emit ' );
256
270
257
271
$ testComponent ->call ('actionThatEmits ' );
258
272
259
273
$ this ->expectException (AssertionFailedError::class);
260
- $ this ->expectExceptionMessage ('The expected event "event1" data "foo2" does not exists ' );
261
- $ this ->assertComponentEmitEvent ($ testComponent , 'event1 ' , [
262
- 'foo ' => 'bar ' ,
263
- 'foo2 ' => 'bar2 ' ,
264
- ]);
274
+ $ this ->expectExceptionMessage ('The component "component_with_emit" did not emit event "event1". ' );
275
+ $ this ->assertComponentNotEmitEvent ($ testComponent , 'event1 ' );
265
276
}
266
277
267
- public function testComponentEmitsEventWithNotValidExpectedDataFails (): void
278
+ public function testComponentEmitsEventWithIncorrectDataFails (): void
268
279
{
269
280
$ testComponent = $ this ->createLiveComponent ('component_with_emit ' );
270
281
271
282
$ testComponent ->call ('actionThatEmits ' );
272
283
273
284
$ this ->expectException (AssertionFailedError::class);
274
- $ this ->expectExceptionMessage ('The expected event "event1" data "foo" expected "bar2" but "bar" given ' );
275
- $ this ->assertComponentEmitEvent ($ testComponent , 'event1 ' , [
276
- 'foo ' => 'bar2 ' ,
285
+ $ this ->expectExceptionMessage ('The expected event "event1" data does not match. ' );
286
+ $ this ->assertComponentEmitEvent ($ testComponent , 'event1 ' )->withData ([
287
+ 'foo ' => 'bar ' ,
288
+ 'foo2 ' => 'bar2 ' ,
277
289
]);
278
290
}
279
291
}
0 commit comments