50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services\AttendanceTracking;
|
|
|
|
use App\Models\AttendanceData;
|
|
use App\Services\AttendancePendingViolationService;
|
|
use App\Services\AttendanceViolationStudentResolverService;
|
|
use App\Services\ViolationRuleEngineService;
|
|
use Mockery;
|
|
use Tests\TestCase;
|
|
|
|
class AttendancePendingViolationServiceTest extends TestCase
|
|
{
|
|
protected function tearDown(): void
|
|
{
|
|
Mockery::close();
|
|
parent::tearDown();
|
|
}
|
|
|
|
public function test_get_pending_violations_returns_error_when_no_student_identifiers_found(): void
|
|
{
|
|
$attendanceData = Mockery::mock(AttendanceData::class);
|
|
$rules = Mockery::mock(ViolationRuleEngineService::class);
|
|
$resolver = Mockery::mock(AttendanceViolationStudentResolverService::class);
|
|
|
|
$resolver->shouldReceive('resolveForSchoolYear')
|
|
->once()
|
|
->with('2025-2026', null)
|
|
->andReturn([
|
|
'school_year' => '2025-2026',
|
|
'semester' => null,
|
|
'student_ids' => [],
|
|
'student_codes' => [],
|
|
'students' => [],
|
|
'student_code_to_id' => [],
|
|
'existing_ids' => [],
|
|
'debug' => [
|
|
'class_students' => 0,
|
|
'student_ids' => 0,
|
|
],
|
|
]);
|
|
|
|
$service = new AttendancePendingViolationService($attendanceData, $rules, $resolver);
|
|
|
|
$result = $service->getPendingViolations('2025-2026');
|
|
|
|
$this->assertSame([], $result['students']);
|
|
$this->assertSame('No student identifiers found for the current school year.', $result['error']);
|
|
}
|
|
} |