You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm seeing a TypeError when using the Bus fake in my tests (checking that a batch job has been dispatched):
TypeError: Argument 7 passed to Illuminate\Bus\Batch::__construct() must be of the type int, array given, called in /home/vagrant/sites/xxxx/vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php on line 56
The fake (Illuminate\Support\Testing\Fakes\BatchRepositoryFake) appears to passing an array, $batch->options as the 7th argument, where as the Illuminate\Bus\Batch class expects the 7th argument to be an integer, $failedJobs.
Steps To Reproduce:
Dispatch a batchable job from somewhere (in my case, from an Artisan command):
public function handle()
{
$batch = Bus::batch([
new MyJob($my_model)
])->then(function(Batch $batch) use($my_model) {
// Do something
})->catch(function(Batch $batch, Throwable $e) use($my_model) {
// Do something
})->finally(function(Batch $batch) use($my_model) {
// Do something
})->name('my-batch')->dispatch();
}
Run a test that asserts using the Bus fake:
public function test_batch_dispatch()
{
Bus::fake();
//
// Trigger dispatching of job (see above)
//
Bus::assertDispatched(MyJob::class, function(MyJob $job) use($my_model) {
return $job->my_model->id===$my_model->id;
});
Bus::assertDispatchedTimes(MyJob::class, 1);
}
The text was updated successfully, but these errors were encountered:
Description:
I'm seeing a
TypeError
when using theBus
fake in my tests (checking that a batch job has been dispatched):TypeError: Argument 7 passed to Illuminate\Bus\Batch::__construct() must be of the type int, array given, called in /home/vagrant/sites/xxxx/vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/BatchRepositoryFake.php on line 56
The fake (
Illuminate\Support\Testing\Fakes\BatchRepositoryFake
) appears to passing an array,$batch->options
as the 7th argument, where as theIlluminate\Bus\Batch
class expects the 7th argument to be an integer,$failedJobs
.Steps To Reproduce:
Bus
fake:The text was updated successfully, but these errors were encountered: