Files
2026-06-11 11:46:12 -04:00

82 lines
2.5 KiB
PHP

<?php
namespace Tests\Unit\Services\Grading;
use App\Services\Grading\HomeworkTrackingCalendarService;
use App\Services\Grading\HomeworkTrackingService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class HomeworkTrackingServiceTest extends TestCase
{
use RefreshDatabase;
public function test_report_returns_teacher_rows(): void
{
DB::table('configuration')->insert([
['id' => 1, 'config_key' => 'school_year', 'config_value' => '2025-2026'],
['id' => 2, 'config_key' => 'semester', 'config_value' => 'Fall'],
]);
DB::table('classSection')->insert([
'id' => 1,
'class_section_id' => 1,
'class_section_name' => '1A',
'class_id' => 1,
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
DB::table('users')->insert([
'id' => 1,
'school_id' => 1,
'firstname' => 'Teacher',
'lastname' => 'User',
'cellphone' => '5555555555',
'email' => 'teacher@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('teacher_class')->insert([
'id' => 1,
'class_section_id' => 1,
'teacher_id' => 1,
'position' => 'main',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
DB::table('homework')->insert([
'id' => 1,
'student_id' => 100,
'school_id' => 1,
'class_section_id' => 1,
'updated_by' => 1,
'homework_index' => 1,
'score' => 90,
'semester' => 'Fall',
'school_year' => '2025-2026',
'created_at' => now(),
'updated_at' => now(),
]);
$service = new HomeworkTrackingService(new HomeworkTrackingCalendarService);
$result = $service->report('Fall', '2025-2026', 1);
$this->assertNotEmpty($result['teachers']);
$this->assertSame(1, $result['teachers'][0]['class_section_id']);
}
}