add controllers, servoices

This commit is contained in:
root
2026-03-09 02:52:13 -04:00
parent c8de5f7edc
commit d76c871cb7
501 changed files with 34439 additions and 21843 deletions
@@ -0,0 +1,111 @@
<?php
namespace Tests\Unit\Services\Attendance;
use App\Services\Attendance\AttendanceQueryService;
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 \App\Models\Configuration(),
new \App\Models\AttendanceData(),
new \App\Models\AttendanceDay(),
new \App\Models\AttendanceRecord(),
new \App\Models\Student(),
new \App\Models\StudentClass(),
new \App\Models\ClassSection(),
new \App\Models\TeacherClass(),
new \App\Models\Calendar(),
new \App\Models\User(),
new \App\Models\UserRole(),
new \App\Services\Attendance\AttendanceService(
new \App\Models\Configuration(),
new \App\Models\AttendanceData(),
new \App\Models\AttendanceDay(),
new \App\Models\ClassSection(),
new \App\Models\UserRole(),
new \App\Services\Attendance\AttendancePolicyService(),
new \App\Services\Attendance\StudentAttendanceWriterService(
new \App\Models\AttendanceData(),
new \App\Models\Student(),
new \App\Services\Attendance\AttendanceRecordSyncService(new \App\Models\AttendanceRecord())
),
new \App\Services\Attendance\TeacherAttendanceSubmissionService(
new \App\Models\AttendanceDay(),
new \App\Models\AttendanceData(),
new \App\Models\TeacherClass(),
new \App\Models\Student(),
new \App\Services\Attendance\AttendancePolicyService(),
new \App\Services\Attendance\StudentAttendanceWriterService(
new \App\Models\AttendanceData(),
new \App\Models\Student(),
new \App\Services\Attendance\AttendanceRecordSyncService(new \App\Models\AttendanceRecord())
)
),
new \App\Services\Attendance\AttendanceRecordSyncService(new \App\Models\AttendanceRecord())
),
new \App\Services\Attendance\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']);
}
}