fix student registration
This commit is contained in:
@@ -66,6 +66,50 @@ class StudentControllerTest extends TestCase
|
||||
$this->assertNotEmpty($response->json('rows'));
|
||||
}
|
||||
|
||||
public function test_store_creates_emergency_contact_for_first_parent(): void
|
||||
{
|
||||
$user = $this->seedUser();
|
||||
$parentId = 1234;
|
||||
|
||||
Sanctum::actingAs($user, [], 'api');
|
||||
$response = $this->postJson('/api/v1/students', [
|
||||
'school_year' => '2025-2026',
|
||||
'firstname' => 'Sara',
|
||||
'lastname' => 'Ahmed',
|
||||
'dob' => '2016-03-25',
|
||||
'age' => 8,
|
||||
'gender' => 'Female',
|
||||
'is_active' => true,
|
||||
'registration_grade' => '3',
|
||||
'is_new' => true,
|
||||
'photo_consent' => true,
|
||||
'parent_id' => $parentId,
|
||||
'registration_date' => '2026-03-25',
|
||||
'tuition_paid' => true,
|
||||
'semester' => 'Fall',
|
||||
'year_of_registration' => 2026,
|
||||
'name' => 'Amina Ahmed',
|
||||
'cellphone' => '5555555555',
|
||||
'email' => 'amina.ahmed@example.com',
|
||||
'relation' => 'Mother',
|
||||
]);
|
||||
|
||||
$response->assertStatus(201);
|
||||
$response->assertJson(['ok' => true]);
|
||||
$this->assertDatabaseHas('students', [
|
||||
'parent_id' => $parentId,
|
||||
'firstname' => 'Sara',
|
||||
'lastname' => 'Ahmed',
|
||||
]);
|
||||
$this->assertDatabaseHas('emergency_contacts', [
|
||||
'parent_id' => $parentId,
|
||||
'emergency_contact_name' => 'Amina Ahmed',
|
||||
'cellphone' => '5555555555',
|
||||
'email' => 'amina.ahmed@example.com',
|
||||
'relation' => 'Mother',
|
||||
]);
|
||||
}
|
||||
|
||||
private function seedConfig(): void
|
||||
{
|
||||
DB::table('configuration')->insert([
|
||||
|
||||
Reference in New Issue
Block a user