add controllers, servoices
This commit is contained in:
@@ -2,49 +2,39 @@
|
||||
|
||||
namespace Tests\Unit\Services\AttendanceTracking;
|
||||
|
||||
use App\Models\AttendanceData;
|
||||
use App\Services\AttendancePendingViolationService;
|
||||
use App\Services\AttendanceViolationStudentResolverService;
|
||||
use App\Services\ViolationRuleEngineService;
|
||||
use App\Services\AttendanceTracking\AttendancePendingViolationService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AttendancePendingViolationServiceTest extends TestCase
|
||||
{
|
||||
protected function tearDown(): void
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_returns_error_when_no_students(): void
|
||||
{
|
||||
Mockery::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
$resolver = Mockery::mock(\App\Services\AttendanceTracking\AttendanceViolationStudentResolverService::class);
|
||||
$resolver->shouldReceive('resolveForSchoolYear')->andReturn([
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
'student_ids' => [],
|
||||
'student_codes' => [],
|
||||
'students' => [],
|
||||
'student_code_to_id' => [],
|
||||
'existing_ids' => [],
|
||||
'debug' => [],
|
||||
]);
|
||||
|
||||
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);
|
||||
$engine = Mockery::mock(\App\Services\AttendanceTracking\ViolationRuleEngineService::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(
|
||||
new \App\Models\AttendanceData(),
|
||||
$engine,
|
||||
$resolver
|
||||
);
|
||||
|
||||
$service = new AttendancePendingViolationService($attendanceData, $rules, $resolver);
|
||||
$result = $service->getPendingViolations('2025-2026', null, null);
|
||||
|
||||
$result = $service->getPendingViolations('2025-2026');
|
||||
|
||||
$this->assertSame([], $result['students']);
|
||||
$this->assertSame('No student identifiers found for the current school year.', $result['error']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user