add more controller

This commit is contained in:
root
2026-03-10 00:48:32 -04:00
parent 5eeaec0257
commit 20ee70d153
151 changed files with 9481 additions and 8407 deletions
@@ -0,0 +1,124 @@
<?php
namespace Tests\Feature\Api\V1\Administrator;
use App\Models\EmergencyContact;
use App\Models\Student;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class EmergencyContactControllerTest extends TestCase
{
use RefreshDatabase;
public function test_index_returns_grouped_contacts(): void
{
$admin = User::factory()->create();
$parent = User::factory()->create([
'firstname' => 'Omar',
'lastname' => 'Parent',
'cellphone' => '1111111111',
]);
DB::table('parents')->insert([
'secondparent_firstname' => 'Nora',
'secondparent_lastname' => 'Parent',
'secondparent_gender' => 'Female',
'secondparent_email' => 'nora.parent@example.com',
'secondparent_phone' => '2222222222',
'firstparent_id' => $parent->id,
'secondparent_id' => 1234,
'semester' => 'Fall',
'school_year' => '2025-2026',
'created_at' => now(),
'updated_at' => now(),
]);
Student::factory()->create([
'parent_id' => $parent->id,
'firstname' => 'Rami',
'lastname' => 'Student',
'school_id' => 'S-202',
]);
EmergencyContact::query()->create([
'parent_id' => $parent->id,
'emergency_contact_name' => 'Uncle Amin',
'cellphone' => '3333333333',
'email' => 'amin@example.com',
'relation' => 'Uncle',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
Sanctum::actingAs($admin);
$response = $this->getJson('/api/v1/administrator/emergency-contacts');
$response->assertOk();
$response->assertJson(['ok' => true]);
$response->assertJsonPath('groups.0.parent_id', $parent->id);
$response->assertJsonPath('groups.0.parent_phones.0', '1111111111');
$response->assertJsonPath('groups.0.parent_phones.1', '2222222222');
}
public function test_update_changes_emergency_contact(): void
{
$admin = User::factory()->create();
$parent = User::factory()->create();
$contact = EmergencyContact::query()->create([
'parent_id' => $parent->id,
'emergency_contact_name' => 'Old Name',
'cellphone' => '4444444444',
'email' => 'old@example.com',
'relation' => 'Friend',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
Sanctum::actingAs($admin);
$response = $this->patchJson('/api/v1/administrator/emergency-contacts/' . $contact->id, [
'name' => 'New Name',
'cellphone' => '5555555555',
'email' => 'new@example.com',
'relation' => 'Neighbor',
]);
$response->assertOk();
$response->assertJson(['ok' => true]);
$this->assertDatabaseHas('emergency_contacts', [
'id' => $contact->id,
'emergency_contact_name' => 'New Name',
'email' => 'new@example.com',
'relation' => 'Neighbor',
]);
}
public function test_destroy_deletes_emergency_contact(): void
{
$admin = User::factory()->create();
$parent = User::factory()->create();
$contact = EmergencyContact::query()->create([
'parent_id' => $parent->id,
'emergency_contact_name' => 'Delete Name',
'cellphone' => '6666666666',
'email' => 'delete@example.com',
'relation' => 'Friend',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
Sanctum::actingAs($admin);
$response = $this->deleteJson('/api/v1/administrator/emergency-contacts/' . $contact->id);
$response->assertOk();
$response->assertJson(['ok' => true]);
$this->assertDatabaseMissing('emergency_contacts', [
'id' => $contact->id,
]);
}
}
@@ -0,0 +1,141 @@
<?php
namespace Tests\Feature\Api\V1\Administrator;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class TeacherClassAssignmentControllerTest extends TestCase
{
use RefreshDatabase;
public function test_index_returns_teachers_and_classes(): void
{
$this->seedConfig();
$admin = $this->seedAdminUser();
$this->seedTeacherUser();
$this->seedClassSection();
Sanctum::actingAs($admin);
$response = $this->getJson('/api/v1/administrator/teacher-class/assignments?school_year=2025-2026');
$response->assertOk();
$response->assertJson(['ok' => true]);
$this->assertNotEmpty($response->json('teachers'));
$this->assertNotEmpty($response->json('classes'));
}
public function test_store_and_delete_assignment(): void
{
$this->seedConfig();
$admin = $this->seedAdminUser();
$teacher = $this->seedTeacherUser();
$classSectionId = $this->seedClassSection();
Sanctum::actingAs($admin);
$storeResponse = $this->postJson('/api/v1/administrator/teacher-class/assign', [
'teacher_id' => $teacher->id,
'class_section_id' => $classSectionId,
'teacher_role' => 'teacher',
'school_year' => '2025-2026',
]);
$storeResponse->assertOk();
$this->assertDatabaseHas('teacher_class', [
'teacher_id' => $teacher->id,
'class_section_id' => $classSectionId,
'position' => 'main',
]);
$deleteResponse = $this->postJson('/api/v1/administrator/teacher-class/delete', [
'teacher_id' => $teacher->id,
'class_section_id' => $classSectionId,
'position' => 'main',
'school_year' => '2025-2026',
]);
$deleteResponse->assertOk();
$this->assertDatabaseMissing('teacher_class', [
'teacher_id' => $teacher->id,
'class_section_id' => $classSectionId,
'position' => 'main',
]);
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
]);
}
private function seedAdminUser(): User
{
$userId = DB::table('users')->insertGetId([
'firstname' => 'Admin',
'lastname' => 'User',
'cellphone' => '5555555555',
'email' => 'admin.teacher.assignment@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
return User::query()->findOrFail($userId);
}
private function seedTeacherUser(): User
{
$roleId = DB::table('roles')->insertGetId([
'name' => 'teacher',
]);
$userId = DB::table('users')->insertGetId([
'firstname' => 'Olivia',
'lastname' => 'Teacher',
'cellphone' => '6666666666',
'email' => 'teacher.assignment.admin@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
DB::table('user_roles')->insert([
'user_id' => $userId,
'role_id' => $roleId,
]);
return User::query()->findOrFail($userId);
}
private function seedClassSection(): int
{
DB::table('classSection')->insert([
'class_id' => 1,
'class_section_id' => 401,
'class_section_name' => '4A',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
return 401;
}
}
@@ -0,0 +1,153 @@
<?php
namespace Tests\Feature\Api\V1\Exams;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\DB;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class ExamDraftControllerTest extends TestCase
{
use RefreshDatabase;
public function test_teacher_store_creates_draft(): void
{
$this->seedConfig();
$teacher = $this->seedTeacher();
$classSectionId = $this->seedClassSection();
$this->seedAssignment($teacher->id, $classSectionId);
Sanctum::actingAs($teacher);
$file = UploadedFile::fake()->create('draft.docx', 10, 'application/vnd.openxmlformats-officedocument.wordprocessingml.document');
$response = $this->post('/api/v1/exams/drafts/teacher', [
'class_section_id' => $classSectionId,
'exam_type' => 'Final Exam',
'description' => 'Draft',
'draft_file' => $file,
]);
$response->assertStatus(201);
$this->assertDatabaseHas('exam_drafts', [
'teacher_id' => $teacher->id,
'class_section_id' => $classSectionId,
'status' => 'submitted',
]);
}
public function test_admin_review_updates_status(): void
{
$this->seedConfig();
$admin = $this->seedAdmin();
$draftId = $this->seedDraft();
Sanctum::actingAs($admin);
$response = $this->postJson('/api/v1/exams/drafts/admin/review', [
'draft_id' => $draftId,
'review_status' => 'reviewed',
]);
$response->assertOk();
$this->assertDatabaseHas('exam_drafts', [
'id' => $draftId,
'status' => 'reviewed',
]);
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
]);
}
private function seedTeacher(): User
{
$userId = DB::table('users')->insertGetId([
'firstname' => 'Teacher',
'lastname' => 'User',
'cellphone' => '1111111111',
'email' => 'teacher.exam.feature@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
return User::query()->findOrFail($userId);
}
private function seedAdmin(): User
{
$userId = DB::table('users')->insertGetId([
'firstname' => 'Admin',
'lastname' => 'User',
'cellphone' => '2222222222',
'email' => 'admin.exam.feature@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
return User::query()->findOrFail($userId);
}
private function seedClassSection(): int
{
DB::table('classSection')->insert([
'class_id' => 1,
'class_section_id' => 802,
'class_section_name' => '8B',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
return 802;
}
private function seedAssignment(int $teacherId, int $classSectionId): void
{
DB::table('teacher_class')->insert([
'teacher_id' => $teacherId,
'class_section_id' => $classSectionId,
'position' => 'main',
'school_year' => '2025-2026',
'created_at' => now(),
'updated_at' => now(),
]);
}
private function seedDraft(): int
{
return DB::table('exam_drafts')->insertGetId([
'teacher_id' => 1,
'class_section_id' => 802,
'semester' => 'Fall',
'school_year' => '2025-2026',
'exam_type' => 'Quiz',
'draft_title' => 'Quiz Draft',
'description' => 'Draft',
'status' => 'submitted',
'version' => 1,
'created_at' => now(),
'updated_at' => now(),
]);
}
}
@@ -0,0 +1,198 @@
<?php
namespace Tests\Feature\Api\V1\Parents;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class ParentAttendanceReportControllerTest extends TestCase
{
use RefreshDatabase;
public function test_form_returns_students_and_sundays(): void
{
$this->seedConfig();
$parent = $this->seedParent();
$this->seedStudent($parent->id);
Sanctum::actingAs($parent);
$response = $this->getJson('/api/v1/parents/attendance-reports/form');
$response->assertOk();
$response->assertJson(['ok' => true]);
$this->assertNotEmpty($response->json('students'));
$this->assertNotEmpty($response->json('sundays'));
}
public function test_submit_creates_report_and_attendance(): void
{
$this->seedConfig();
$parent = $this->seedParent();
$studentId = $this->seedStudent($parent->id);
$this->seedClassSection($studentId);
$date = $this->nextSunday();
Sanctum::actingAs($parent);
$response = $this->postJson('/api/v1/parents/attendance-reports', [
'student_ids' => [$studentId],
'date' => $date,
'type' => 'absent',
'reason' => 'Sick',
]);
$response->assertStatus(201);
$response->assertJson(['ok' => true]);
$this->assertDatabaseHas('parent_attendance_reports', [
'student_id' => $studentId,
'report_date' => $date,
'type' => 'absent',
]);
$this->assertDatabaseHas('attendance_data', [
'student_id' => $studentId,
'date' => $date,
'status' => 'absent',
]);
}
public function test_check_existing_returns_rows(): void
{
$this->seedConfig();
$parent = $this->seedParent();
$studentId = $this->seedStudent($parent->id);
$date = $this->nextSunday();
DB::table('parent_attendance_reports')->insert([
'parent_id' => $parent->id,
'student_id' => $studentId,
'report_date' => $date,
'type' => 'late',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'new',
]);
Sanctum::actingAs($parent);
$response = $this->postJson('/api/v1/parents/attendance-reports/check-existing', [
'student_ids' => [$studentId],
'date' => $date,
'type' => 'late',
]);
$response->assertOk();
$response->assertJson(['ok' => true]);
$this->assertSame($studentId, $response->json('students.0.student_id'));
}
public function test_update_report_updates_reason(): void
{
$this->seedConfig();
$parent = $this->seedParent();
$studentId = $this->seedStudent($parent->id);
$date = $this->nextSunday();
$reportId = DB::table('parent_attendance_reports')->insertGetId([
'parent_id' => $parent->id,
'student_id' => $studentId,
'report_date' => $date,
'type' => 'absent',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'new',
]);
Sanctum::actingAs($parent);
$response = $this->patchJson('/api/v1/parents/attendance-reports/' . $reportId, [
'reason' => 'Family emergency',
]);
$response->assertOk();
$this->assertDatabaseHas('parent_attendance_reports', [
'id' => $reportId,
'reason' => 'Family emergency',
]);
}
private function seedParent(): User
{
$id = DB::table('users')->insertGetId([
'firstname' => 'Parent',
'lastname' => 'User',
'cellphone' => '1234567890',
'email' => 'parent.attendance@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
return User::query()->findOrFail($id);
}
private function seedStudent(int $parentId): int
{
return DB::table('students')->insertGetId([
'school_id' => 'S-300',
'firstname' => 'Evan',
'lastname' => 'Parent',
'dob' => '2014-09-01',
'age' => 11,
'gender' => 'Male',
'photo_consent' => 1,
'parent_id' => $parentId,
'year_of_registration' => '2025',
'school_year' => '2025-2026',
'semester' => 'Fall',
]);
}
private function seedClassSection(int $studentId): void
{
DB::table('classSection')->insert([
'class_id' => 1,
'class_section_id' => 10,
'class_section_name' => '1A',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
DB::table('student_class')->insert([
'student_id' => $studentId,
'class_section_id' => 10,
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
['config_key' => 'date_age_reference', 'config_value' => '2025-12-31'],
['config_key' => 'parent_report_cutoff', 'config_value' => '23:59'],
['config_key' => 'fall_semester_start', 'config_value' => '2025-09-01'],
['config_key' => 'spring_semester_start', 'config_value' => '2026-01-15'],
['config_key' => 'last_school_day', 'config_value' => '2026-06-15'],
]);
}
private function nextSunday(): string
{
$dt = new \DateTime('today');
if ((int) $dt->format('w') !== 0) {
$dt->modify('next sunday');
}
return $dt->format('Y-m-d');
}
}
@@ -0,0 +1,125 @@
<?php
namespace Tests\Feature\Api\V1\Parents;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class ParentControllerTest extends TestCase
{
use RefreshDatabase;
public function test_attendance_returns_rows(): void
{
$this->seedConfig();
$parent = $this->seedParent();
$studentId = DB::table('students')->insertGetId([
'school_id' => 'S-100',
'firstname' => 'Adam',
'lastname' => 'Parent',
'dob' => '2015-09-01',
'age' => 10,
'gender' => 'Male',
'photo_consent' => 1,
'parent_id' => $parent->id,
'year_of_registration' => '2025',
'school_year' => '2025-2026',
'semester' => 'Fall',
]);
DB::table('attendance_data')->insert([
'class_id' => 1,
'class_section_id' => 1,
'student_id' => $studentId,
'school_id' => '1',
'date' => '2025-10-01',
'status' => 'absent',
'reason' => 'Sick',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
Sanctum::actingAs($parent);
$response = $this->getJson('/api/v1/parents/attendance?school_year=2025-2026');
$response->assertOk();
$response->assertJson(['ok' => true]);
$response->assertJsonPath('attendance.0.status', 'absent');
}
public function test_registration_creates_student_and_contact(): void
{
$this->seedConfig();
$parent = $this->seedParent();
Sanctum::actingAs($parent);
$payload = [
'students' => [
[
'firstname' => 'Sara',
'lastname' => 'Parent',
'dob' => '2016-02-01',
'gender' => 'Female',
'registration_grade' => '2',
'photo_consent' => true,
'is_new' => true,
'allergies' => ['Peanuts'],
'medical_conditions' => ['Asthma'],
],
],
'emergency_contacts' => [
[
'name' => 'John Parent',
'cellphone' => '1234567890',
'email' => 'john.parent@example.com',
'relation' => 'Father',
],
],
];
$response = $this->postJson('/api/v1/parents/registration', $payload);
$response->assertStatus(201);
$response->assertJson(['ok' => true]);
$this->assertDatabaseHas('students', ['firstname' => 'Sara', 'parent_id' => $parent->id]);
$this->assertDatabaseHas('emergency_contacts', ['parent_id' => $parent->id, 'emergency_contact_name' => 'John Parent']);
}
private function seedParent(): User
{
$id = DB::table('users')->insertGetId([
'firstname' => 'Parent',
'lastname' => 'User',
'cellphone' => '1234567890',
'email' => 'parent@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
return User::query()->findOrFail($id);
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
['config_key' => 'date_age_reference', 'config_value' => '2025-12-31'],
['config_key' => 'max_kids', 'config_value' => '5'],
['config_key' => 'max_emergency', 'config_value' => '5'],
['config_key' => 'enrollment_deadline', 'config_value' => '2025-09-01'],
]);
}
}
@@ -0,0 +1,108 @@
<?php
namespace Tests\Feature\Api\V1\Reports;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class SlipPrinterControllerTest extends TestCase
{
use RefreshDatabase;
public function test_preview_returns_text(): void
{
$this->seedConfig();
$user = $this->seedUser();
Sanctum::actingAs($user);
$response = $this->postJson('/api/v1/reports/slips/preview', [
'student_name' => 'Ali Student',
'school_year' => '2025-2026',
]);
$response->assertOk();
$response->assertJson(['ok' => true]);
$this->assertNotEmpty($response->json('text'));
}
public function test_print_creates_log_and_returns_pdf(): void
{
$this->seedConfig();
$user = $this->seedUser();
Sanctum::actingAs($user);
$response = $this->postJson('/api/v1/reports/slips/print', [
'student_name' => 'Nora Student',
'school_year' => '2025-2026',
'date' => '09/01/2025',
'time_in' => '8:10 AM',
'grade' => '3',
]);
$response->assertOk();
$this->assertSame('application/pdf', $response->headers->get('content-type'));
$this->assertDatabaseHas('late_slip_logs', [
'student_name' => 'Nora Student',
'school_year' => '2025-2026',
]);
}
public function test_logs_returns_rows(): void
{
$this->seedConfig();
$user = $this->seedUser();
DB::table('late_slip_logs')->insert([
'school_year' => '2025-2026',
'semester' => 'fall',
'student_name' => 'Log Student',
'slip_date' => '2025-09-01',
'time_in' => '08:00:00',
'grade' => '2',
'reason' => 'Late',
'admin_name' => 'Admin',
'printed_by' => $user->id,
'printed_at' => now(),
]);
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/reports/slips/logs?school_year=2025-2026');
$response->assertOk();
$response->assertJson(['ok' => true]);
$this->assertNotEmpty($response->json('logs'));
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
]);
}
private function seedUser(): User
{
$userId = DB::table('users')->insertGetId([
'firstname' => 'Admin',
'lastname' => 'User',
'cellphone' => '9999999999',
'email' => 'slip.printer@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
return User::query()->findOrFail($userId);
}
}
@@ -0,0 +1,66 @@
<?php
namespace Tests\Feature\Api\V1\Settings;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class ConfigurationControllerTest extends TestCase
{
use RefreshDatabase;
public function test_index_returns_configs(): void
{
DB::table('configuration')->insert([
'config_key' => 'school_year',
'config_value' => '2025-2026',
]);
Sanctum::actingAs($this->seedUser());
$response = $this->getJson('/api/v1/configuration');
$response->assertOk();
$response->assertJson(['ok' => true]);
$this->assertNotEmpty($response->json('configs'));
}
public function test_store_creates_config(): void
{
Sanctum::actingAs($this->seedUser());
$response = $this->postJson('/api/v1/configuration', [
'config_key' => 'semester',
'config_value' => 'Fall',
]);
$response->assertStatus(201);
$this->assertDatabaseHas('configuration', [
'config_key' => 'semester',
'config_value' => 'Fall',
]);
}
private function seedUser(): User
{
$userId = DB::table('users')->insertGetId([
'firstname' => 'Admin',
'lastname' => 'User',
'cellphone' => '3333333333',
'email' => 'config@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
return User::query()->findOrFail($userId);
}
}
@@ -0,0 +1,128 @@
<?php
namespace Tests\Feature\Api\V1\Students;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class StudentControllerTest extends TestCase
{
use RefreshDatabase;
public function test_assign_and_remove_class(): void
{
$this->seedConfig();
$user = $this->seedUser();
$studentId = $this->seedStudent();
$classSectionId = $this->seedClassSection();
Sanctum::actingAs($user);
$assignResponse = $this->postJson('/api/v1/students/assign-class', [
'student_id' => $studentId,
'class_section_id' => [$classSectionId],
]);
$assignResponse->assertOk();
$this->assertDatabaseHas('student_class', [
'student_id' => $studentId,
'class_section_id' => $classSectionId,
]);
$removeResponse = $this->postJson('/api/v1/students/remove-class', [
'student_id' => $studentId,
'class_section_id' => $classSectionId,
]);
$removeResponse->assertOk();
$this->assertDatabaseMissing('student_class', [
'student_id' => $studentId,
'class_section_id' => $classSectionId,
]);
}
public function test_score_card_returns_rows(): void
{
$this->seedConfig();
$user = $this->seedUser();
$studentId = $this->seedStudent();
$this->seedClassSection();
DB::table('semester_scores')->insert([
'student_id' => $studentId,
'class_section_id' => 701,
'school_year' => '2025-2026',
'semester' => 'Fall',
'semester_score' => 90,
]);
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/students/' . $studentId . '/score-card');
$response->assertOk();
$response->assertJson(['ok' => true]);
$this->assertNotEmpty($response->json('rows'));
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
]);
}
private function seedUser(): User
{
$userId = DB::table('users')->insertGetId([
'firstname' => 'Admin',
'lastname' => 'User',
'cellphone' => '7777777777',
'email' => 'student.controller@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
return User::query()->findOrFail($userId);
}
private function seedStudent(): int
{
return DB::table('students')->insertGetId([
'school_id' => 'S-900',
'firstname' => 'Omar',
'lastname' => 'Student',
'dob' => '2014-09-01',
'age' => 11,
'gender' => 'Male',
'photo_consent' => 1,
'parent_id' => 1,
'year_of_registration' => '2025',
'school_year' => '2025-2026',
'semester' => 'Fall',
]);
}
private function seedClassSection(): int
{
DB::table('classSection')->insert([
'class_id' => 1,
'class_section_id' => 701,
'class_section_name' => '7A',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
return 701;
}
}
@@ -0,0 +1,95 @@
<?php
namespace Tests\Feature\Api\V1\Subjects;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class SubjectCurriculumControllerTest extends TestCase
{
use RefreshDatabase;
public function test_index_returns_entries(): void
{
$user = $this->seedUser();
$classId = $this->seedClass();
$this->seedEntry($classId);
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/subjects/curriculum');
$response->assertOk();
$response->assertJson(['ok' => true]);
$this->assertNotEmpty($response->json('entries'));
}
public function test_store_creates_entry(): void
{
$user = $this->seedUser();
$classId = $this->seedClass();
Sanctum::actingAs($user);
$response = $this->postJson('/api/v1/subjects/curriculum', [
'class_id' => $classId,
'subject' => 'islamic',
'unit_number' => 1,
'unit_title' => 'Faith',
'chapter_name' => 'Intro',
]);
$response->assertStatus(201);
$this->assertDatabaseHas('subject_curriculum_items', [
'class_id' => $classId,
'chapter_name' => 'Intro',
]);
}
private function seedUser(): User
{
$userId = DB::table('users')->insertGetId([
'firstname' => 'Admin',
'lastname' => 'User',
'cellphone' => '1111111111',
'email' => 'curriculum@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
return User::query()->findOrFail($userId);
}
private function seedClass(): int
{
return DB::table('classes')->insertGetId([
'class_name' => 'Grade 2',
'schedule' => 'Sunday',
'capacity' => 25,
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
}
private function seedEntry(int $classId): void
{
DB::table('subject_curriculum_items')->insert([
'class_id' => $classId,
'subject' => 'islamic',
'unit_number' => 1,
'unit_title' => 'Faith',
'chapter_name' => 'Intro',
'created_at' => now(),
'updated_at' => now(),
]);
}
}
@@ -0,0 +1,61 @@
<?php
namespace Tests\Feature\Api\V1\System;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class SchoolIdControllerTest extends TestCase
{
use RefreshDatabase;
public function test_generate_student_returns_id(): void
{
$user = User::factory()->create();
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/system/school-ids/student');
$response->assertOk();
$response->assertJson(['ok' => true]);
$response->assertJsonPath('result.type', 'student');
$this->assertNotEmpty($response->json('result.school_id'));
}
public function test_generate_user_returns_id(): void
{
$user = User::factory()->create();
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/system/school-ids/user');
$response->assertOk();
$response->assertJson(['ok' => true]);
$response->assertJsonPath('result.type', 'user');
$this->assertNotEmpty($response->json('result.school_id'));
}
public function test_assign_sets_user_school_id(): void
{
$user = User::factory()->create();
Sanctum::actingAs($user);
$target = User::factory()->create([
'school_id' => null,
]);
$response = $this->postJson('/api/v1/system/school-ids/assign', [
'user_id' => $target->id,
]);
$response->assertOk();
$response->assertJson(['ok' => true]);
$this->assertNotEmpty($response->json('result.school_id'));
$this->assertSame(
$response->json('result.school_id'),
User::query()->findOrFail($target->id)->school_id
);
}
}
@@ -0,0 +1,166 @@
<?php
namespace Tests\Feature\Api\V1\Teachers;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class TeacherControllerTest extends TestCase
{
use RefreshDatabase;
public function test_classes_returns_students_and_assignments(): void
{
$this->seedConfig();
$teacher = $this->seedTeacherUser();
$classSectionId = $this->seedClassSection();
$this->seedTeacherAssignment($teacher->id, $classSectionId);
$this->seedStudent($teacher->id, $classSectionId);
Sanctum::actingAs($teacher);
$response = $this->getJson('/api/v1/teachers/classes?class_section_id=' . $classSectionId);
$response->assertOk();
$response->assertJson(['ok' => true]);
$this->assertNotEmpty($response->json('students'));
$this->assertSame($classSectionId, $response->json('active_class_section_id'));
}
public function test_switch_class_returns_active_id(): void
{
$this->seedConfig();
$teacher = $this->seedTeacherUser();
$classSectionId = $this->seedClassSection();
$this->seedTeacherAssignment($teacher->id, $classSectionId);
Sanctum::actingAs($teacher);
$response = $this->postJson('/api/v1/teachers/classes/switch', [
'class_section_id' => $classSectionId,
]);
$response->assertOk();
$response->assertJsonPath('active_class_section_id', $classSectionId);
}
public function test_absence_submit_creates_staff_attendance(): void
{
Carbon::setTestNow(Carbon::parse('2025-10-01'));
$this->seedConfig();
$teacher = $this->seedTeacherUser();
Sanctum::actingAs($teacher);
$formResponse = $this->getJson('/api/v1/teachers/absence/form');
$formResponse->assertOk();
$date = $formResponse->json('available_dates.0');
$response = $this->postJson('/api/v1/teachers/absence', [
'dates' => [$date],
'reason' => 'Family event',
'reason_type' => 'personal',
]);
$response->assertOk();
$this->assertDatabaseHas('staff_attendance', [
'user_id' => $teacher->id,
'date' => $date,
'status' => 'absent',
]);
Carbon::setTestNow();
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
['config_key' => 'fall_semester_start', 'config_value' => '2025-09-01'],
['config_key' => 'spring_semester_start', 'config_value' => '2026-01-15'],
['config_key' => 'last_school_day', 'config_value' => '2026-06-15'],
]);
}
private function seedTeacherUser(): User
{
$roleId = DB::table('roles')->insertGetId([
'name' => 'teacher',
]);
$userId = DB::table('users')->insertGetId([
'firstname' => 'Tara',
'lastname' => 'Teacher',
'cellphone' => '4444444444',
'email' => 'teacher.feature@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
DB::table('user_roles')->insert([
'user_id' => $userId,
'role_id' => $roleId,
]);
return User::query()->findOrFail($userId);
}
private function seedClassSection(): int
{
DB::table('classSection')->insert([
'class_id' => 1,
'class_section_id' => 301,
'class_section_name' => '3A',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
return 301;
}
private function seedTeacherAssignment(int $teacherId, int $classSectionId): void
{
DB::table('teacher_class')->insert([
'teacher_id' => $teacherId,
'class_section_id' => $classSectionId,
'position' => 'main',
'school_year' => '2025-2026',
'created_at' => now(),
'updated_at' => now(),
]);
}
private function seedStudent(int $parentId, int $classSectionId): void
{
$studentId = DB::table('students')->insertGetId([
'school_id' => 'S-600',
'firstname' => 'Kai',
'lastname' => 'Student',
'dob' => '2014-09-01',
'age' => 11,
'gender' => 'Male',
'photo_consent' => 1,
'parent_id' => $parentId,
'year_of_registration' => '2025',
'school_year' => '2025-2026',
'semester' => 'Fall',
]);
DB::table('student_class')->insert([
'student_id' => $studentId,
'class_section_id' => $classSectionId,
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
}
}
@@ -0,0 +1,68 @@
<?php
namespace Tests\Unit\Services\EmergencyContacts;
use App\Models\EmergencyContact;
use App\Models\Student;
use App\Models\User;
use App\Services\EmergencyContacts\EmergencyContactDirectoryService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class EmergencyContactDirectoryServiceTest extends TestCase
{
use RefreshDatabase;
public function test_groups_include_parent_students_contacts_and_phones(): void
{
$parent = User::factory()->create([
'firstname' => 'Salma',
'lastname' => 'Parent',
'cellphone' => '1111111111',
]);
DB::table('parents')->insert([
'secondparent_firstname' => 'Hadi',
'secondparent_lastname' => 'Parent',
'secondparent_gender' => 'Male',
'secondparent_email' => 'second.parent@example.com',
'secondparent_phone' => '2222222222',
'firstparent_id' => $parent->id,
'secondparent_id' => 999,
'semester' => 'Fall',
'school_year' => '2025-2026',
'created_at' => now(),
'updated_at' => now(),
]);
Student::factory()->create([
'parent_id' => $parent->id,
'firstname' => 'Layla',
'lastname' => 'Student',
'school_id' => 'S-101',
]);
EmergencyContact::query()->create([
'parent_id' => $parent->id,
'emergency_contact_name' => 'Aunt Sara',
'cellphone' => '3333333333',
'email' => 'sara@example.com',
'relation' => 'Aunt',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
$service = app(EmergencyContactDirectoryService::class);
$groups = $service->groups();
$this->assertCount(1, $groups);
$group = $groups[0];
$this->assertSame($parent->id, $group['parent_id']);
$this->assertSame('Salma Parent', $group['parent_name']);
$this->assertSame(['1111111111', '2222222222'], $group['parent_phones']);
$this->assertNotEmpty($group['students']);
$this->assertNotEmpty($group['contacts']);
}
}
@@ -0,0 +1,93 @@
<?php
namespace Tests\Unit\Services\Exams;
use App\Services\Exams\ExamDraftConfigService;
use App\Services\Exams\ExamDraftFileService;
use App\Services\Exams\ExamDraftTeacherService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class ExamDraftTeacherServiceTest extends TestCase
{
use RefreshDatabase;
public function test_store_creates_draft(): void
{
$this->seedConfig();
$teacherId = $this->seedTeacher();
$classSectionId = $this->seedClassSection();
$this->seedAssignment($teacherId, $classSectionId);
$service = new ExamDraftTeacherService(new ExamDraftConfigService(), new ExamDraftFileService());
$file = UploadedFile::fake()->create('draft.docx', 10, 'application/vnd.openxmlformats-officedocument.wordprocessingml.document');
$result = $service->store($teacherId, [
'class_section_id' => $classSectionId,
'exam_type' => 'Final Exam',
'description' => 'Draft',
], $file);
$this->assertTrue($result['ok']);
$this->assertDatabaseHas('exam_drafts', [
'teacher_id' => $teacherId,
'class_section_id' => $classSectionId,
'status' => 'submitted',
]);
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
]);
}
private function seedTeacher(): int
{
return DB::table('users')->insertGetId([
'firstname' => 'Teacher',
'lastname' => 'User',
'cellphone' => '1111111111',
'email' => 'teacher.exam@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
}
private function seedClassSection(): int
{
DB::table('classSection')->insert([
'class_id' => 1,
'class_section_id' => 801,
'class_section_name' => '8A',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
return 801;
}
private function seedAssignment(int $teacherId, int $classSectionId): void
{
DB::table('teacher_class')->insert([
'teacher_id' => $teacherId,
'class_section_id' => $classSectionId,
'position' => 'main',
'school_year' => '2025-2026',
'created_at' => now(),
'updated_at' => now(),
]);
}
}
@@ -0,0 +1,85 @@
<?php
namespace Tests\Unit\Services\Parents;
use App\Services\Parents\ParentAttendanceReportCalendarService;
use App\Services\Parents\ParentAttendanceReportService;
use App\Services\Parents\ParentConfigService;
use App\Services\SemesterRangeService;
use App\Services\Semesters\SemesterConfigService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class ParentAttendanceReportServiceTest extends TestCase
{
use RefreshDatabase;
public function test_form_data_returns_students(): void
{
$this->seedConfig();
$parentId = $this->seedParent();
$this->seedStudent($parentId);
$service = new ParentAttendanceReportService(
new ParentConfigService(),
new ParentAttendanceReportCalendarService(new ParentConfigService()),
new SemesterRangeService(new SemesterConfigService())
);
$data = $service->formData($parentId);
$this->assertSame($parentId, $data['students'][0]['parent_id']);
$this->assertNotEmpty($data['sundays']);
}
private function seedParent(): int
{
return DB::table('users')->insertGetId([
'firstname' => 'Parent',
'lastname' => 'User',
'cellphone' => '1234567890',
'email' => 'parent.report.service@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
}
private function seedStudent(int $parentId): void
{
DB::table('students')->insert([
'school_id' => 'S-400',
'firstname' => 'Casey',
'lastname' => 'Parent',
'dob' => '2014-09-01',
'age' => 11,
'gender' => 'Female',
'photo_consent' => 1,
'parent_id' => $parentId,
'year_of_registration' => '2025',
'school_year' => '2025-2026',
'semester' => 'Fall',
]);
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
['config_key' => 'date_age_reference', 'config_value' => '2025-12-31'],
['config_key' => 'parent_report_cutoff', 'config_value' => '23:59'],
['config_key' => 'fall_semester_start', 'config_value' => '2025-09-01'],
['config_key' => 'spring_semester_start', 'config_value' => '2026-01-15'],
['config_key' => 'last_school_day', 'config_value' => '2026-06-15'],
]);
}
}
@@ -0,0 +1,74 @@
<?php
namespace Tests\Unit\Services\Parents;
use App\Models\User;
use App\Services\Parents\ParentAttendanceService;
use App\Services\Parents\ParentConfigService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class ParentAttendanceServiceTest extends TestCase
{
use RefreshDatabase;
public function test_list_attendance_returns_rows(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
['config_key' => 'date_age_reference', 'config_value' => '2025-12-31'],
]);
$parentId = DB::table('users')->insertGetId([
'firstname' => 'Parent',
'lastname' => 'User',
'cellphone' => '1234567890',
'email' => 'parent2@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
$studentId = DB::table('students')->insertGetId([
'school_id' => 'S-101',
'firstname' => 'Maya',
'lastname' => 'Parent',
'dob' => '2014-09-01',
'age' => 11,
'gender' => 'Female',
'photo_consent' => 1,
'parent_id' => $parentId,
'year_of_registration' => '2025',
'school_year' => '2025-2026',
'semester' => 'Fall',
]);
DB::table('attendance_data')->insert([
'class_id' => 1,
'class_section_id' => 1,
'student_id' => $studentId,
'school_id' => '1',
'date' => '2025-10-02',
'status' => 'late',
'reason' => 'Traffic',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
$service = new ParentAttendanceService(new ParentConfigService());
$result = $service->listAttendance($parentId, '2025-2026');
$this->assertSame('2025-2026', $result['selectedYear']);
$this->assertCount(1, $result['attendance']);
$this->assertSame('late', $result['attendance'][0]['status']);
}
}
@@ -0,0 +1,35 @@
<?php
namespace Tests\Unit\Services\Parents;
use App\Services\Parents\ParentConfigService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class ParentConfigServiceTest extends TestCase
{
use RefreshDatabase;
public function test_context_returns_config_values(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
['config_key' => 'date_age_reference', 'config_value' => '2025-12-31'],
['config_key' => 'max_kids', 'config_value' => '4'],
['config_key' => 'max_emergency', 'config_value' => '2'],
['config_key' => 'enrollment_deadline', 'config_value' => '2025-09-01'],
['config_key' => 'refund_deadline', 'config_value' => '2025-09-15'],
['config_key' => 'fall_semester_start', 'config_value' => '2025-09-05'],
]);
$service = new ParentConfigService();
$context = $service->context();
$this->assertSame('2025-2026', $context['school_year']);
$this->assertSame('Fall', $context['semester']);
$this->assertSame(4, $context['max_kids']);
$this->assertSame(2, $context['max_emergency']);
}
}
@@ -0,0 +1,60 @@
<?php
namespace Tests\Unit\Services\Parents;
use App\Services\Parents\ParentConfigService;
use App\Services\Parents\ParentEmergencyContactService;
use App\Services\PhoneFormatterService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class ParentEmergencyContactServiceTest extends TestCase
{
use RefreshDatabase;
public function test_store_creates_contact(): void
{
$this->seedConfig();
$parentId = $this->seedParent();
$service = new ParentEmergencyContactService(new ParentConfigService(), new PhoneFormatterService());
$contact = $service->store($parentId, [
'name' => 'Sam Contact',
'cellphone' => '1234567890',
'email' => 'sam@example.com',
'relation' => 'Uncle',
]);
$this->assertSame('Sam Contact', $contact['emergency_contact_name']);
$this->assertDatabaseHas('emergency_contacts', ['parent_id' => $parentId, 'emergency_contact_name' => 'Sam Contact']);
}
private function seedParent(): int
{
return DB::table('users')->insertGetId([
'firstname' => 'Parent',
'lastname' => 'User',
'cellphone' => '1234567890',
'email' => 'parent5@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
]);
}
}
@@ -0,0 +1,84 @@
<?php
namespace Tests\Unit\Services\Parents;
use App\Services\Parents\ParentConfigService;
use App\Services\Parents\ParentEnrollmentService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class ParentEnrollmentServiceTest extends TestCase
{
use RefreshDatabase;
public function test_overview_returns_students(): void
{
$this->seedConfig();
$parentId = $this->seedParent();
$studentId = DB::table('students')->insertGetId([
'school_id' => 'S-200',
'firstname' => 'Lana',
'lastname' => 'Parent',
'dob' => '2013-09-01',
'age' => 12,
'gender' => 'Female',
'photo_consent' => 1,
'parent_id' => $parentId,
'year_of_registration' => '2025',
'school_year' => '2025-2026',
'semester' => 'Fall',
]);
DB::table('enrollments')->insert([
'student_id' => $studentId,
'parent_id' => $parentId,
'school_year' => '2025-2026',
'semester' => 'Fall',
'enrollment_date' => '2025-09-01',
'enrollment_status' => 'enrolled',
'admission_status' => 'accepted',
'is_withdrawn' => 0,
]);
$service = new ParentEnrollmentService(new ParentConfigService());
$result = $service->overview($parentId, '2025-2026');
$this->assertSame('2025-2026', $result['selectedYear']);
$this->assertCount(1, $result['students']);
$this->assertSame('enrolled', $result['students'][0]['enrollment_status']);
}
private function seedParent(): int
{
return DB::table('users')->insertGetId([
'firstname' => 'Parent',
'lastname' => 'User',
'cellphone' => '1234567890',
'email' => 'parent3@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
['config_key' => 'date_age_reference', 'config_value' => '2025-12-31'],
['config_key' => 'enrollment_deadline', 'config_value' => '2025-09-01'],
['config_key' => 'refund_deadline', 'config_value' => '2025-09-15'],
['config_key' => 'fall_semester_start', 'config_value' => '2025-09-05'],
]);
}
}
@@ -0,0 +1,63 @@
<?php
namespace Tests\Unit\Services\Parents;
use App\Services\Parents\ParentInvoiceService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class ParentInvoiceServiceTest extends TestCase
{
use RefreshDatabase;
public function test_list_invoices_filters_by_parent(): void
{
$parentId = $this->seedParent();
$otherParentId = $this->seedParent('other@example.com');
DB::table('invoices')->insert([
'parent_id' => $parentId,
'invoice_number' => 'INV-1',
'total_amount' => 100,
'paid_amount' => 0,
'balance' => 100,
'issue_date' => '2025-09-01',
]);
DB::table('invoices')->insert([
'parent_id' => $otherParentId,
'invoice_number' => 'INV-2',
'total_amount' => 50,
'paid_amount' => 0,
'balance' => 50,
'issue_date' => '2025-09-02',
]);
$service = new ParentInvoiceService();
$rows = $service->listInvoices($parentId);
$this->assertCount(1, $rows);
$this->assertSame('INV-1', $rows[0]['invoice_number']);
}
private function seedParent(string $email = 'parent@example.com'): int
{
return DB::table('users')->insertGetId([
'firstname' => 'Parent',
'lastname' => 'User',
'cellphone' => '1234567890',
'email' => $email,
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
}
}
@@ -0,0 +1,78 @@
<?php
namespace Tests\Unit\Services\Parents;
use App\Services\Parents\ParentConfigService;
use App\Services\Parents\ParentRegistrationService;
use App\Services\SchoolIdService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class ParentRegistrationServiceTest extends TestCase
{
use RefreshDatabase;
public function test_register_creates_student_and_contact(): void
{
$this->seedConfig();
$parentId = $this->seedParent();
$service = new ParentRegistrationService(new ParentConfigService(), new SchoolIdService());
$result = $service->register($parentId, [
[
'firstname' => 'Omar',
'lastname' => 'Parent',
'dob' => '2015-06-01',
'gender' => 'Male',
'registration_grade' => '3',
'photo_consent' => true,
'is_new' => true,
'allergies' => ['Eggs'],
'medical_conditions' => ['Asthma'],
],
], [
[
'name' => 'Nora Parent',
'cellphone' => '1234567890',
'email' => 'nora@example.com',
'relation' => 'Mother',
],
]);
$this->assertNotEmpty($result['created_student_ids']);
$this->assertDatabaseHas('students', ['firstname' => 'Omar', 'parent_id' => $parentId]);
$this->assertDatabaseHas('emergency_contacts', ['parent_id' => $parentId, 'emergency_contact_name' => 'Nora Parent']);
}
private function seedParent(): int
{
return DB::table('users')->insertGetId([
'firstname' => 'Parent',
'lastname' => 'User',
'cellphone' => '1234567890',
'email' => 'parent4@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
['config_key' => 'date_age_reference', 'config_value' => '2025-12-31'],
['config_key' => 'max_kids', 'config_value' => '5'],
['config_key' => 'max_emergency', 'config_value' => '5'],
]);
}
}
@@ -0,0 +1,21 @@
<?php
namespace Tests\Unit\Services\Reports;
use App\Services\Reports\SlipPrinterFormatterService;
use Tests\TestCase;
class SlipPrinterFormatterServiceTest extends TestCase
{
public function test_to_db_date_parses_us_format(): void
{
$service = new SlipPrinterFormatterService();
$this->assertSame('2025-09-01', $service->toDbDate('09/01/2025'));
}
public function test_to_db_time_parses_string(): void
{
$service = new SlipPrinterFormatterService();
$this->assertSame('08:15:00', $service->toDbTime('8:15 AM'));
}
}
@@ -0,0 +1,38 @@
<?php
namespace Tests\Unit\Services\SchoolIds;
use App\Models\User;
use App\Services\SchoolIds\SchoolIdAssignmentService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class SchoolIdAssignmentServiceTest extends TestCase
{
use RefreshDatabase;
public function test_assigns_school_id_when_missing(): void
{
$user = User::factory()->create([
'school_id' => null,
]);
$service = app(SchoolIdAssignmentService::class);
$schoolId = $service->assignToUser($user->id);
$this->assertNotNull($schoolId);
$this->assertSame($schoolId, User::query()->findOrFail($user->id)->school_id);
}
public function test_assign_returns_existing_school_id(): void
{
$user = User::factory()->create([
'school_id' => '2500001',
]);
$service = app(SchoolIdAssignmentService::class);
$schoolId = $service->assignToUser($user->id);
$this->assertSame('2500001', $schoolId);
}
}
@@ -0,0 +1,32 @@
<?php
namespace Tests\Unit\Services\SchoolIds;
use App\Services\SchoolIds\SchoolIdGenerationService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class SchoolIdGenerationServiceTest extends TestCase
{
use RefreshDatabase;
public function test_generates_student_school_id_with_prefix(): void
{
$service = app(SchoolIdGenerationService::class);
$schoolId = $service->generateStudentId();
$year = date('y');
$this->assertStringStartsWith('STU' . $year, $schoolId);
$this->assertSame(10, strlen($schoolId));
}
public function test_generates_user_school_id_with_prefix(): void
{
$service = app(SchoolIdGenerationService::class);
$schoolId = $service->generateUserId();
$year = date('y');
$this->assertStringStartsWith($year, $schoolId);
$this->assertSame(7, strlen($schoolId));
}
}
@@ -0,0 +1,27 @@
<?php
namespace Tests\Unit\Services\Settings;
use App\Services\Settings\ConfigurationService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ConfigurationServiceTest extends TestCase
{
use RefreshDatabase;
public function test_store_creates_config(): void
{
$service = new ConfigurationService();
$config = $service->store([
'config_key' => 'school_year',
'config_value' => '2025-2026',
]);
$this->assertNotNull($config->id);
$this->assertDatabaseHas('configuration', [
'id' => $config->id,
'config_key' => 'school_year',
]);
}
}
@@ -0,0 +1,95 @@
<?php
namespace Tests\Unit\Services\Students;
use App\Services\Students\StudentAssignmentService;
use App\Services\Students\StudentConfigService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class StudentAssignmentServiceTest extends TestCase
{
use RefreshDatabase;
public function test_assign_creates_student_class_rows(): void
{
$this->seedConfig();
$studentId = $this->seedStudent();
$classSectionId = $this->seedClassSection();
$service = new StudentAssignmentService(new StudentConfigService());
$result = $service->assignClasses($studentId, [$classSectionId], false);
$this->assertTrue($result['ok']);
$this->assertDatabaseHas('student_class', [
'student_id' => $studentId,
'class_section_id' => $classSectionId,
'school_year' => '2025-2026',
]);
}
public function test_remove_deletes_assignment(): void
{
$this->seedConfig();
$studentId = $this->seedStudent();
$classSectionId = $this->seedClassSection();
DB::table('student_class')->insert([
'student_id' => $studentId,
'class_section_id' => $classSectionId,
'semester' => 'Fall',
'school_year' => '2025-2026',
'created_at' => now(),
'updated_at' => now(),
]);
$service = new StudentAssignmentService(new StudentConfigService());
$result = $service->removeClass($studentId, $classSectionId);
$this->assertTrue($result['ok']);
$this->assertDatabaseMissing('student_class', [
'student_id' => $studentId,
'class_section_id' => $classSectionId,
'school_year' => '2025-2026',
]);
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
]);
}
private function seedStudent(): int
{
return DB::table('students')->insertGetId([
'school_id' => 'S-700',
'firstname' => 'Mina',
'lastname' => 'Student',
'dob' => '2014-09-01',
'age' => 11,
'gender' => 'Female',
'photo_consent' => 1,
'parent_id' => 1,
'year_of_registration' => '2025',
'school_year' => '2025-2026',
'semester' => 'Fall',
]);
}
private function seedClassSection(): int
{
DB::table('classSection')->insert([
'class_id' => 1,
'class_section_id' => 501,
'class_section_name' => '5A',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
return 501;
}
}
@@ -0,0 +1,61 @@
<?php
namespace Tests\Unit\Services\Students;
use App\Services\Students\StudentProfileService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class StudentProfileServiceTest extends TestCase
{
use RefreshDatabase;
public function test_update_student_saves_allergies(): void
{
$studentId = $this->seedStudent();
$service = new StudentProfileService();
$result = $service->updateStudent($studentId, [
'firstname' => 'Lee',
'lastname' => 'Student',
'dob' => '2014-09-01',
'age' => 11,
'gender' => 'Male',
'registration_grade' => '1',
'photo_consent' => true,
'parent_id' => 1,
'registration_date' => '2025-09-01',
'tuition_paid' => false,
'year_of_registration' => '2025',
'school_year' => '2025-2026',
'rfid_tag' => 'RF-1',
'semester' => 'Fall',
'is_new' => true,
'allergies' => 'Peanuts',
]);
$this->assertTrue($result['ok']);
$this->assertDatabaseHas('student_allergies', [
'student_id' => $studentId,
'allergy' => 'Peanuts',
]);
}
private function seedStudent(): int
{
return DB::table('students')->insertGetId([
'school_id' => 'S-850',
'firstname' => 'Lee',
'lastname' => 'Student',
'dob' => '2014-09-01',
'age' => 11,
'gender' => 'Male',
'photo_consent' => 1,
'parent_id' => 1,
'year_of_registration' => '2025',
'school_year' => '2025-2026',
'semester' => 'Fall',
]);
}
}
@@ -0,0 +1,71 @@
<?php
namespace Tests\Unit\Services\Students;
use App\Services\Students\StudentScoreCardService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class StudentScoreCardServiceTest extends TestCase
{
use RefreshDatabase;
public function test_score_card_returns_rows_and_comments(): void
{
$studentId = $this->seedStudent();
$this->seedClassSection();
DB::table('semester_scores')->insert([
'student_id' => $studentId,
'class_section_id' => 601,
'school_year' => '2025-2026',
'semester' => 'Fall',
'semester_score' => 88,
]);
DB::table('score_comments')->insert([
'student_id' => $studentId,
'school_year' => '2025-2026',
'semester' => 'Fall',
'score_type' => 'midterm',
'comment_review' => 'Great effort',
'created_at' => now(),
]);
$service = new StudentScoreCardService();
$result = $service->scoreCard($studentId);
$this->assertTrue($result['ok']);
$this->assertSame('S-800', $result['student']['school_id']);
$this->assertSame('Great effort', $result['rows'][0]['comments']['midterm']);
}
private function seedStudent(): int
{
return DB::table('students')->insertGetId([
'school_id' => 'S-800',
'firstname' => 'Zane',
'lastname' => 'Student',
'dob' => '2014-09-01',
'age' => 11,
'gender' => 'Male',
'photo_consent' => 1,
'parent_id' => 1,
'year_of_registration' => '2025',
'school_year' => '2025-2026',
'semester' => 'Fall',
]);
}
private function seedClassSection(): void
{
DB::table('classSection')->insert([
'class_id' => 1,
'class_section_id' => 601,
'class_section_name' => '6A',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
}
}
@@ -0,0 +1,73 @@
<?php
namespace Tests\Unit\Services\Subjects;
use App\Services\Subjects\SubjectCurriculumService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class SubjectCurriculumServiceTest extends TestCase
{
use RefreshDatabase;
public function test_store_creates_entry(): void
{
$classId = $this->seedClass();
$service = new SubjectCurriculumService();
$entry = $service->store([
'class_id' => $classId,
'subject' => 'islamic',
'unit_number' => 1,
'unit_title' => 'Faith',
'chapter_name' => 'Intro',
]);
$this->assertNotNull($entry->id);
$this->assertDatabaseHas('subject_curriculum_items', [
'id' => $entry->id,
'class_id' => $classId,
]);
}
public function test_update_changes_title(): void
{
$classId = $this->seedClass();
$entryId = DB::table('subject_curriculum_items')->insertGetId([
'class_id' => $classId,
'subject' => 'quran',
'unit_number' => 2,
'unit_title' => 'Old',
'chapter_name' => 'Chapter 1',
'created_at' => now(),
'updated_at' => now(),
]);
$service = new SubjectCurriculumService();
$entry = $service->update($entryId, [
'class_id' => $classId,
'subject' => 'quran',
'unit_number' => 2,
'unit_title' => 'New',
'chapter_name' => 'Chapter 1',
]);
$this->assertNotNull($entry);
$this->assertDatabaseHas('subject_curriculum_items', [
'id' => $entryId,
'unit_title' => 'New',
]);
}
private function seedClass(): int
{
return DB::table('classes')->insertGetId([
'class_name' => 'Grade 1',
'schedule' => 'Sunday',
'capacity' => 20,
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
}
}
@@ -0,0 +1,108 @@
<?php
namespace Tests\Unit\Services\Teachers;
use App\Libraries\StaffTimeOffLinkService;
use App\Services\SemesterRangeService;
use App\Services\Semesters\SemesterConfigService;
use App\Services\Teachers\TeacherAbsenceService;
use App\Services\Teachers\TeacherConfigService;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class TeacherAbsenceServiceTest extends TestCase
{
use RefreshDatabase;
public function test_form_data_returns_available_dates(): void
{
Carbon::setTestNow(Carbon::parse('2025-10-01'));
$this->seedConfig();
$teacherId = $this->seedTeacherUser();
$service = new TeacherAbsenceService(
new TeacherConfigService(),
new SemesterRangeService(new SemesterConfigService()),
new StaffTimeOffLinkService()
);
$data = $service->formData($teacherId);
$this->assertSame('Fall', $data['semester']);
$this->assertNotEmpty($data['available_dates']);
Carbon::setTestNow();
}
public function test_submit_creates_staff_attendance(): void
{
Carbon::setTestNow(Carbon::parse('2025-10-01'));
$this->seedConfig();
$teacherId = $this->seedTeacherUser();
$service = new TeacherAbsenceService(
new TeacherConfigService(),
new SemesterRangeService(new SemesterConfigService()),
new StaffTimeOffLinkService()
);
$date = $service->formData($teacherId)['available_dates'][0];
$result = $service->submit($teacherId, [
'dates' => [$date],
'reason' => 'Family event',
'reason_type' => 'personal',
]);
$this->assertTrue($result['ok']);
$this->assertDatabaseHas('staff_attendance', [
'user_id' => $teacherId,
'date' => $date,
'status' => 'absent',
]);
Carbon::setTestNow();
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
['config_key' => 'fall_semester_start', 'config_value' => '2025-09-01'],
['config_key' => 'spring_semester_start', 'config_value' => '2026-01-15'],
['config_key' => 'last_school_day', 'config_value' => '2026-06-15'],
]);
}
private function seedTeacherUser(): int
{
$roleId = DB::table('roles')->insertGetId([
'name' => 'teacher',
]);
$userId = DB::table('users')->insertGetId([
'firstname' => 'Nina',
'lastname' => 'Teacher',
'cellphone' => '3333333333',
'email' => 'teacher.absence@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
DB::table('user_roles')->insert([
'user_id' => $userId,
'role_id' => $roleId,
]);
return $userId;
}
}
@@ -0,0 +1,117 @@
<?php
namespace Tests\Unit\Services\Teachers;
use App\Services\Teachers\TeacherAssignmentService;
use App\Services\Teachers\TeacherConfigService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class TeacherAssignmentServiceTest extends TestCase
{
use RefreshDatabase;
public function test_assign_creates_teacher_class_row(): void
{
$this->seedConfig();
$teacherId = $this->seedTeacherUser();
$classSectionId = $this->seedClassSection();
$service = new TeacherAssignmentService(new TeacherConfigService());
$result = $service->assign([
'teacher_id' => $teacherId,
'class_section_id' => $classSectionId,
'teacher_role' => 'teacher',
]);
$this->assertTrue($result['ok']);
$this->assertDatabaseHas('teacher_class', [
'teacher_id' => $teacherId,
'class_section_id' => $classSectionId,
'position' => 'main',
]);
}
public function test_delete_removes_assignment(): void
{
$this->seedConfig();
$teacherId = $this->seedTeacherUser();
$classSectionId = $this->seedClassSection();
DB::table('teacher_class')->insert([
'teacher_id' => $teacherId,
'class_section_id' => $classSectionId,
'position' => 'ta',
'school_year' => '2025-2026',
'created_at' => now(),
'updated_at' => now(),
]);
$service = new TeacherAssignmentService(new TeacherConfigService());
$result = $service->delete([
'teacher_id' => $teacherId,
'class_section_id' => $classSectionId,
'position' => 'ta',
]);
$this->assertTrue($result['ok']);
$this->assertDatabaseMissing('teacher_class', [
'teacher_id' => $teacherId,
'class_section_id' => $classSectionId,
'position' => 'ta',
]);
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
]);
}
private function seedTeacherUser(): int
{
$roleId = DB::table('roles')->insertGetId([
'name' => 'teacher',
]);
$userId = DB::table('users')->insertGetId([
'firstname' => 'Alex',
'lastname' => 'Teacher',
'cellphone' => '2222222222',
'email' => 'teacher.assignment@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
DB::table('user_roles')->insert([
'user_id' => $userId,
'role_id' => $roleId,
]);
return $userId;
}
private function seedClassSection(): int
{
DB::table('classSection')->insert([
'class_id' => 1,
'class_section_id' => 201,
'class_section_name' => '2A',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
return 201;
}
}
@@ -0,0 +1,118 @@
<?php
namespace Tests\Unit\Services\Teachers;
use App\Services\Teachers\TeacherConfigService;
use App\Services\Teachers\TeacherDashboardService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class TeacherDashboardServiceTest extends TestCase
{
use RefreshDatabase;
public function test_class_view_returns_students(): void
{
$this->seedConfig();
$teacherId = $this->seedTeacherUser();
$classSectionId = $this->seedClassSection();
$this->seedTeacherAssignment($teacherId, $classSectionId);
$this->seedStudent($teacherId, $classSectionId);
$service = new TeacherDashboardService(new TeacherConfigService());
$data = $service->classView($teacherId, $classSectionId);
$this->assertSame($classSectionId, $data['active_class_section_id']);
$this->assertNotEmpty($data['classes']);
$this->assertNotEmpty($data['students']);
}
private function seedConfig(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
]);
}
private function seedTeacherUser(): int
{
$roleId = DB::table('roles')->insertGetId([
'name' => 'teacher',
]);
$userId = DB::table('users')->insertGetId([
'firstname' => 'Tina',
'lastname' => 'Teacher',
'cellphone' => '1111111111',
'email' => 'teacher.dashboard@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'password' => bcrypt('password'),
'user_type' => 'primary',
'semester' => 'Fall',
'school_year' => '2025-2026',
'status' => 'Active',
]);
DB::table('user_roles')->insert([
'user_id' => $userId,
'role_id' => $roleId,
]);
return $userId;
}
private function seedClassSection(): int
{
DB::table('classSection')->insert([
'class_id' => 1,
'class_section_id' => 101,
'class_section_name' => '1A',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
return 101;
}
private function seedTeacherAssignment(int $teacherId, int $classSectionId): void
{
DB::table('teacher_class')->insert([
'teacher_id' => $teacherId,
'class_section_id' => $classSectionId,
'position' => 'main',
'school_year' => '2025-2026',
'created_at' => now(),
'updated_at' => now(),
]);
}
private function seedStudent(int $parentId, int $classSectionId): void
{
$studentId = DB::table('students')->insertGetId([
'school_id' => 'S-500',
'firstname' => 'Sam',
'lastname' => 'Student',
'dob' => '2014-09-01',
'age' => 11,
'gender' => 'Male',
'photo_consent' => 1,
'parent_id' => $parentId,
'year_of_registration' => '2025',
'school_year' => '2025-2026',
'semester' => 'Fall',
]);
DB::table('student_class')->insert([
'student_id' => $studentId,
'class_section_id' => $classSectionId,
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
}
}