Skip to content

[9.x] Support Lazy Collections in BatchFake#45507

Merged
taylorotwell merged 1 commit into
laravel:9.xfrom
evan-burrell:fix/fake-batches
Jan 4, 2023
Merged

[9.x] Support Lazy Collections in BatchFake#45507
taylorotwell merged 1 commit into
laravel:9.xfrom
evan-burrell:fix/fake-batches

Conversation

@evan-burrell

Copy link
Copy Markdown
Contributor

Add support for LazyCollections when using withFakeBatch

Given a basic job batch example

use Batchable;

Model::cursor()
    ->map(fn (Model $model) => new ModelJob($model))
    ->chunk(1000)
    ->each(function (LazyCollection $jobs) {
        $this->batch->add($jobs);
    });

and associated test case

[$job] = (new ModelJobBatch())->withFakeBatch();

$job->handle();

Receives
TypeError : array_merge(): Argument #2 must be of type array, Illuminate\Support\LazyCollection given

@taylorotwell
taylorotwell merged commit 8d2cbbe into laravel:9.x Jan 4, 2023
@evan-burrell
evan-burrell deleted the fix/fake-batches branch January 4, 2023 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants