@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\App\Support\SchoolYear;
|
||||
|
||||
use App\Support\SchoolYear\SchoolYearContext;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
|
||||
final class SchoolYearContextTest extends CIUnitTestCase
|
||||
{
|
||||
public function testActiveContextIsWritableAndNotReadonly(): void
|
||||
{
|
||||
$context = new SchoolYearContext(4, '2025-2026', 'active', true);
|
||||
|
||||
$this->assertTrue($context->isActive());
|
||||
$this->assertFalse($context->isReadonly());
|
||||
$this->assertTrue($context->isExplicitSelection());
|
||||
$this->assertSame('2025-2026', $context->yearName());
|
||||
}
|
||||
|
||||
public function testClosedAndArchivedContextsAreReadonly(): void
|
||||
{
|
||||
$this->assertTrue((new SchoolYearContext(2, '2023-2024', 'closed'))->isReadonly());
|
||||
$this->assertTrue((new SchoolYearContext(1, '2022-2023', 'archived'))->isReadonly());
|
||||
$this->assertFalse((new SchoolYearContext(5, '2026-2027', 'draft'))->isReadonly());
|
||||
}
|
||||
|
||||
public function testArrayRepresentationIncludesReadonlyState(): void
|
||||
{
|
||||
$context = new SchoolYearContext(3, '2024-2025', 'closed');
|
||||
|
||||
$this->assertSame([
|
||||
'id' => 3,
|
||||
'name' => '2024-2025',
|
||||
'status' => 'closed',
|
||||
'readonly' => true,
|
||||
'explicitSelection' => false,
|
||||
], $context->toArray());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\App\Support\SchoolYear;
|
||||
|
||||
use App\Support\SchoolYear\SchoolYearTableRegistry;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use InvalidArgumentException;
|
||||
|
||||
final class SchoolYearTableRegistryTest extends CIUnitTestCase
|
||||
{
|
||||
public function testClassifiesYearScopedTables(): void
|
||||
{
|
||||
$this->assertSame('YEAR_SCOPED', SchoolYearTableRegistry::categoryOf('invoices'));
|
||||
$this->assertSame('YEAR_SCOPED', SchoolYearTableRegistry::categoryOf('attendance_data'));
|
||||
}
|
||||
|
||||
public function testClassifiesGlobalTables(): void
|
||||
{
|
||||
$this->assertSame('GLOBAL', SchoolYearTableRegistry::categoryOf('users'));
|
||||
$this->assertSame('GLOBAL', SchoolYearTableRegistry::categoryOf('configuration'));
|
||||
}
|
||||
|
||||
public function testClassifiesIdentityTables(): void
|
||||
{
|
||||
$this->assertSame('IDENTITY_WITH_YEAR_RELATION', SchoolYearTableRegistry::categoryOf('students'));
|
||||
$this->assertSame('IDENTITY_WITH_YEAR_RELATION', SchoolYearTableRegistry::categoryOf('teachers'));
|
||||
}
|
||||
|
||||
public function testClassifiesContextTables(): void
|
||||
{
|
||||
$this->assertSame('CONTEXT', SchoolYearTableRegistry::categoryOf('notifications'));
|
||||
$this->assertSame('CONTEXT', SchoolYearTableRegistry::categoryOf('support_requests'));
|
||||
}
|
||||
|
||||
public function testRejectsUnregisteredTables(): void
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
SchoolYearTableRegistry::categoryOf('unknown_table');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user