fix: use closure-based __get for mock property access
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:
parent
f2f27ec766
commit
d88095780e
1 changed files with 3 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue