Skip to content

Test coverage does not mark unserialized closures as covered #1067

Open
@bernardwiesner

Description

@bernardwiesner

I am using laravel's Bus batch to dispatch jobs, and they use closures that get serialized and un-serialized

https://laravel.com/docs/11.x/queues#dispatching-batches

Example:
https://github.com/laravel/framework/blob/46ac7829eba556031fa5f540f3771d52fa4117a2/src/Illuminate/Bus/PendingBatch.php#L173

    public function then($callback)
    {
        $this->options['then'][] = $callback instanceof Closure
            ? new SerializableClosure($callback)
            : $callback;

        return $this;
    }

This results in the code coverage marking the then closure as not covered. Is there any workaround to cover such code blocks that get serialized and un-serialized and then are executed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions