131 lines
4.3 KiB
PHP
131 lines
4.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services\Attendance;
|
|
|
|
use App\Models\AttendanceData;
|
|
use App\Models\AttendanceDay;
|
|
use App\Models\AttendanceRecord;
|
|
use App\Models\Calendar;
|
|
use App\Models\ClassSection;
|
|
use App\Models\Configuration;
|
|
use App\Models\Student;
|
|
use App\Models\StudentClass;
|
|
use App\Models\TeacherClass;
|
|
use App\Models\User;
|
|
use App\Models\UserRole;
|
|
use App\Services\Attendance\AttendanceAutoPublishService;
|
|
use App\Services\Attendance\AttendancePolicyService;
|
|
use App\Services\Attendance\AttendanceQueryService;
|
|
use App\Services\Attendance\AttendanceRecordSyncService;
|
|
use App\Services\Attendance\AttendanceService;
|
|
use App\Services\Attendance\SemesterRangeService;
|
|
use App\Services\Attendance\StudentAttendanceWriterService;
|
|
use App\Services\Attendance\TeacherAttendanceSubmissionService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\TestCase;
|
|
|
|
class AttendanceQueryServiceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_teacher_grid_returns_section_labels_and_grid(): void
|
|
{
|
|
DB::table('classSection')->insert([
|
|
'id' => 1,
|
|
'class_id' => 1,
|
|
'class_section_id' => 10,
|
|
'class_section_name' => '1A',
|
|
'semester' => 'Fall',
|
|
'school_year' => '2025-2026',
|
|
]);
|
|
|
|
DB::table('users')->insert([
|
|
'id' => 1,
|
|
'school_id' => 1,
|
|
'firstname' => 'Teacher',
|
|
'lastname' => 'One',
|
|
'cellphone' => '5555555555',
|
|
'email' => 'teacher@example.com',
|
|
'address_street' => '123 Main',
|
|
'city' => 'City',
|
|
'state' => 'ST',
|
|
'zip' => '12345',
|
|
'accept_school_policy' => 1,
|
|
'is_verified' => 1,
|
|
'status' => 'Active',
|
|
'is_suspended' => 0,
|
|
'failed_attempts' => 0,
|
|
'password' => bcrypt('secret'),
|
|
'semester' => 'Fall',
|
|
'school_year' => '2025-2026',
|
|
]);
|
|
|
|
DB::table('teacher_class')->insert([
|
|
'class_section_id' => 10,
|
|
'teacher_id' => 1,
|
|
'position' => 'main',
|
|
'semester' => 'Fall',
|
|
'school_year' => '2025-2026',
|
|
]);
|
|
|
|
DB::table('staff_attendance')->insert([
|
|
'user_id' => 1,
|
|
'role_name' => 'teacher',
|
|
'date' => '2025-01-05',
|
|
'semester' => 'Fall',
|
|
'school_year' => '2025-2026',
|
|
'status' => 'present',
|
|
'reason' => null,
|
|
]);
|
|
|
|
$service = new AttendanceQueryService(
|
|
new Configuration,
|
|
new AttendanceData,
|
|
new AttendanceDay,
|
|
new AttendanceRecord,
|
|
new Student,
|
|
new StudentClass,
|
|
new ClassSection,
|
|
new TeacherClass,
|
|
new Calendar,
|
|
new User,
|
|
new UserRole,
|
|
new AttendanceService(
|
|
new Configuration,
|
|
new AttendanceData,
|
|
new AttendanceDay,
|
|
new ClassSection,
|
|
new UserRole,
|
|
new AttendancePolicyService,
|
|
new StudentAttendanceWriterService(
|
|
new AttendanceData,
|
|
new Student,
|
|
new AttendanceRecordSyncService(new AttendanceRecord)
|
|
),
|
|
new TeacherAttendanceSubmissionService(
|
|
new AttendanceDay,
|
|
new AttendanceData,
|
|
new TeacherClass,
|
|
new Student,
|
|
new AttendancePolicyService,
|
|
new StudentAttendanceWriterService(
|
|
new AttendanceData,
|
|
new Student,
|
|
new AttendanceRecordSyncService(new AttendanceRecord)
|
|
),
|
|
new AttendanceAutoPublishService
|
|
),
|
|
new AttendanceRecordSyncService(new AttendanceRecord)
|
|
),
|
|
new SemesterRangeService
|
|
);
|
|
|
|
$grid = $service->teacherGrid('Fall', '2025-2026', '2025-01-05', 10);
|
|
|
|
$this->assertSame('1A', $grid['sections'][10]);
|
|
$this->assertSame(1, count($grid['grid']));
|
|
$this->assertSame('present', $grid['grid'][0]['status']);
|
|
}
|
|
}
|