create([ 'latitude' => '34.112456', 'longitude' => '-118.4270732', ]); $this->mock(GetWeatherInformationService::class, function (MockInterface $mock) use ($place) { $mock->shouldReceive('execute') ->once() ->withArgs(function ($data) use ($place) { $this->assertEquals([ 'account_id' => $place->account_id, 'place_id' => $place->id, ], $data); return true; }); }); $pendingBatch = $fake->batch([ $job = new GetWeatherInformation($place), ]); $batch = $pendingBatch->dispatch(); $fake->assertBatched(function (PendingBatch $pendingBatch) { $this->assertCount(1, $pendingBatch->jobs); $this->assertInstanceOf(GetWeatherInformation::class, $pendingBatch->jobs->first()); return true; }); $batch = app(DatabaseBatchRepository::class)->store($pendingBatch); $job->withBatchId($batch->id)->handle(); } }