fix: resolve test failures for Sanctum auth guard and AttendanceMailerService binding
API CI/CD / Validate (composer + pint) (push) Successful in 2m12s
API CI/CD / Test (PHPUnit) (push) Failing after 2m29s
API CI/CD / Build frontend assets (push) Successful in 2m19s
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 2m12s
API CI/CD / Test (PHPUnit) (push) Failing after 2m29s
API CI/CD / Build frontend assets (push) Successful in 2m19s
API CI/CD / Security audit (push) Successful in 32s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
- Add SanctumServiceProvider explicitly to bootstrap/providers.php to ensure sanctum auth driver is registered in CI environments - Add mockService() to 3 validation tests that were missing it (test_record_returns_validation_errors_for_bad_payload, test_send_manual_email_validates_payload, test_save_notification_note_validates_payload) to prevent container resolution failure during middleware gathering - Update test URLs from /api/attendance-tracking/ to /api/v1/attendance-tracking/ to match current route structure
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
|
||||
use App\Providers\AppServiceProvider;
|
||||
use App\Providers\EventServiceProvider;
|
||||
use Laravel\Sanctum\SanctumServiceProvider;
|
||||
|
||||
return [
|
||||
AppServiceProvider::class,
|
||||
EventServiceProvider::class,
|
||||
SanctumServiceProvider::class,
|
||||
];
|
||||
|
||||
@@ -38,7 +38,7 @@ class AttendanceTrackingControllerTest extends TestCase
|
||||
'semester' => 'Fall',
|
||||
]);
|
||||
|
||||
$response = $this->getJson('/api/attendance-tracking/pending-violations?school_year=2025-2026&semester=Fall');
|
||||
$response = $this->getJson('/api/v1/attendance-tracking/pending-violations?school_year=2025-2026&semester=Fall');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
@@ -63,7 +63,7 @@ class AttendanceTrackingControllerTest extends TestCase
|
||||
'semester' => 'Fall',
|
||||
]);
|
||||
|
||||
$response = $this->getJson('/api/attendance-tracking/notified-violations?school_year=2025-2026&semester=Fall');
|
||||
$response = $this->getJson('/api/v1/attendance-tracking/notified-violations?school_year=2025-2026&semester=Fall');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
@@ -89,7 +89,7 @@ class AttendanceTrackingControllerTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
$response = $this->getJson('/api/attendance-tracking/student-case/10');
|
||||
$response = $this->getJson('/api/v1/attendance-tracking/student-case/10');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
@@ -112,7 +112,7 @@ class AttendanceTrackingControllerTest extends TestCase
|
||||
'status' => 404,
|
||||
]);
|
||||
|
||||
$response = $this->getJson('/api/attendance-tracking/student-case/999');
|
||||
$response = $this->getJson('/api/v1/attendance-tracking/student-case/999');
|
||||
|
||||
$response->assertStatus(404)
|
||||
->assertJson([
|
||||
@@ -141,7 +141,7 @@ class AttendanceTrackingControllerTest extends TestCase
|
||||
'message' => 'Notification queued.',
|
||||
]);
|
||||
|
||||
$response = $this->postJson('/api/attendance-tracking/record', $payload);
|
||||
$response = $this->postJson('/api/v1/attendance-tracking/record', $payload);
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
@@ -152,7 +152,9 @@ class AttendanceTrackingControllerTest extends TestCase
|
||||
|
||||
public function test_record_returns_validation_errors_for_bad_payload(): void
|
||||
{
|
||||
$response = $this->postJson('/api/attendance-tracking/record', [
|
||||
$this->mockService();
|
||||
|
||||
$response = $this->postJson('/api/v1/attendance-tracking/record', [
|
||||
'student_id' => 0,
|
||||
'date' => 'bad-date',
|
||||
]);
|
||||
@@ -176,7 +178,7 @@ class AttendanceTrackingControllerTest extends TestCase
|
||||
'details' => [],
|
||||
]);
|
||||
|
||||
$response = $this->postJson('/api/attendance-tracking/send-auto-emails', [
|
||||
$response = $this->postJson('/api/v1/attendance-tracking/send-auto-emails', [
|
||||
'variant' => 'default',
|
||||
]);
|
||||
|
||||
@@ -204,7 +206,7 @@ class AttendanceTrackingControllerTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
$response = $this->getJson('/api/attendance-tracking/compose?student_id=10&code=ABS_1&variant=default&incident_date=2026-03-01');
|
||||
$response = $this->getJson('/api/v1/attendance-tracking/compose?student_id=10&code=ABS_1&variant=default&incident_date=2026-03-01');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
@@ -238,7 +240,7 @@ class AttendanceTrackingControllerTest extends TestCase
|
||||
'message' => 'Email sent successfully.',
|
||||
]);
|
||||
|
||||
$response = $this->postJson('/api/attendance-tracking/send-manual-email', $payload);
|
||||
$response = $this->postJson('/api/v1/attendance-tracking/send-manual-email', $payload);
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
@@ -249,7 +251,9 @@ class AttendanceTrackingControllerTest extends TestCase
|
||||
|
||||
public function test_send_manual_email_validates_payload(): void
|
||||
{
|
||||
$response = $this->postJson('/api/attendance-tracking/send-manual-email', [
|
||||
$this->mockService();
|
||||
|
||||
$response = $this->postJson('/api/v1/attendance-tracking/send-manual-email', [
|
||||
'student_id' => 0,
|
||||
'to' => 'not-an-email',
|
||||
]);
|
||||
@@ -273,7 +277,7 @@ class AttendanceTrackingControllerTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
$response = $this->getJson('/api/attendance-tracking/parents-info?student_id=10');
|
||||
$response = $this->getJson('/api/v1/attendance-tracking/parents-info?student_id=10');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
@@ -304,7 +308,7 @@ class AttendanceTrackingControllerTest extends TestCase
|
||||
'message' => 'Note saved.',
|
||||
]);
|
||||
|
||||
$response = $this->postJson('/api/attendance-tracking/save-notification-note', $payload);
|
||||
$response = $this->postJson('/api/v1/attendance-tracking/save-notification-note', $payload);
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
@@ -315,7 +319,9 @@ class AttendanceTrackingControllerTest extends TestCase
|
||||
|
||||
public function test_save_notification_note_validates_payload(): void
|
||||
{
|
||||
$response = $this->postJson('/api/attendance-tracking/save-notification-note', [
|
||||
$this->mockService();
|
||||
|
||||
$response = $this->postJson('/api/v1/attendance-tracking/save-notification-note', [
|
||||
'student_id' => 0,
|
||||
'code' => '',
|
||||
'note' => '',
|
||||
|
||||
Reference in New Issue
Block a user