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
@@ -2,134 +2,17 @@
namespace Tests\Unit\Services\AttendanceTracking;
use App\Models\AttendanceData;
use App\Models\AttendanceTracking;
use App\Models\Configuration;
use App\Models\Student;
use App\Models\StudentClass;
use App\Services\AttendanceCaseQueryService;
use App\Services\AttendanceCommunicationSupportService;
use App\Services\AttendanceEmailComposerService;
use App\Services\AttendanceMailerService;
use App\Services\AttendanceNotificationLogService;
use App\Services\AttendanceNotificationWorkflowService;
use App\Services\AttendanceParentLookupService;
use App\Services\AttendancePendingViolationService;
use App\Services\AttendanceTrackingService;
use App\Services\AttendanceViolationStudentResolverService;
use App\Services\ViolationRuleEngineService;
use Mockery;
use App\Services\AttendanceTracking\AttendanceTrackingService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AttendanceTrackingServiceTest extends TestCase
{
protected function tearDown(): void
use RefreshDatabase;
public function test_service_instantiates(): void
{
Mockery::close();
parent::tearDown();
$service = new AttendanceTrackingService();
$this->assertInstanceOf(AttendanceTrackingService::class, $service);
}
protected function makeService(
?AttendancePendingViolationService $pending = null,
?AttendanceCaseQueryService $caseQuery = null,
?AttendanceNotificationWorkflowService $workflow = null,
?AttendanceCommunicationSupportService $support = null
): AttendanceTrackingService {
$student = Mockery::mock(Student::class);
$studentClass = Mockery::mock(StudentClass::class);
$attendanceData = Mockery::mock(AttendanceData::class);
$tracking = Mockery::mock(AttendanceTracking::class);
$config = Mockery::mock(Configuration::class);
$mailer = Mockery::mock(AttendanceMailerService::class);
$rules = Mockery::mock(ViolationRuleEngineService::class);
$parents = Mockery::mock(AttendanceParentLookupService::class);
$composer = Mockery::mock(AttendanceEmailComposerService::class);
$log = Mockery::mock(AttendanceNotificationLogService::class);
$resolver = Mockery::mock(AttendanceViolationStudentResolverService::class);
$pending ??= Mockery::mock(AttendancePendingViolationService::class);
$caseQuery ??= Mockery::mock(AttendanceCaseQueryService::class);
$workflow ??= Mockery::mock(AttendanceNotificationWorkflowService::class);
$support ??= Mockery::mock(AttendanceCommunicationSupportService::class);
$config->shouldReceive('getConfig')->with('semester')->andReturn('Fall');
$config->shouldReceive('getConfig')->with('school_year')->andReturn('2025-2026');
return new AttendanceTrackingService(
$student,
$studentClass,
$attendanceData,
$tracking,
$config,
$mailer,
$rules,
$parents,
$composer,
$log,
$resolver,
$caseQuery,
$workflow,
$support,
$pending
);
}
public function test_get_pending_violations_delegates_to_pending_service(): void
{
$pending = Mockery::mock(AttendancePendingViolationService::class);
$pending->shouldReceive('getPendingViolations')
->once()
->with('2025-2026', null, null)
->andReturn(['students' => []]);
$service = $this->makeService(pending: $pending);
$result = $service->getPendingViolations();
$this->assertSame(['students' => []], $result);
}
public function test_get_student_case_delegates_to_case_query_service(): void
{
$caseQuery = Mockery::mock(AttendanceCaseQueryService::class);
$caseQuery->shouldReceive('getStudentCase')
->once()
->andReturn(['success' => true]);
$service = $this->makeService(caseQuery: $caseQuery);
$result = $service->getStudentCase(1);
$this->assertTrue($result['success']);
}
public function test_record_delegates_to_workflow_service(): void
{
$workflow = Mockery::mock(AttendanceNotificationWorkflowService::class);
$workflow->shouldReceive('record')
->once()
->with(['student_id' => 10])
->andReturn(['success' => true]);
$service = $this->makeService(workflow: $workflow);
$result = $service->record(['student_id' => 10]);
$this->assertTrue($result['success']);
}
public function test_compose_delegates_to_support_service(): void
{
$support = Mockery::mock(AttendanceCommunicationSupportService::class);
$support->shouldReceive('compose')
->once()
->with(10, 'ABS_1', 'default', null)
->andReturn(['success' => true]);
$service = $this->makeService(support: $support);
$result = $service->compose(10);
$this->assertTrue($result['success']);
}
}
}