121 lines
5.1 KiB
PHP
121 lines
5.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\App\Views;
|
|
|
|
use CodeIgniter\Test\CIUnitTestCase;
|
|
|
|
final class FamilyCardViewTest extends CIUnitTestCase
|
|
{
|
|
public function testStudentNameExpandsCompleteStudentDetails(): void
|
|
{
|
|
helper('time');
|
|
|
|
$html = view('family/card', [
|
|
'f' => [
|
|
'id' => 9,
|
|
'household_name' => 'Family of Tester',
|
|
'guardians' => [],
|
|
'students' => [[
|
|
'id' => 12,
|
|
'school_id' => 'STU-12',
|
|
'firstname' => 'Test',
|
|
'lastname' => 'Student',
|
|
'dob' => '2015-01-02',
|
|
'age' => 11,
|
|
'gender' => 'Female',
|
|
'grade' => '5 / 5-A',
|
|
'enrollment_status' => 'enrolled',
|
|
'registration_grade' => '5',
|
|
'is_active' => 1,
|
|
'photo_consent' => 1,
|
|
'registration_date' => '2025-09-02 14:30:00',
|
|
'year_of_registration' => '2025',
|
|
'rfid_tag' => 'RF-12',
|
|
'tuition_paid' => 1,
|
|
'allergies' => ['Peanut'],
|
|
'medical_conditions' => ['Asthma'],
|
|
'score_history' => [[
|
|
'school_year' => '2025-2026',
|
|
'midterm_s1' => 88.5,
|
|
'midterm_comment_s1' => 'Strong first semester.',
|
|
'ptap_s1' => 91,
|
|
'ptap_comment_s1' => 'Participates consistently.',
|
|
'attendance_s1' => 95,
|
|
'attendance_comment_s1' => 'Excellent attendance.',
|
|
'final_s2' => 92,
|
|
'final_comment_s2' => 'Excellent finish.',
|
|
'ptap_s2' => 94,
|
|
'ptap_comment_s2' => 'Continued strong participation.',
|
|
'attendance_s2' => 100,
|
|
'attendance_comment_s2' => 'Perfect attendance.',
|
|
'year_score' => 93.25,
|
|
]],
|
|
]],
|
|
'selected_student_id' => 12,
|
|
'emergency_contacts' => [],
|
|
'finance_summary' => [],
|
|
],
|
|
]);
|
|
|
|
$this->assertStringContainsString('Test Student', $html);
|
|
$this->assertStringContainsString('data-bs-target="#fc-student-details-9-12"', $html);
|
|
$this->assertStringContainsString('accordion-collapse collapse show', $html);
|
|
$this->assertStringContainsString('Student Details', $html);
|
|
$this->assertStringContainsString('STU-12', $html);
|
|
$this->assertStringContainsString('5 / 5-A', $html);
|
|
$this->assertStringContainsString('Enrollment Status', $html);
|
|
$this->assertStringNotContainsString('Enrollment School Year', $html);
|
|
$this->assertStringNotContainsString('Enrollment Semester', $html);
|
|
$this->assertStringContainsString('Peanut', $html);
|
|
$this->assertStringContainsString('Asthma', $html);
|
|
$this->assertStringContainsString('Scores History', $html);
|
|
$this->assertStringContainsString('Midterm Comment S1', $html);
|
|
$this->assertStringContainsString('Attendance Comment S2', $html);
|
|
$this->assertStringContainsString('Strong first semester.', $html);
|
|
$this->assertStringContainsString('93.25', $html);
|
|
$this->assertStringNotContainsString('data-family-student-id="12"', $html);
|
|
$this->assertStringNotContainsString('id="fc-tab-fin"', $html);
|
|
$this->assertStringNotContainsString('Invoices:', $html);
|
|
}
|
|
|
|
public function testAdministrativeFamilyCardDisplaysParentInvoices(): void
|
|
{
|
|
helper('time');
|
|
|
|
$html = view('family/card', [
|
|
'f' => [
|
|
'id' => 10,
|
|
'household_name' => 'Family of Admin Test',
|
|
'guardians' => [],
|
|
'students' => [],
|
|
'emergency_contacts' => [],
|
|
'can_view_invoices' => true,
|
|
'finance_summary' => [
|
|
'invoices_count' => 1,
|
|
'total_amount' => 500,
|
|
'paid_amount' => 200,
|
|
'balance' => 300,
|
|
],
|
|
'invoices' => [[
|
|
'parent_id' => 88,
|
|
'parent_name' => 'Parent Person',
|
|
'invoice_number' => 'INV-2026-001',
|
|
'status' => 'Partially Paid',
|
|
'total_amount' => 500,
|
|
'paid_amount' => 200,
|
|
'balance' => 300,
|
|
'issue_date' => '2026-09-01 12:00:00',
|
|
'due_date' => '2026-09-30 12:00:00',
|
|
]],
|
|
'payments' => [],
|
|
],
|
|
]);
|
|
|
|
$this->assertStringContainsString('id="fc-tab-fin"', $html);
|
|
$this->assertStringContainsString('Parent Invoices', $html);
|
|
$this->assertStringContainsString('Parent Person', $html);
|
|
$this->assertStringContainsString('INV-2026-001', $html);
|
|
$this->assertStringContainsString('Invoices: 1', $html);
|
|
}
|
|
}
|