Files
alrahma_sunday_school/tests/app/Services/SchoolYearWriteGuardTest.php
T
root e06ccc9cc0
Tests / PHPUnit (push) Failing after 40s
ADD SCHOOL YEAR MANAGEMENT
2026-07-12 02:21:39 -04:00

52 lines
1.3 KiB
PHP

<?php
namespace Tests\App\Services;
use App\Services\SchoolYearWriteGuard;
use App\Support\SchoolYear\SchoolYearContext;
use CodeIgniter\Test\CIUnitTestCase;
use RuntimeException;
final class SchoolYearWriteGuardTest extends CIUnitTestCase
{
public function testAllowsActiveYearWrites(): void
{
$guard = new SchoolYearWriteGuard();
$guard->assertWritable(new SchoolYearContext(4, '2025-2026', 'active'));
$this->assertTrue(true);
}
public function testAllowsDraftOnlyWhenExplicitlyAllowedForAdmin(): void
{
$guard = new SchoolYearWriteGuard();
$guard->assertWritable(
new SchoolYearContext(5, '2026-2027', 'draft'),
allowDraftForAdmin: true,
isAdmin: true
);
$this->assertTrue(true);
}
public function testRejectsClosedYearWrites(): void
{
$this->expectException(RuntimeException::class);
(new SchoolYearWriteGuard())->assertWritable(
new SchoolYearContext(3, '2024-2025', 'closed')
);
}
public function testRejectsDraftYearWritesByDefault(): void
{
$this->expectException(RuntimeException::class);
(new SchoolYearWriteGuard())->assertWritable(
new SchoolYearContext(5, '2026-2027', 'draft')
);
}
}