67 lines
2.0 KiB
PHP
67 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services\Incidents;
|
|
|
|
use App\Services\Incidents\IncidentHistoryService;
|
|
use App\Services\Incidents\IncidentLookupService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\TestCase;
|
|
|
|
class IncidentHistoryServiceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_processed_enriches_grade_and_updater_names(): void
|
|
{
|
|
DB::table('classSection')->insert([
|
|
'id' => 1,
|
|
'class_id' => 1,
|
|
'class_section_id' => 5,
|
|
'class_section_name' => '5A',
|
|
'semester' => 'Fall',
|
|
'school_year' => '2025-2026',
|
|
]);
|
|
|
|
DB::table('users')->insert([
|
|
'id' => 3,
|
|
'school_id' => 1,
|
|
'firstname' => 'Admin',
|
|
'lastname' => 'User',
|
|
'cellphone' => '5555555555',
|
|
'email' => 'admin@example.com',
|
|
'address_street' => '123 Main',
|
|
'city' => 'City',
|
|
'state' => 'ST',
|
|
'zip' => '12345',
|
|
'accept_school_policy' => 1,
|
|
'is_verified' => 1,
|
|
'status' => 'Active',
|
|
'is_suspended' => 0,
|
|
'failed_attempts' => 0,
|
|
'password' => bcrypt('secret'),
|
|
'semester' => 'Fall',
|
|
'school_year' => '2025-2026',
|
|
]);
|
|
|
|
DB::table('incident')->insert([
|
|
'student_id' => 1,
|
|
'student_name' => 'Student One',
|
|
'grade' => 5,
|
|
'incident' => 'Test incident',
|
|
'incident_datetime' => '2025-01-01 10:00:00',
|
|
'incident_state' => 'open',
|
|
'updated_by_open' => 3,
|
|
'open_description' => 'Opened',
|
|
'semester' => 'Fall',
|
|
'school_year' => '2025-2026',
|
|
]);
|
|
|
|
$service = new IncidentHistoryService(new IncidentLookupService);
|
|
$rows = $service->processed('2025-2026', 'Fall');
|
|
|
|
$this->assertSame('5A', $rows[0]['grade']);
|
|
$this->assertSame('Admin User', $rows[0]['updated_by_open_name']);
|
|
}
|
|
}
|