fix: use closure-based __get for mock property access
Some checks are pending
CI / PHP 8.3 (push) Waiting to run
CI / PHP 8.4 (push) Waiting to run

Replace individual __get expectations with a single closure that handles
all property access. Fixes ErrorException on undefined property access
with Mockery mocks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude 2026-02-23 07:02:04 +00:00
parent f2f27ec766
commit d88095780e
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -33,12 +33,9 @@ function makeTask(array $attributes = []): ContentTask
$task->shouldReceive('markCompleted')->byDefault();
$task->shouldReceive('markFailed')->byDefault();
foreach ($attributes as $prop => $value) {
$task->shouldReceive('__get')->with($prop)->andReturn($value);
}
// Return null for any property not explicitly configured
$task->shouldReceive('__get')->byDefault()->andReturn(null);
$task->shouldReceive('__get')->andReturnUsing(function (string $prop) use ($attributes) {
return $attributes[$prop] ?? null;
})->byDefault();
return $task;
}