62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?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',
|
|
]);
|
|
}
|
|
}
|