Skip to content

Commit a6e4e8e

Browse files
committed
document assert listening
1 parent f2a24c4 commit a6e4e8e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

mocking.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ When testing code that dispatches events, you may wish to instruct Laravel to no
254254

255255
// Assert an event was not dispatched...
256256
Event::assertNotDispatched(OrderFailedToShip::class);
257-
257+
258258
// Assert that no events were dispatched...
259259
Event::assertNothingDispatched();
260260
}
@@ -266,6 +266,13 @@ You may pass a closure to the `assertDispatched` or `assertNotDispatched` method
266266
return $event->order->id === $order->id;
267267
});
268268

269+
If you would simply like to assert that an event listener is listening to a given event, you may use the `assertListening` method:
270+
271+
Event::assertListening(
272+
OrderShipped::class,
273+
[SendShipmentNotification::class, 'handle']
274+
);
275+
269276
> {note} After calling `Event::fake()`, no event listeners will be executed. So, if your tests use model factories that rely on events, such as creating a UUID during a model's `creating` event, you should call `Event::fake()` **after** using your factories.
270277
271278
<a name="faking-a-subset-of-events"></a>

0 commit comments

Comments
 (0)