92 lines
3.6 KiB
PHP
92 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Mahasiswa;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\Concerns\FakesLegacyDatabase;
|
|
use Tests\Concerns\InspectsHtml;
|
|
use Tests\TestCase;
|
|
|
|
/** Transkrip dari nilai asli DB lama untuk mahasiswa yang masuk lewat provider legacy. */
|
|
class LegacyTranskripTest extends TestCase
|
|
{
|
|
use FakesLegacyDatabase;
|
|
use InspectsHtml;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->useLegacyDatabase();
|
|
$this->post(route('login.store'), ['username' => 'D1041191001', 'password' => 'rahasia-mhs'])
|
|
->assertRedirect(route('mahasiswa.dashboard'));
|
|
}
|
|
|
|
/** @return list<string> */
|
|
private function courseNames(): array
|
|
{
|
|
$response = $this->get(route('mahasiswa.transkrip'))->assertOk();
|
|
$cells = $this->dom($response)->query('//tbody/tr/td[contains(@class, "table__title")]');
|
|
|
|
return array_map(fn ($cell): string => trim($cell->textContent), iterator_to_array($cells));
|
|
}
|
|
|
|
public function test_transcript_lists_counted_courses_once(): void
|
|
{
|
|
$this->seedLegacyGrades();
|
|
|
|
$this->assertSame(['Algoritma', 'Basis Data', 'Jaringan Komputer', 'Etika Profesi'], $this->courseNames());
|
|
}
|
|
|
|
public function test_retaken_course_keeps_the_best_grade(): void
|
|
{
|
|
$this->seedLegacyGrades();
|
|
|
|
$row = $this->dom($this->get(route('mahasiswa.transkrip')))->query('//tr[td[contains(@class, "table__title") and normalize-space(.) = "Algoritma"]]')->item(0);
|
|
|
|
$this->assertNotNull($row);
|
|
$this->assertStringContainsString('IF101', $row->textContent);
|
|
$this->assertStringNotContainsString('IF101P', $row->textContent);
|
|
$this->assertStringContainsString('4,00', $row->textContent);
|
|
}
|
|
|
|
public function test_summary_follows_legacy_rules(): void
|
|
{
|
|
$this->seedLegacyGrades();
|
|
|
|
$this->get(route('mahasiswa.transkrip'))->assertOk()
|
|
->assertSee('3,07') // IPK: 33,75 / 11
|
|
->assertSee('33,75') // jumlah mutu
|
|
->assertSee('Cetak')
|
|
->assertDontSee('Unduh PDF')
|
|
->assertDontSee('dari 144 SKS');
|
|
|
|
$figures = $this->dom($this->get(route('mahasiswa.transkrip')))->query('//*[contains(@class, "stat__value")]');
|
|
$this->assertSame(['3,07', '11', '8', '4'], array_map(fn ($node): string => trim($node->textContent), iterator_to_array($figures)));
|
|
}
|
|
|
|
public function test_falls_back_to_stored_transcript_for_old_students(): void
|
|
{
|
|
$db = DB::connection('untan');
|
|
$db->table('t_matakuliah')->insert([
|
|
['idmatakuliah' => 50, 'idmastermk' => null, 'kodemk' => 'MK050', 'namamk' => 'Pengantar Ekonomi', 'sks' => 3, 'semester' => 1, 'nilailulus' => 1, 'tipe' => 0],
|
|
['idmatakuliah' => 51, 'idmastermk' => null, 'kodemk' => 'MK051', 'namamk' => 'Bahasa Indonesia', 'sks' => 2, 'semester' => 1, 'nilailulus' => 1, 'tipe' => 0],
|
|
]);
|
|
$db->table('t_transkrip')->insert([
|
|
['idmahasiswa' => 500, 'idmatakuliah' => 50, 'nilaimutu' => 3, 'nilaihuruf' => 'B'],
|
|
['idmahasiswa' => 500, 'idmatakuliah' => 51, 'nilaimutu' => 4, 'nilaihuruf' => 'A'],
|
|
['idmahasiswa' => 501, 'idmatakuliah' => 50, 'nilaimutu' => 1, 'nilaihuruf' => 'D'],
|
|
]);
|
|
|
|
$this->assertSame(['Pengantar Ekonomi', 'Bahasa Indonesia'], $this->courseNames());
|
|
$this->get(route('mahasiswa.transkrip'))->assertSee('3,40'); // (9 + 8) / 5
|
|
}
|
|
|
|
public function test_student_without_grades_sees_empty_state(): void
|
|
{
|
|
$this->get(route('mahasiswa.transkrip'))->assertOk()
|
|
->assertSee('Transkrip masih kosong')
|
|
->assertDontSee('Cetak');
|
|
}
|
|
}
|