@@ -219,61 +219,73 @@ public function testSetLocaleRenderLocalizedComponent(): void
219219 $ this ->assertStringContainsString ('Locale: de ' , $ testComponent ->render ());
220220 }
221221
222- public function testComponentEmitsExpectedEventWithExpectedEventData (): void
222+ public function testComponentEmitsExpectedEventData (): void
223223 {
224224 $ testComponent = $ this ->createLiveComponent ('component_with_emit ' );
225225
226226 $ testComponent ->call ('actionThatEmits ' );
227227
228- $ this ->assertComponentEmitEvent ($ testComponent , 'event1 ' , [
228+ $ this ->assertComponentEmitEvent ($ testComponent , 'event1 ' )-> withData ( [
229229 'foo ' => 'bar ' ,
230+ 'bar ' => 'foo ' ,
230231 ]);
231232 }
232233
233- public function testComponentDoesNotEmitUnexpectedEvent (): void
234+ public function testComponentEmitsExpectedEventDataFails (): void
234235 {
235236 $ testComponent = $ this ->createLiveComponent ('component_with_emit ' );
236237
237238 $ testComponent ->call ('actionThatEmits ' );
238239
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+ ]);
240245 }
241246
242- public function testComponentDoesNotEmitUnexpectedEventFails (): void
247+ public function testComponentEmitsExpectedPartialEventData (): void
243248 {
244249 $ testComponent = $ this ->createLiveComponent ('component_with_emit ' );
245250
246251 $ testComponent ->call ('actionThatEmits ' );
247252
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 ' );
251265 }
252266
253- public function testComponentEmitsEventWithNotFoundExpectedDataFails (): void
267+ public function testComponentDoesNotEmitUnexpectedEventFails (): void
254268 {
255269 $ testComponent = $ this ->createLiveComponent ('component_with_emit ' );
256270
257271 $ testComponent ->call ('actionThatEmits ' );
258272
259273 $ 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 ' );
265276 }
266277
267- public function testComponentEmitsEventWithNotValidExpectedDataFails (): void
278+ public function testComponentEmitsEventWithIncorrectDataFails (): void
268279 {
269280 $ testComponent = $ this ->createLiveComponent ('component_with_emit ' );
270281
271282 $ testComponent ->call ('actionThatEmits ' );
272283
273284 $ 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 ' ,
277289 ]);
278290 }
279291}
0 commit comments