91 lines
2.7 KiB
PHP
91 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services\Attendance;
|
|
|
|
use App\Services\Attendance\StaffAttendanceService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\TestCase;
|
|
|
|
class StaffAttendanceServiceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_month_data_returns_sections_and_days(): void
|
|
{
|
|
DB::table('configuration')->insert([
|
|
['config_key' => 'semester', 'config_value' => 'Fall'],
|
|
['config_key' => 'school_year', 'config_value' => '2025-2026'],
|
|
]);
|
|
|
|
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-09-07',
|
|
'semester' => 'Fall',
|
|
'school_year' => '2025-2026',
|
|
'status' => 'present',
|
|
'reason' => null,
|
|
]);
|
|
|
|
DB::table('calendar_events')->insert([
|
|
'title' => 'No School',
|
|
'date' => '2025-09-21',
|
|
'no_school' => 1,
|
|
'semester' => 'Fall',
|
|
'school_year' => '2025-2026',
|
|
]);
|
|
|
|
$service = new StaffAttendanceService(
|
|
new \App\Models\Configuration(),
|
|
new \App\Models\StaffAttendance(),
|
|
new \App\Models\TeacherClass(),
|
|
new \App\Models\ClassSection(),
|
|
new \App\Services\Attendance\SemesterRangeService()
|
|
);
|
|
|
|
$payload = $service->monthData('Fall', '2025-2026');
|
|
|
|
$this->assertNotEmpty($payload['sections']);
|
|
$this->assertContains('2025-09-21', $payload['noSchoolDays']);
|
|
}
|
|
}
|