add more controller

This commit is contained in:
root
2026-03-10 00:48:32 -04:00
parent 5eeaec0257
commit 20ee70d153
151 changed files with 9481 additions and 8407 deletions
@@ -0,0 +1,38 @@
<?php
namespace Tests\Unit\Services\SchoolIds;
use App\Models\User;
use App\Services\SchoolIds\SchoolIdAssignmentService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class SchoolIdAssignmentServiceTest extends TestCase
{
use RefreshDatabase;
public function test_assigns_school_id_when_missing(): void
{
$user = User::factory()->create([
'school_id' => null,
]);
$service = app(SchoolIdAssignmentService::class);
$schoolId = $service->assignToUser($user->id);
$this->assertNotNull($schoolId);
$this->assertSame($schoolId, User::query()->findOrFail($user->id)->school_id);
}
public function test_assign_returns_existing_school_id(): void
{
$user = User::factory()->create([
'school_id' => '2500001',
]);
$service = app(SchoolIdAssignmentService::class);
$schoolId = $service->assignToUser($user->id);
$this->assertSame('2500001', $schoolId);
}
}
@@ -0,0 +1,32 @@
<?php
namespace Tests\Unit\Services\SchoolIds;
use App\Services\SchoolIds\SchoolIdGenerationService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class SchoolIdGenerationServiceTest extends TestCase
{
use RefreshDatabase;
public function test_generates_student_school_id_with_prefix(): void
{
$service = app(SchoolIdGenerationService::class);
$schoolId = $service->generateStudentId();
$year = date('y');
$this->assertStringStartsWith('STU' . $year, $schoolId);
$this->assertSame(10, strlen($schoolId));
}
public function test_generates_user_school_id_with_prefix(): void
{
$service = app(SchoolIdGenerationService::class);
$schoolId = $service->generateUserId();
$year = date('y');
$this->assertStringStartsWith($year, $schoolId);
$this->assertSame(7, strlen($schoolId));
}
}