42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services\Whatsapp;
|
|
|
|
use App\Services\Whatsapp\WhatsappContextService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\TestCase;
|
|
|
|
class WhatsappContextServiceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_school_year_aliases_generate_expected_values(): void
|
|
{
|
|
$service = new WhatsappContextService;
|
|
[$aliases, $canonical, $startYear] = $service->schoolYearAliases('2025/2026');
|
|
|
|
$this->assertContains('2025-2026', $aliases);
|
|
$this->assertSame('2025-2026', $canonical);
|
|
$this->assertSame(2025, $startYear);
|
|
}
|
|
|
|
public function test_has_roster_for_year(): void
|
|
{
|
|
DB::table('student_class')->insert([
|
|
'student_id' => 1,
|
|
'class_section_id' => 1,
|
|
'school_year' => '2025-2026',
|
|
'semester' => 'Fall',
|
|
'is_event_only' => 0,
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]);
|
|
|
|
$service = new WhatsappContextService;
|
|
|
|
$this->assertTrue($service->hasRosterForYear('2025-2026'));
|
|
$this->assertFalse($service->hasRosterForYear('2030-2031'));
|
|
}
|
|
}
|