This one is throwing me for a bit of a loop and possible I missed something but here is the outline of what im facing.
I have a test that consists of the following:
Event::fake();
// setup db and expectations
$this->expectException(PatientAppointmentMeetingNotEnded::class);
// run tests
$mock = Mockery::mock(\App\AEQ\AWSChime::class);
$mock->shouldReceive('hasMeetingEnded')->andReturn(false);
$job = new \App\Jobs\ParseTranscription($this->meeting);
$job->handle($mock);
Event::assertNotDispatched(TranscriptionErrored::class);
Event::assertDispatched(TranscriptionErrored::class);
If you look at the assertNotDispatched and assertDispatched you can see that there is no way this test should pass (you cant not dispatch an event and not dispatch an event at the same time). The issue is that when running this test it passes. This leads me to believe that either I have some sort of misconfiguration of my app when it comes to events.
Even adding something like:
Event::shouldReceive('blahblah')
->once()
->andReturnNull();
Will return success. This is also true if I do not include the Event::fake(); call in the test. To be very clear I am dispatching events in the job I am testing as such Event::dispatch(new TranscriptionErrored($this->meeting, $e->getMessage()));. I have also included $app->withFacades(); in bootstrap/app.php.
From what I can tell the events are being triggered and are able to be processed when actually running the job, the real question is why are they not able to be tested? If anyone has any pointers or guidance on this issue it would be much appreciated.