Files
alrahma_sunday_school_api/tests/Unit/Services/Payments/PaymentEventChargesServiceTest.php
T
2026-06-04 02:24:41 -04:00

83 lines
2.5 KiB
PHP

<?php
namespace Tests\Unit\Services\Payments;
use App\Services\Payments\PaymentEventChargesService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class PaymentEventChargesServiceTest extends TestCase
{
use RefreshDatabase;
public function test_get_enrolled_students_returns_grade(): void
{
DB::table('students')->insert([
'id' => 1,
'school_id' => 'S1',
'firstname' => 'Student',
'lastname' => 'One',
'dob' => '2010-01-01',
'age' => 14,
'gender' => 'Male',
'is_active' => 1,
'registration_grade' => '5',
'is_new' => 1,
'photo_consent' => 1,
'parent_id' => 10,
'registration_date' => '2025-01-01',
'tuition_paid' => 0,
'rfid_tag' => null,
'semester' => 'Fall',
'year_of_registration' => '2025',
'school_year' => '2025-2026',
]);
DB::table('enrollments')->insert([
'id' => 1,
'student_id' => 1,
'class_section_id' => 100,
'parent_id' => 10,
'enrollment_date' => '2025-09-01',
'enrollment_status' => 'enrolled',
'withdrawal_date' => null,
'is_withdrawn' => 0,
'admission_status' => 'accepted',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
DB::table('classSection')->insert([
'id' => 1,
'class_id' => 9,
'class_section_id' => 100,
'class_section_name' => 'Section A',
'created_at' => null,
'updated_at' => null,
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
DB::table('student_class')->insert([
'id' => 1,
'student_id' => 1,
'class_section_id' => 100,
'is_event_only' => 0,
'semester' => 'Fall',
'school_year' => '2025-2026',
'description' => null,
'created_at' => '2025-09-01 00:00:00',
'updated_at' => '2025-09-01 00:00:00',
'updated_by' => null,
]);
$service = app(PaymentEventChargesService::class);
$students = $service->getEnrolledStudents(10, '2025-2026');
$this->assertCount(1, $students);
$this->assertSame(1, $students[0]['id']);
$this->assertSame('9', (string) $students[0]['grade']);
}
}