add controllers, servoices
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\Semesters;
|
||||
|
||||
use App\Services\Semesters\SemesterConfigService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SemesterConfigServiceTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_reads_dates_from_configuration(): void
|
||||
{
|
||||
DB::table('configuration')->insert([
|
||||
['id' => 1, 'config_key' => 'fall_semester_start', 'config_value' => '2025-09-01'],
|
||||
['id' => 2, 'config_key' => 'spring_semester_start', 'config_value' => '2026-01-20'],
|
||||
['id' => 3, 'config_key' => 'last_school_day', 'config_value' => '2026-06-01'],
|
||||
]);
|
||||
|
||||
$service = new SemesterConfigService();
|
||||
$this->assertSame('2025-09-01', $service->getFallStart()?->format('Y-m-d'));
|
||||
$this->assertSame('2026-01-20', $service->getSpringStart()?->format('Y-m-d'));
|
||||
$this->assertSame('2026-06-01', $service->getLastSchoolDay()?->format('Y-m-d'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\Semesters;
|
||||
|
||||
use App\Services\SemesterRangeService;
|
||||
use App\Services\Semesters\SemesterConfigService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SemesterRangeServiceTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_get_school_year_range_falls_back_when_config_missing(): void
|
||||
{
|
||||
$service = new SemesterRangeService(new SemesterConfigService());
|
||||
[$start, $end] = $service->getSchoolYearRange('2025-2026');
|
||||
|
||||
$this->assertSame('2025-09-01', $start);
|
||||
$this->assertSame('2026-06-30', $end);
|
||||
}
|
||||
|
||||
public function test_get_semester_for_date_uses_config_dates(): void
|
||||
{
|
||||
DB::table('configuration')->insert([
|
||||
['id' => 1, 'config_key' => 'fall_semester_start', 'config_value' => '2025-09-01'],
|
||||
['id' => 2, 'config_key' => 'spring_semester_start', 'config_value' => '2026-01-20'],
|
||||
['id' => 3, 'config_key' => 'last_school_day', 'config_value' => '2026-06-01'],
|
||||
]);
|
||||
|
||||
$service = new SemesterRangeService(new SemesterConfigService());
|
||||
$semester = $service->getSemesterForDate('2025-10-01');
|
||||
|
||||
$this->assertSame('Fall', $semester);
|
||||
}
|
||||
|
||||
public function test_normalize_semester(): void
|
||||
{
|
||||
$service = new SemesterRangeService(new SemesterConfigService());
|
||||
|
||||
$this->assertSame('Fall', $service->normalizeSemester('fall'));
|
||||
$this->assertSame('Spring', $service->normalizeSemester('SPRING'));
|
||||
$this->assertSame('', $service->normalizeSemester('winter'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user