fix: use concrete anonymous class instead of Mockery for AttendanceMailerService binding in setUp
API CI/CD / Validate (composer + pint) (push) Successful in 2m6s
API CI/CD / Test (PHPUnit) (push) Failing after 2m27s
API CI/CD / Build frontend assets (push) Successful in 2m23s
API CI/CD / Security audit (push) Successful in 32s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 2m6s
API CI/CD / Test (PHPUnit) (push) Failing after 2m27s
API CI/CD / Build frontend assets (push) Successful in 2m23s
API CI/CD / Security audit (push) Successful in 32s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
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.
This commit is contained in:
@@ -20,12 +20,19 @@ class AttendanceTrackingControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
// Bind the AttendanceMailerService interface to a mock so the
|
// Bind the AttendanceMailerService interface to a no-op implementation
|
||||||
// controller can be instantiated during route middleware gathering
|
// so the controller can be instantiated during route middleware gathering
|
||||||
// even when the full service chain is not mocked.
|
// even when the full service chain is not mocked.
|
||||||
$this->app->instance(
|
$this->app->instance(
|
||||||
AttendanceMailerService::class,
|
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 {}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user