From 96e9d944dd4fb2ad88669a205970c34cde52e5f8 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 22 Jun 2026 02:28:17 -0400 Subject: [PATCH] fix: use concrete anonymous class instead of Mockery for AttendanceMailerService binding in setUp Mockery's lifecycle (created in setUp, closed in tearDown) may interfere with the container binding across tests. Using a plain anonymous class avoids this issue entirely. --- .../AttendanceTrackingControllerTest.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/Feature/Api/V1/AttendanceTracking/AttendanceTrackingControllerTest.php b/tests/Feature/Api/V1/AttendanceTracking/AttendanceTrackingControllerTest.php index 37e92e9b..007e1de2 100644 --- a/tests/Feature/Api/V1/AttendanceTracking/AttendanceTrackingControllerTest.php +++ b/tests/Feature/Api/V1/AttendanceTracking/AttendanceTrackingControllerTest.php @@ -20,12 +20,19 @@ class AttendanceTrackingControllerTest extends TestCase { parent::setUp(); - // Bind the AttendanceMailerService interface to a mock so the - // controller can be instantiated during route middleware gathering + // Bind the AttendanceMailerService interface to a no-op implementation + // so the controller can be instantiated during route middleware gathering // even when the full service chain is not mocked. $this->app->instance( AttendanceMailerService::class, - Mockery::mock(AttendanceMailerService::class) + new class implements AttendanceMailerService { + public function send(string $to, string $subject, string $html): bool + { + return true; + } + + public function queueAttendanceEvent(array $payload): void {} + } ); }