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,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',
]);
}
}