64 lines
2.0 KiB
PHP
64 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services\AttendanceTracking;
|
|
|
|
use App\Services\AttendanceTracking\AttendanceCommunicationSupportService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Mockery;
|
|
use Tests\TestCase;
|
|
|
|
class AttendanceCommunicationSupportServiceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_compose_requires_student_id(): void
|
|
{
|
|
$service = $this->makeService();
|
|
$result = $service->compose(0);
|
|
|
|
$this->assertFalse($result['success']);
|
|
$this->assertSame(422, $result['status']);
|
|
}
|
|
|
|
public function test_get_violation_dates_for_student(): void
|
|
{
|
|
DB::table('configuration')->insert([
|
|
['config_key' => 'semester', 'config_value' => 'Fall'],
|
|
['config_key' => 'school_year', 'config_value' => '2025-2026'],
|
|
]);
|
|
|
|
DB::table('attendance_data')->insert([
|
|
'class_id' => 1,
|
|
'class_section_id' => 1,
|
|
'student_id' => 1,
|
|
'school_id' => 'S1',
|
|
'date' => '2025-01-01',
|
|
'status' => 'absent',
|
|
'is_reported' => 'no',
|
|
'is_notified' => 'no',
|
|
'semester' => 'Fall',
|
|
'school_year' => '2025-2026',
|
|
]);
|
|
|
|
$service = $this->makeService();
|
|
$dates = $service->getViolationDatesForStudent(1, 'ABS_1', '2025-01-01');
|
|
|
|
$this->assertSame(['2025-01-01'], $dates);
|
|
}
|
|
|
|
private function makeService(): AttendanceCommunicationSupportService
|
|
{
|
|
$parentLookup = Mockery::mock(\App\Services\AttendanceTracking\AttendanceParentLookupService::class);
|
|
$emailComposer = Mockery::mock(\App\Services\AttendanceTracking\AttendanceEmailComposerService::class);
|
|
|
|
return new AttendanceCommunicationSupportService(
|
|
new \App\Models\Student(),
|
|
new \App\Models\AttendanceData(),
|
|
new \App\Models\Configuration(),
|
|
$parentLookup,
|
|
$emailComposer
|
|
);
|
|
}
|
|
}
|