fix registration issue and split parent controller into services
This commit is contained in:
@@ -54,6 +54,50 @@ class StudentModelTest extends ModelCrudTestCase
|
||||
$this->assertNotContains($returningStudentId, $ids);
|
||||
}
|
||||
|
||||
public function testEnrollmentWithdrawalRosterExcludesRegisteredOnlyStudents(): void
|
||||
{
|
||||
$db = Database::connect('tests');
|
||||
$schoolYear = $this->validSchoolYear();
|
||||
$parentId = $this->insertParent($db, 'parent-roster-filter@example.test');
|
||||
$registeredOnlyId = $this->insertStudent($db, $parentId, 'Registered', 'Only');
|
||||
$enrolledId = $this->insertStudent($db, $parentId, 'Roster', 'Student');
|
||||
|
||||
$db->table('student_year_status')->insert([
|
||||
'student_id' => $registeredOnlyId,
|
||||
'school_year' => $schoolYear,
|
||||
'is_new' => 1,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
$db->table('student_year_status')->insert([
|
||||
'student_id' => $enrolledId,
|
||||
'school_year' => $schoolYear,
|
||||
'is_new' => 1,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
$db->table('enrollments')->insert([
|
||||
'student_id' => $enrolledId,
|
||||
'class_section_id' => null,
|
||||
'parent_id' => $parentId,
|
||||
'enrollment_date' => date('Y-m-d'),
|
||||
'enrollment_status' => 'admission under review',
|
||||
'withdrawal_date' => null,
|
||||
'is_withdrawn' => 0,
|
||||
'admission_status' => 'pending',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => $schoolYear,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
$rows = (new StudentModel())->getStudentsWithClassAndEnrollment($schoolYear);
|
||||
$ids = array_map(static fn (array $row): int => (int) $row['id'], $rows);
|
||||
|
||||
$this->assertNotContains($registeredOnlyId, $ids);
|
||||
$this->assertContains($enrolledId, $ids);
|
||||
}
|
||||
|
||||
private function insertParent($db, string $email): int
|
||||
{
|
||||
$db->table('users')->insert([
|
||||
|
||||
Reference in New Issue
Block a user