fix logic and tests, update docker CI file

This commit is contained in:
root
2026-03-09 15:58:44 -04:00
parent 1cb3573d4b
commit 79e44fe037
188 changed files with 1776 additions and 524 deletions
@@ -21,7 +21,7 @@ class AdministratorAbsenceControllerTest extends TestCase
public function test_guest_cannot_access_absence_index(): void
{
$response = $this->getJson('/api/administrator/absence');
$response = $this->getJson('/api/v1/administrator/absence');
$response->assertStatus(401);
}
@@ -46,7 +46,7 @@ class AdministratorAbsenceControllerTest extends TestCase
$this->app->instance(AdministratorAbsenceService::class, $mock);
$response = $this->getJson('/api/administrator/absence');
$response = $this->getJson('/api/v1/administrator/absence');
$response->assertOk()
->assertJson([
@@ -62,7 +62,7 @@ class AdministratorAbsenceControllerTest extends TestCase
Sanctum::actingAs($user);
$response = $this->postJson('/api/administrator/absence', [
$response = $this->postJson('/api/v1/administrator/absence', [
'dates' => ['2026-03-08'],
'reason_type' => 'vacation',
'reason' => '',
@@ -78,7 +78,7 @@ class AdministratorAbsenceControllerTest extends TestCase
Sanctum::actingAs($user);
$response = $this->postJson('/api/administrator/absence', [
$response = $this->postJson('/api/v1/administrator/absence', [
'dates' => ['03/08/2026'],
'reason_type' => 'vacation',
'reason' => 'Family trip',
@@ -112,7 +112,7 @@ class AdministratorAbsenceControllerTest extends TestCase
$this->app->instance(AdministratorAbsenceService::class, $mock);
$response = $this->postJson('/api/administrator/absence', $payload);
$response = $this->postJson('/api/v1/administrator/absence', $payload);
$response->assertOk()
->assertJson([
@@ -22,7 +22,7 @@ class AdministratorEnrollmentControllerTest extends TestCase
public function test_guest_cannot_update_enrollment_statuses(): void
{
$response = $this->postJson('/api/administrator/enrollment-withdrawal/update-statuses', [
$response = $this->postJson('/api/v1/administrator/enrollment-withdrawal/update-statuses', [
'enrollment_status' => [
10 => 'enrolled',
],
@@ -50,7 +50,7 @@ class AdministratorEnrollmentControllerTest extends TestCase
$this->app->instance(AdministratorEnrollmentQueryService::class, $mock);
$response = $this->getJson('/api/administrator/enrollment-withdrawal?schoolYear=2025-2026');
$response = $this->getJson('/api/v1/administrator/enrollment-withdrawal?schoolYear=2025-2026');
$response->assertOk()
->assertJson([
@@ -74,7 +74,7 @@ class AdministratorEnrollmentControllerTest extends TestCase
$this->app->instance(AdministratorEnrollmentQueryService::class, $mock);
$response = $this->getJson('/api/administrator/enrollment-withdrawal/new-students');
$response = $this->getJson('/api/v1/administrator/enrollment-withdrawal/new-students');
$response->assertOk()
->assertJson([
@@ -88,7 +88,7 @@ class AdministratorEnrollmentControllerTest extends TestCase
$user = User::factory()->create();
Sanctum::actingAs($user);
$response = $this->postJson('/api/administrator/enrollment-withdrawal/update-statuses', [
$response = $this->postJson('/api/v1/administrator/enrollment-withdrawal/update-statuses', [
'enrollment_status' => [
10 => 'bad-status',
],
@@ -121,7 +121,7 @@ class AdministratorEnrollmentControllerTest extends TestCase
$this->app->instance(AdministratorEnrollmentStatusService::class, $mock);
$response = $this->postJson('/api/administrator/enrollment-withdrawal/update-statuses', $payload);
$response = $this->postJson('/api/v1/administrator/enrollment-withdrawal/update-statuses', $payload);
$response->assertOk()
->assertJson([
@@ -48,30 +48,29 @@ class AdministratorEnrollmentQueryApiTest extends TestCase
'lastname' => 'Two',
]);
$studentOne = Student::query()->create([
$studentOne = Student::factory()->create([
'id' => 1,
'parent_id' => $parentOne->id,
'firstname' => 'Ali',
'lastname' => 'Ben',
'is_new' => 1,
'registration_date' => '2025-09-10 08:00:00',
'admission_status' => 'accepted',
]);
$studentTwo = Student::query()->create([
$studentTwo = Student::factory()->create([
'id' => 2,
'parent_id' => $parentTwo->id,
'firstname' => 'Sara',
'lastname' => 'Ali',
'is_new' => 0,
'registration_date' => '2024-09-10 08:00:00',
'admission_status' => 'accepted',
]);
ClassSection::unguard();
ClassSection::query()->create([
'class_section_id' => 10,
'class_section_name' => 'Grade 5A',
'class_id' => 5,
'school_year' => '2025-2026',
'semester' => 'Fall',
]);
@@ -107,7 +106,7 @@ class AdministratorEnrollmentQueryApiTest extends TestCase
'enrollment_date' => now()->subYear()->toDateString(),
]);
$response = $this->getJson('/api/administrator/enrollment-withdrawal?schoolYear=2025-2026');
$response = $this->getJson('/api/v1/administrator/enrollment-withdrawal?schoolYear=2025-2026');
$response->assertOk()
->assertJson([
@@ -142,30 +141,29 @@ class AdministratorEnrollmentQueryApiTest extends TestCase
'lastname' => 'House',
]);
$studentOne = Student::query()->create([
$studentOne = Student::factory()->create([
'id' => 9,
'parent_id' => $parent->id,
'firstname' => 'Adam',
'lastname' => 'Y',
'is_new' => 1,
'registration_date' => '2025-10-01 10:00:00',
'admission_status' => 'accepted',
]);
$studentTwo = Student::query()->create([
$studentTwo = Student::factory()->create([
'id' => 10,
'parent_id' => $parent->id,
'firstname' => 'Eve',
'lastname' => 'Z',
'is_new' => 0,
'registration_date' => null,
'admission_status' => 'accepted',
]);
ClassSection::unguard();
ClassSection::query()->create([
'class_section_id' => 20,
'class_section_name' => 'Grade 1A',
'class_id' => 1,
'school_year' => '2025-2026',
'semester' => 'Fall',
]);
@@ -201,7 +199,7 @@ class AdministratorEnrollmentQueryApiTest extends TestCase
'enrollment_date' => now()->toDateString(),
]);
$response = $this->getJson('/api/administrator/enrollment-withdrawal/new-students');
$response = $this->getJson('/api/v1/administrator/enrollment-withdrawal/new-students');
$response->assertOk()
->assertJson([
@@ -224,4 +222,4 @@ class AdministratorEnrollmentQueryApiTest extends TestCase
$this->assertSame('Class not Assigned', $second['class_section']);
$this->assertSame('waitlist', $second['enrollment_status']);
}
}
}
@@ -5,7 +5,7 @@ namespace Tests\Feature\Api\Administrator;
use App\Models\Configuration;
use App\Models\Enrollment;
use App\Models\Invoice;
use App\Models\RefundModel as Refund;
use App\Models\Refund;
use App\Models\Student;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
@@ -37,7 +37,7 @@ class AdministratorEnrollmentUpdateStatusesApiTest extends TestCase
$admin = User::factory()->create();
Sanctum::actingAs($admin);
$response = $this->postJson('/api/administrator/enrollment-withdrawal/update-statuses', []);
$response = $this->postUpdateStatuses([]);
$response->assertStatus(422)
->assertJsonValidationErrors(['enrollment_status']);
@@ -48,14 +48,10 @@ class AdministratorEnrollmentUpdateStatusesApiTest extends TestCase
$admin = User::factory()->create();
Sanctum::actingAs($admin);
$response = $this->postJson('/api/administrator/enrollment-withdrawal/update-statuses', [
'enrollment_status' => [
10 => 'not-valid',
],
]);
$response = $this->postUpdateStatuses(['not-valid']);
$response->assertStatus(422)
->assertJsonValidationErrors(['enrollment_status.10']);
->assertJsonValidationErrors(['enrollment_status.0']);
}
public function test_update_statuses_creates_new_enrollment_row(): void
@@ -72,19 +68,15 @@ class AdministratorEnrollmentUpdateStatusesApiTest extends TestCase
'email' => 'parent1@test.com',
]);
Student::unguard();
Student::query()->create([
Student::factory()->create([
'id' => 10,
'parent_id' => $parent->id,
'firstname' => 'Ali',
'lastname' => 'Ben',
'admission_status' => 'pending',
]);
$response = $this->postJson('/api/administrator/enrollment-withdrawal/update-statuses', [
'enrollment_status' => [
10 => 'enrolled',
],
$response = $this->postUpdateStatuses([
10 => 'enrolled',
]);
$response->assertOk()
@@ -117,13 +109,11 @@ class AdministratorEnrollmentUpdateStatusesApiTest extends TestCase
'email' => 'parent2@test.com',
]);
Student::unguard();
Student::query()->create([
Student::factory()->create([
'id' => 11,
'parent_id' => $parent->id,
'firstname' => 'Sara',
'lastname' => 'Ali',
'admission_status' => 'pending',
]);
Enrollment::unguard();
@@ -138,10 +128,8 @@ class AdministratorEnrollmentUpdateStatusesApiTest extends TestCase
'enrollment_date' => now()->toDateString(),
]);
$response = $this->postJson('/api/administrator/enrollment-withdrawal/update-statuses', [
'enrollment_status' => [
11 => 'withdrawn',
],
$response = $this->postUpdateStatuses([
11 => 'withdrawn',
]);
$response->assertOk();
@@ -169,13 +157,11 @@ class AdministratorEnrollmentUpdateStatusesApiTest extends TestCase
'email' => 'parent3@test.com',
]);
Student::unguard();
Student::query()->create([
Student::factory()->create([
'id' => 12,
'parent_id' => $parent->id,
'firstname' => 'Mina',
'lastname' => 'K',
'admission_status' => 'accepted',
]);
Enrollment::unguard();
@@ -194,16 +180,15 @@ class AdministratorEnrollmentUpdateStatusesApiTest extends TestCase
$invoice = Invoice::query()->create([
'parent_id' => 102,
'school_year' => '2025-2026',
'invoice_number' => 'INV-REF-1',
'balance' => 125.00,
'amount_due' => 125.00,
'total_amount' => 125.00,
'issue_date' => now()->toDateString(),
'due_date' => now()->addDays(10)->toDateString(),
]);
$response = $this->postJson('/api/administrator/enrollment-withdrawal/update-statuses', [
'enrollment_status' => [
12 => 'refund pending',
],
$response = $this->postUpdateStatuses([
12 => 'refund pending',
]);
$response->assertOk();
@@ -241,28 +226,23 @@ class AdministratorEnrollmentUpdateStatusesApiTest extends TestCase
'email' => 'parent4@test.com',
]);
Student::unguard();
Student::query()->create([
Student::factory()->create([
'id' => 13,
'parent_id' => $parent->id,
'firstname' => 'Adam',
'lastname' => 'Q',
'admission_status' => 'pending',
]);
Student::query()->create([
Student::factory()->create([
'id' => 14,
'parent_id' => null,
'parent_id' => 0,
'firstname' => 'No',
'lastname' => 'Parent',
'admission_status' => 'pending',
]);
$response = $this->postJson('/api/administrator/enrollment-withdrawal/update-statuses', [
'enrollment_status' => [
13 => 'enrolled',
14 => 'enrolled',
],
$response = $this->postUpdateStatuses([
13 => 'enrolled',
14 => 'enrolled',
]);
$response->assertStatus(207);
@@ -279,4 +259,10 @@ class AdministratorEnrollmentUpdateStatusesApiTest extends TestCase
'school_year' => '2025-2026',
]);
}
}
private function postUpdateStatuses(array $enrollmentStatus)
{
$query = http_build_query(['enrollment_status' => $enrollmentStatus]);
return $this->post('/api/v1/administrator/enrollment-withdrawal/update-statuses?' . $query, []);
}
}
@@ -39,7 +39,7 @@ class AdministratorNotificationControllerTest extends TestCase
$this->app->instance(AdminNotificationSubjectService::class, $mock);
$response = $this->getJson('/api/administrator/notifications/alerts');
$response = $this->getJson('/api/v1/administrator/notifications/alerts');
$response->assertOk()
->assertJson([
@@ -54,7 +54,7 @@ class AdministratorNotificationControllerTest extends TestCase
$user = User::factory()->create();
Sanctum::actingAs($user);
$response = $this->postJson('/api/administrator/notifications/alerts', []);
$response = $this->postJson('/api/v1/administrator/notifications/alerts', []);
$response->assertStatus(422)
->assertJsonValidationErrors(['subjects']);
@@ -82,7 +82,7 @@ class AdministratorNotificationControllerTest extends TestCase
$this->app->instance(AdminNotificationSubjectService::class, $mock);
$response = $this->postJson('/api/administrator/notifications/alerts', $payload);
$response = $this->postJson('/api/v1/administrator/notifications/alerts', $payload);
$response->assertOk()
->assertJson([
@@ -106,7 +106,7 @@ class AdministratorNotificationControllerTest extends TestCase
$this->app->instance(AdminPrintRecipientService::class, $mock);
$response = $this->getJson('/api/administrator/notifications/print-recipients');
$response = $this->getJson('/api/v1/administrator/notifications/print-recipients');
$response->assertOk()
->assertJson([
@@ -121,7 +121,7 @@ class AdministratorNotificationControllerTest extends TestCase
$user = User::factory()->create();
Sanctum::actingAs($user);
$response = $this->postJson('/api/administrator/notifications/print-recipients', []);
$response = $this->postJson('/api/v1/administrator/notifications/print-recipients', []);
$response->assertStatus(422)
->assertJsonValidationErrors(['notify']);
@@ -150,7 +150,7 @@ class AdministratorNotificationControllerTest extends TestCase
$this->app->instance(AdminPrintRecipientService::class, $mock);
$response = $this->postJson('/api/administrator/notifications/print-recipients', $payload);
$response = $this->postJson('/api/v1/administrator/notifications/print-recipients', $payload);
$response->assertOk()
->assertJson([
@@ -43,7 +43,7 @@ class AdministratorTeacherSubmissionControllerTest extends TestCase
$this->app->instance(TeacherSubmissionReportService::class, $mock);
$response = $this->getJson('/api/administrator/teacher-submissions');
$response = $this->getJson('/api/v1/administrator/teacher-submissions');
$response->assertOk()
->assertJson([
@@ -58,7 +58,7 @@ class AdministratorTeacherSubmissionControllerTest extends TestCase
$user = User::factory()->create();
Sanctum::actingAs($user);
$response = $this->postJson('/api/administrator/teacher-submissions/notify', [
$response = $this->postJson('/api/v1/administrator/teacher-submissions/notify', [
'missing_items' => [],
]);
@@ -96,7 +96,7 @@ class AdministratorTeacherSubmissionControllerTest extends TestCase
$this->app->instance(TeacherSubmissionNotificationService::class, $mock);
$response = $this->postJson('/api/administrator/teacher-submissions/notify', $payload);
$response = $this->postJson('/api/v1/administrator/teacher-submissions/notify', $payload);
$response->assertOk()
->assertJson([
@@ -35,7 +35,7 @@ class AdministratorTeacherSubmissionNotifyApiTest extends TestCase
$admin = User::factory()->create();
Sanctum::actingAs($admin);
$response = $this->postJson('/api/administrator/teacher-submissions/notify', [
$response = $this->postJson('/api/v1/administrator/teacher-submissions/notify', [
'missing_items' => [],
]);
@@ -55,19 +55,20 @@ class AdministratorTeacherSubmissionNotifyApiTest extends TestCase
]);
Sanctum::actingAs($admin);
DB::table('users')->insert([
[
'id' => 100,
'firstname' => 'John',
'lastname' => 'Teacher',
'email' => 'teacher@test.com',
],
User::factory()->create([
'id' => 100,
'firstname' => 'John',
'lastname' => 'Teacher',
'email' => 'teacher@test.com',
]);
DB::table('classSection')->insert([
[
'class_section_id' => 10,
'class_section_name' => 'Grade 5A',
'class_id' => 5,
'semester' => 'Fall',
'school_year' => '2025-2026',
],
]);
@@ -87,7 +88,7 @@ class AdministratorTeacherSubmissionNotifyApiTest extends TestCase
],
];
$response = $this->postJson('/api/administrator/teacher-submissions/notify', $payload);
$response = $this->postJson('/api/v1/administrator/teacher-submissions/notify', $payload);
$response->assertOk()
->assertJson([
@@ -123,19 +124,20 @@ class AdministratorTeacherSubmissionNotifyApiTest extends TestCase
]);
Sanctum::actingAs($admin);
DB::table('users')->insert([
[
'id' => 101,
'firstname' => 'Bad',
'lastname' => 'Email',
'email' => 'not-an-email',
],
User::factory()->create([
'id' => 101,
'firstname' => 'Bad',
'lastname' => 'Email',
'email' => 'not-an-email',
]);
DB::table('classSection')->insert([
[
'class_section_id' => 11,
'class_section_name' => 'Grade 6A',
'class_id' => 6,
'semester' => 'Fall',
'school_year' => '2025-2026',
],
]);
@@ -147,7 +149,7 @@ class AdministratorTeacherSubmissionNotifyApiTest extends TestCase
],
];
$response = $this->postJson('/api/administrator/teacher-submissions/notify', $payload);
$response = $this->postJson('/api/v1/administrator/teacher-submissions/notify', $payload);
$response->assertStatus(207)
->assertJson([
@@ -167,4 +169,4 @@ class AdministratorTeacherSubmissionNotifyApiTest extends TestCase
'semester' => 'Fall',
]);
}
}
}
@@ -10,6 +10,7 @@ use App\Models\TeacherSubmissionNotificationHistory;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
@@ -37,25 +38,26 @@ class AdministratorTeacherSubmissionReportApiTest extends TestCase
$admin = User::factory()->create(['id' => 900, 'firstname' => 'Admin', 'lastname' => 'One']);
Sanctum::actingAs($admin);
DB::table('users')->insert([
[
'id' => 100,
'firstname' => 'Main',
'lastname' => 'Teacher',
'email' => 'main@test.com',
],
[
'id' => 101,
'firstname' => 'TA',
'lastname' => 'Teacher',
'email' => 'ta@test.com',
],
User::factory()->create([
'id' => 100,
'firstname' => 'Main',
'lastname' => 'Teacher',
'email' => 'main@test.com',
]);
User::factory()->create([
'id' => 101,
'firstname' => 'TA',
'lastname' => 'Teacher',
'email' => 'ta@test.com',
]);
DB::table('classSection')->insert([
[
'class_section_id' => 10,
'class_section_name' => 'Grade 5A',
'class_id' => 5,
'semester' => 'Fall',
'school_year' => '2025-2026',
],
]);
@@ -91,10 +93,12 @@ class AdministratorTeacherSubmissionReportApiTest extends TestCase
],
]);
$schoolId = (string) Str::uuid();
SemesterScore::unguard();
SemesterScore::query()->create([
'student_id' => 1,
'class_section_id' => 10,
'school_id' => $schoolId,
'school_year' => '2025-2026',
'semester' => 'Fall',
'midterm_exam_score' => '88',
@@ -103,15 +107,17 @@ class AdministratorTeacherSubmissionReportApiTest extends TestCase
SemesterScore::query()->create([
'student_id' => 2,
'class_section_id' => 10,
'school_id' => $schoolId,
'school_year' => '2025-2026',
'semester' => 'Fall',
'midterm_exam_score' => '',
'midterm_exam_score' => null,
'participation_score' => '9',
]);
ScoreComment::unguard();
ScoreComment::query()->create([
'student_id' => 1,
'class_section_id' => 10,
'school_year' => '2025-2026',
'semester' => 'Fall',
'score_type' => 'midterm',
@@ -119,6 +125,7 @@ class AdministratorTeacherSubmissionReportApiTest extends TestCase
]);
ScoreComment::query()->create([
'student_id' => 1,
'class_section_id' => 10,
'school_year' => '2025-2026',
'semester' => 'Fall',
'score_type' => 'ptap',
@@ -147,7 +154,7 @@ class AdministratorTeacherSubmissionReportApiTest extends TestCase
'sent_at' => now(),
]);
$response = $this->getJson('/api/administrator/teacher-submissions');
$response = $this->getJson('/api/v1/administrator/teacher-submissions');
$response->assertOk()
->assertJson([
@@ -195,19 +202,20 @@ class AdministratorTeacherSubmissionReportApiTest extends TestCase
$admin = User::factory()->create();
Sanctum::actingAs($admin);
DB::table('users')->insert([
[
'id' => 200,
'firstname' => 'Solo',
'lastname' => 'Teacher',
'email' => 'solo@test.com',
],
User::factory()->create([
'id' => 200,
'firstname' => 'Solo',
'lastname' => 'Teacher',
'email' => 'solo@test.com',
]);
DB::table('classSection')->insert([
[
'class_section_id' => 11,
'class_section_name' => 'Grade 6A',
'class_id' => 6,
'semester' => 'Fall',
'school_year' => '2025-2026',
],
]);
@@ -221,7 +229,7 @@ class AdministratorTeacherSubmissionReportApiTest extends TestCase
],
]);
$response = $this->getJson('/api/administrator/teacher-submissions');
$response = $this->getJson('/api/v1/administrator/teacher-submissions');
$response->assertOk()
->assertJsonCount(1, 'rows');
@@ -241,19 +249,20 @@ class AdministratorTeacherSubmissionReportApiTest extends TestCase
$admin = User::factory()->create(['id' => 901, 'firstname' => 'Admin', 'lastname' => 'Two']);
Sanctum::actingAs($admin);
DB::table('users')->insert([
[
'id' => 300,
'firstname' => 'Hist',
'lastname' => 'Teacher',
'email' => 'hist@test.com',
],
User::factory()->create([
'id' => 300,
'firstname' => 'Hist',
'lastname' => 'Teacher',
'email' => 'hist@test.com',
]);
DB::table('classSection')->insert([
[
'class_section_id' => 12,
'class_section_name' => 'Grade 7A',
'class_id' => 7,
'semester' => 'Fall',
'school_year' => '2025-2026',
],
]);
@@ -282,11 +291,11 @@ class AdministratorTeacherSubmissionReportApiTest extends TestCase
]);
}
$response = $this->getJson('/api/administrator/teacher-submissions');
$response = $this->getJson('/api/v1/administrator/teacher-submissions');
$response->assertOk();
$history = $response->json('notificationHistory.12.300');
$this->assertCount(3, $history);
}
}
}