Hi!
I have a Livewire component that dispatches a Laravel Event from an action. The Listener is implementing ShouldQueue. This is working fine when manually testing, but when testing with PHPunit, the event is not fired.
The test fails with the following error: The expected [App\Events\ProductVideosChanged] event was not dispatched.
Livewire Component:
public function deleteVideo($videoId)
{
$video = ProductVideo::where('id', $videoId)->first();
$video->delete();
$this->refreshVideos();
event(new ProductVideosChanged($this->product));
}
EventServiceProvider.php
protected $listen = [
ProductVideosChanged::class => [
SyncProductVideos::class,
],
];
ProductVideoTest.php
/** @test */
public function it_can_delete_product_video()
{
// ...
Event::fake();
Event::assertDispatched(ProductVideosChanged::class);
}
Why is the event not dispatched in the test?