Laravel - Mocking - Queue Fake
You may use the Queue
facade's fake
method to prevent queued jobs from being pushed to the queue. Most likely, it is sufficient to simply assert that Laravel was instructed to push a given job to the queue since the queued jobs themselves may be tested in another test class.
After calling the Queue
facade's fake
method, you may then assert that the application attempted to push jobs to the queue:
You may pass a closure to the assertPushed
or assertNotPushed
methods in order to assert that a job was pushed that passes a given "truth test". If at least one job was pushed that passes the given truth test then the assertion will be successful:
Queue::assertPushed(function (ShipOrder $job) use ($order) {
return $job->order->id === $order->id;
});