37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services\ClassPreparation;
|
|
|
|
use App\Services\ClassPreparation\ClassPreparationLogService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\TestCase;
|
|
|
|
class ClassPreparationLogServiceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_has_prep_changed_detects_diff(): void
|
|
{
|
|
$service = new ClassPreparationLogService();
|
|
|
|
$this->assertTrue($service->hasPrepChanged(['a' => 1], ['a' => 2]));
|
|
$this->assertFalse($service->hasPrepChanged(['a' => 1], ['a' => 1]));
|
|
}
|
|
|
|
public function test_create_log_and_get_latest(): void
|
|
{
|
|
$service = new ClassPreparationLogService();
|
|
$created = $service->createLog('101', '1-A', '2025-2026', ['Small Table' => 2], '2025-09-01 00:00:00');
|
|
|
|
$this->assertTrue($created);
|
|
$this->assertDatabaseHas('class_preparation_log', [
|
|
'class_section_id' => 101,
|
|
'school_year' => '2025-2026',
|
|
]);
|
|
|
|
$log = $service->getLatestLog('101', '2025-2026');
|
|
$this->assertNotNull($log);
|
|
}
|
|
}
|