Files
alrahma_sunday_school/tests/app/Support/SchoolYear/SchoolYearContextTest.php
T
root feb1b29a32
Tests / PHPUnit (push) Failing after 1m19s
apply the school year concept
2026-07-14 00:59:00 -04:00

42 lines
1.5 KiB
PHP

<?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 testNonActiveContextsAreReadonly(): void
{
$this->assertTrue((new SchoolYearContext(5, '2026-2027', 'draft'))->isReadonly());
$this->assertTrue((new SchoolYearContext(6, '2026-2027', 'closing'))->isReadonly());
$this->assertTrue((new SchoolYearContext(2, '2023-2024', 'closed'))->isReadonly());
$this->assertTrue((new SchoolYearContext(1, '2022-2023', 'archived'))->isReadonly());
$this->assertTrue((new SchoolYearContext(1, '2022-2023', 'archived'))->isHistorical());
}
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());
}
}