I have a job under queue that does some calculations and then saves it in DB.
Now I have the job test code
Queue::fake();
$user = User::first();
Queue::assertPushed(TheJob::class);
// confirm user's new data
$user->fresh() // still the job queue's calculations are not reflected.
My question is, how can I confirm that the queue's calculated data now exists in DB?
@chaudigv You don’t if you’re faking the queue. If the faking the queue, then the job isn’t executed.
So work out what it is you actually want to test: do you want to assert the job was pushed to the queue? Or do you want to assert that the job did what it was supposed to do?
I need to assert that a Job was dispatched and assert the calculated data after it's completion.
In such case, I can have two tests. One to assert the Job using Queue:fake(). And another one without the fake so it actually runs and I can assert the calculated values.
@chaudigv You probably want to (unit) test whatever your job is doing and test that your job is being dispatched. Everything in between is already tested in the framework itself.