101 lines
4.0 KiB
PHP
101 lines
4.0 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Mahasiswa;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\Concerns\FakesLegacyDatabase;
|
|
use Tests\TestCase;
|
|
|
|
/** Tagihan dan pembayaran asli (t_keuanganmhs) untuk mahasiswa yang masuk lewat provider legacy. */
|
|
class LegacyPembayaranTest extends TestCase
|
|
{
|
|
use FakesLegacyDatabase;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->useLegacyDatabase();
|
|
$this->post(route('login.store'), ['username' => 'D1041191001', 'password' => 'rahasia-mhs'])
|
|
->assertRedirect(route('mahasiswa.dashboard'));
|
|
}
|
|
|
|
/**
|
|
* Mahasiswa 500. 2019/2020 Genap (365): SPP 3.000.000 dan Registrasi 100.000, keduanya lunas.
|
|
* 2020/2021 Ganjil (368): SPP 3.000.000 dibayar 1.000.000, Registrasi 100.000 belum dibayar, kekurangan 2.100.000.
|
|
* Tidak dihitung: pengembalian (jenis 3) dan baris mahasiswa 501.
|
|
*/
|
|
private function seedFinance(): void
|
|
{
|
|
$this->seedLegacyKrs();
|
|
$db = DB::connection('untan');
|
|
|
|
$db->table('t_periodekuliah')->insert(['idperiode' => 365, 'thakad' => '2019/2020', 'semester' => 2, 'perkuliahan' => 1]);
|
|
$db->table('t_komponenpembayaran')->insert([['idkomponen' => 2, 'namakomponen' => 'SPP'], ['idkomponen' => 4, 'namakomponen' => 'Registrasi']]);
|
|
|
|
$row = fn (int $mhs, int $komponen, int $jenis, int $periode, float $jumlah, ?string $tanggal = null, ?string $kuitansi = null): array => [
|
|
'idmahasiswa' => $mhs, 'idkomponen' => $komponen, 'jenis' => $jenis, 'idperiode' => $periode,
|
|
'jumlah' => $jumlah, 'tgltransaksi' => $tanggal, 'nokuitansi' => $kuitansi,
|
|
];
|
|
$db->table('t_keuanganmhs')->insert([
|
|
$row(500, 2, 1, 365, 3000000), $row(500, 2, 2, 365, 3000000, '2020-02-10', 'K-0365'),
|
|
$row(500, 4, 1, 365, 100000), $row(500, 4, 2, 365, 100000, '2020-02-10', 'K-0366'),
|
|
$row(500, 2, 1, 368, 3000000), $row(500, 2, 2, 368, 1000000, '2020-08-05', 'K-0368'),
|
|
$row(500, 4, 1, 368, 100000),
|
|
$row(500, 2, 3, 368, 777000, '2020-09-01'),
|
|
$row(501, 2, 1, 368, 9999000),
|
|
]);
|
|
}
|
|
|
|
public function test_billing_is_summed_per_semester_and_component(): void
|
|
{
|
|
$this->seedFinance();
|
|
|
|
$this->get(route('mahasiswa.pembayaran'))->assertOk()
|
|
->assertSee('Ada tagihan yang belum tercatat lunas')
|
|
->assertSee('Total kekurangan Rp 2.100.000 pada 1 semester')
|
|
->assertSee('2020/2021 Ganjil')
|
|
->assertSee('Kurang Rp 2.100.000')
|
|
->assertSee('2019/2020 Genap')
|
|
->assertSee('Lunas')
|
|
->assertSee('Rp 3.100.000')
|
|
->assertSee('Registrasi')
|
|
->assertDontSee('9.999.000')
|
|
->assertDontSee('777.000');
|
|
}
|
|
|
|
public function test_payment_history_is_listed_newest_first(): void
|
|
{
|
|
$this->seedFinance();
|
|
|
|
$this->get(route('mahasiswa.pembayaran'))->assertOk()
|
|
->assertSeeInOrder(['K-0368', 'K-0366', 'K-0365'])
|
|
->assertSee('5 Agt 2020');
|
|
}
|
|
|
|
public function test_fully_paid_student_sees_the_success_notice(): void
|
|
{
|
|
$this->seedFinance();
|
|
DB::connection('untan')->table('t_keuanganmhs')->where('idperiode', 368)->delete();
|
|
|
|
$this->get(route('mahasiswa.pembayaran'))->assertOk()
|
|
->assertSee('Seluruh tagihan tercatat lunas')
|
|
->assertDontSee('Ada tagihan yang belum tercatat lunas');
|
|
}
|
|
|
|
public function test_student_without_records_sees_an_empty_state(): void
|
|
{
|
|
$this->seedLegacyKrs();
|
|
|
|
$this->get(route('mahasiswa.pembayaran'))->assertOk()->assertSee('Belum ada catatan keuangan');
|
|
}
|
|
|
|
public function test_proof_upload_is_not_available_for_legacy_accounts(): void
|
|
{
|
|
$this->seedFinance();
|
|
|
|
$this->get(route('mahasiswa.pembayaran'))->assertOk()->assertDontSee('Unggah bukti pembayaran')->assertDontSee('Virtual account');
|
|
$this->post(route('mahasiswa.pembayaran.bukti'), [])->assertNotFound();
|
|
}
|
|
}
|