From d88095780e5bc68fc24274b9616296e8860fe756 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Feb 2026 07:02:04 +0000 Subject: [PATCH] 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 --- tests/Unit/ProcessContentTaskTest.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/Unit/ProcessContentTaskTest.php b/tests/Unit/ProcessContentTaskTest.php index 9b785c0..362b4e5 100644 --- a/tests/Unit/ProcessContentTaskTest.php +++ b/tests/Unit/ProcessContentTaskTest.php @@ -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; }