[Mahasiswa] Penambahan Cetak KRS, KHS, dan Transkrip
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\Feature\Mahasiswa;
|
||||
|
||||
use App\Support\Legacy\TranscriptSheet;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\Concerns\FakesLegacyDatabase;
|
||||
use Tests\Concerns\InspectsHtml;
|
||||
@@ -88,4 +89,89 @@ class LegacyTranskripTest extends TestCase
|
||||
->assertSee('Transkrip masih kosong')
|
||||
->assertDontSee('Cetak');
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function sheet(): array
|
||||
{
|
||||
return app(TranscriptSheet::class)->forStudent(500);
|
||||
}
|
||||
|
||||
public function test_pdf_is_streamed_inline_named_after_the_nim(): void
|
||||
{
|
||||
$this->seedLegacyGrades();
|
||||
|
||||
$response = $this->get(route('mahasiswa.transkrip.cetak'))->assertOk();
|
||||
|
||||
$this->assertSame('application/pdf', $response->headers->get('Content-Type'));
|
||||
$this->assertStringContainsString('inline', $response->headers->get('Content-Disposition'));
|
||||
$this->assertStringContainsString('Transkrip - D1041191001.pdf', $response->headers->get('Content-Disposition'));
|
||||
$this->assertStringStartsWith('%PDF', $response->getContent());
|
||||
}
|
||||
|
||||
public function test_page_links_the_print_button_to_the_pdf(): void
|
||||
{
|
||||
$this->seedLegacyGrades();
|
||||
|
||||
$this->get(route('mahasiswa.transkrip'))->assertOk()
|
||||
->assertSee('href="'.route('mahasiswa.transkrip.cetak').'"', false);
|
||||
}
|
||||
|
||||
public function test_sheet_has_the_same_courses_and_figures_as_the_page(): void
|
||||
{
|
||||
$this->seedLegacyGrades();
|
||||
$db = DB::connection('untan');
|
||||
$db->table('t_mahasiswa')->where('idmahasiswa', 500)->update(['tmplahir' => 'PONTIANAK', 'tgllahir' => '1998-05-13']);
|
||||
|
||||
$sheet = $this->sheet();
|
||||
|
||||
$this->assertSame($this->courseNames(), array_column($sheet['matkul'], 'nama'));
|
||||
$this->assertSame([1, 2, 3, 4], array_column($sheet['matkul'], 'no'));
|
||||
$this->assertSame([3.07, 11], [$sheet['ipk'], $sheet['sks']]);
|
||||
$this->assertSame(['D1041191001', 'Rina Lestari', 'Teknik Informatika', 2019], [$sheet['nim'], $sheet['nama'], $sheet['prodi'], $sheet['angkatan']]);
|
||||
$this->assertSame('PONTIANAK, 13/05/1998', $sheet['lahir']);
|
||||
$this->assertNotContains('Nilai Mahasiswa Lain', array_column($sheet['matkul'], 'nama'));
|
||||
}
|
||||
|
||||
public function test_rendered_sheet_has_the_transcript_layout(): void
|
||||
{
|
||||
$this->seedLegacyGrades();
|
||||
|
||||
$html = view('mahasiswa.pdf.transkrip', ['card' => $this->sheet()])->render();
|
||||
|
||||
foreach ([
|
||||
'KEMENTERIAN PENDIDIKAN DAN KEBUDAYAAN', 'UNIVERSITAS TANJUNGPURA', 'FAKULTAS TEKNIK', 'Alamat : Jalan Prof. Dr. H. Hadari Nawawi',
|
||||
'REKAPITULASI NILAI', 'Nama Lengkap</td><td>: Rina Lestari', ': D1041191001', ': Teknik Informatika', ': 2019', ': 3.07 / 11 SKS',
|
||||
'KODE MATA', 'Jaringan Komputer', '3 SKS', 'An. Dekan', 'Wakil Dekan I', 'u.b Kasubbag Akademik',
|
||||
'Lambang Universitas Tanjungpura',
|
||||
] as $text) {
|
||||
$this->assertStringContainsString($text, $html);
|
||||
}
|
||||
|
||||
$this->assertStringNotContainsString('NIP. ', $html, 'Tanpa Kasubbag Akademik terdaftar, baris NIP dihilangkan.');
|
||||
}
|
||||
|
||||
public function test_long_transcripts_continue_in_the_right_column_then_on_a_new_page(): void
|
||||
{
|
||||
$this->seedLegacyGrades();
|
||||
$card = $this->sheet();
|
||||
|
||||
$render = fn (int $rows): string => view('mahasiswa.pdf.transkrip', ['card' => [...$card, 'matkul' => array_map(
|
||||
fn (int $i): array => ['no' => $i, 'kode' => "MK{$i}", 'nama' => "Mata Kuliah {$i}", 'sks' => 2, 'huruf' => 'A'],
|
||||
range(1, $rows),
|
||||
)]])->render();
|
||||
|
||||
// Satu halaman: dua tabel berdampingan (kiri 30 baris), tanda tangan sekali. Lebih dari 60 baris: halaman kedua.
|
||||
$this->assertSame(2, substr_count($render(30), 'KODE MATA'));
|
||||
$this->assertSame(2, substr_count($render(55), 'KODE MATA'));
|
||||
$this->assertSame(0, substr_count($render(55), 'page-break-before'));
|
||||
$long = $render(65);
|
||||
$this->assertSame(4, substr_count($long, 'KODE MATA'));
|
||||
$this->assertSame(1, substr_count($long, 'page-break-before'));
|
||||
$this->assertSame(1, substr_count($long, 'Pontianak, '));
|
||||
}
|
||||
|
||||
public function test_student_without_grades_gets_not_found_for_the_pdf(): void
|
||||
{
|
||||
$this->get(route('mahasiswa.transkrip.cetak'))->assertNotFound();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user