Integrasi Menu Laporan Operator
This commit is contained in:
@@ -521,6 +521,7 @@ trait FakesLegacyDatabase
|
||||
});
|
||||
$schema->create('t_negara', function (Blueprint $table) {
|
||||
$table->integer('idnegara')->primary();
|
||||
$table->smallInteger('kdbenua')->nullable();
|
||||
$table->string('kdnegara')->nullable();
|
||||
$table->string('namanegara');
|
||||
});
|
||||
@@ -548,7 +549,7 @@ trait FakesLegacyDatabase
|
||||
$schema->create('t_jenjangprogdi', function (Blueprint $table) {
|
||||
$table->integer('idjenjang')->primary();
|
||||
$table->string('kdjenjang');
|
||||
$table->char('kode', 1);
|
||||
$table->char('kode', 1)->nullable();
|
||||
$table->integer('minsksbeban')->nullable();
|
||||
$table->smallInteger('mstudimax')->nullable();
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ class LegacyDataPelengkapTest extends TestCase
|
||||
public function test_fakultas_jurusan_dan_prodi(): void
|
||||
{
|
||||
$page = $this->get(route('operator.halaman', 'list_fakultas'))->assertOk()->assertSee('Fakultas asli');
|
||||
$this->assertSame(['', 'Kode', 'Nama Fakultas', 'Nama Singkat', 'Alamat', 'No. Telepon', 'Aktif?', 'Aksi'], $this->headers($page, 'Fakultas'));
|
||||
$this->assertSame(['Kode', 'Nama Fakultas', 'Nama Singkat', 'Alamat', 'No. Telepon', 'Aktif?', 'Aksi'], $this->headers($page, 'Fakultas'));
|
||||
$this->assertSame([['D', 'Fakultas Teknik', 'FT', '–', '–'], ['H', 'Fakultas MIPA', 'FMIPA', '–', 'Ya']], array_map(fn (array $r): array => [$r['kode'], $r['nama'], $r['singkat'], $r['alamat'], $r['aktif']], $this->rows('list_fakultas')));
|
||||
$this->assertCount(1, $this->rows('list_fakultas', ['q' => 'mipa']));
|
||||
|
||||
@@ -61,7 +61,7 @@ class LegacyDataPelengkapTest extends TestCase
|
||||
$this->assertSame(['Teknik Elektro'], array_column($this->rows('list_jurusan', ['fakultas' => 5]), 'nama'));
|
||||
|
||||
$prodi = $this->get(route('operator.halaman', 'list_prodi'))->assertOk();
|
||||
$this->assertSame(['', 'Kode', 'Nama Prodi', 'Nama Singkat', 'Jurusan', 'Ketua Prodi', 'Fakultas / Perguruan Tinggi', 'Status', 'Aksi'], $this->headers($prodi, 'Program Studi'));
|
||||
$this->assertSame(['Kode', 'Nama Prodi', 'Nama Singkat', 'Jurusan', 'Ketua Prodi', 'Fakultas / Perguruan Tinggi', 'Status', 'Aksi'], $this->headers($prodi, 'Program Studi'));
|
||||
foreach (['filter_unit' => 'Fakultas MIPA', 'filter_jenjang' => 'S1', 'filter_status' => 'Tidak aktif'] as $name => $option) {
|
||||
$this->assertGreaterThan(0, $this->dom($prodi)->query("//select[@name='{$name}']/option[normalize-space(text())='{$option}']")->length, $name);
|
||||
}
|
||||
@@ -142,26 +142,6 @@ class LegacyDataPelengkapTest extends TestCase
|
||||
));
|
||||
}
|
||||
|
||||
public function test_template_surat_keterangan_aktif_tampil_untuk_akun_lama_dan_demo(): void
|
||||
{
|
||||
$assert = fn (TestResponse $response): TestResponse => $response->assertOk()
|
||||
->assertSee('<h1>Template Surat Keterangan Aktif</h1>', false)
|
||||
->assertSee('Format No. Surat')->assertSee('{{no_surat}}')->assertSee('{{tahun_surat}}')
|
||||
->assertSee('Kalimat Pembuka')->assertSee('Kepala Biro Akademik dan Kemahasiswaan')
|
||||
->assertSee('Nama Orang Tua Ibu')->assertSee('Kalimat Penutup')
|
||||
->assertSee(now()->month >= 8 ? 'Ganjil '.now()->year.'/'.(now()->year + 1) : 'Genap '.(now()->year - 1).'/'.now()->year)
|
||||
->assertDontSee('Halaman sedang menunggu informasi')->assertDontSee('satuRemoteTable');
|
||||
|
||||
$page = $assert($this->get(route('operator.halaman', 'list_templatesurataktif')));
|
||||
$this->assertCount(11, $this->dom($page)->query("//ol[contains(@class, 'surat-isi')]/li[not(contains(@class, 'surat-isi__gap'))]"));
|
||||
$this->assertSame(['Header', 'Kalimat Pembuka', 'Isi', 'Kalimat Penutup'], array_map(fn ($dt): string => $this->textOf($dt), iterator_to_array($this->dom($page)->query("//dl[contains(@class, 'satu-dl')]/div/dt"))));
|
||||
|
||||
Auth::logout();
|
||||
config(['auth.guards.web.provider' => 'users']);
|
||||
Auth::forgetGuards();
|
||||
$assert($this->actingAs(User::factory()->operator()->create())->get(route('operator.halaman', 'list_templatesurataktif')));
|
||||
}
|
||||
|
||||
public function test_akses(): void
|
||||
{
|
||||
$this->getJson(route('operator.pelengkap.data', 'data_universitas/detail'))->assertNotFound();
|
||||
|
||||
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Operator;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Legacy\Reports\ReportContext;
|
||||
use App\Support\Legacy\Reports\ReportRegistry;
|
||||
use App\Support\Legacy\Reports\ReportResult;
|
||||
use App\Support\Legacy\Reports\ReportSource;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use ReflectionProperty;
|
||||
use Tests\Concerns\FakesLegacyDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
/** Mesin menu Laporan untuk akun DB lama: formulir otomatis, JSON berhalaman, validasi parameter, unduh CSV, cetak, akses. */
|
||||
class LegacyLaporanTest extends TestCase
|
||||
{
|
||||
use FakesLegacyDatabase;
|
||||
use RefreshDatabase;
|
||||
|
||||
private string $slug;
|
||||
|
||||
private ?array $original = null;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->useLegacyDatabase();
|
||||
$this->seedLegacyOverview();
|
||||
|
||||
// Satu slug laporan nyata diarahkan ke sumber tiruan agar mesinnya diuji tanpa bergantung pada data
|
||||
$this->slug = ReportRegistry::slugs()[0];
|
||||
$property = new ReflectionProperty(ReportRegistry::class, 'map');
|
||||
$this->original = $property->getValue();
|
||||
$map = ReportRegistry::slugs();
|
||||
$property->setValue(array_fill_keys($map, FakeReportSource::class));
|
||||
FakeReportSource::$slugs = $map;
|
||||
FakeReportSource::$lastContext = null;
|
||||
FakeReportSource::$lastLimit = null;
|
||||
|
||||
$this->post(route('login.store'), ['username' => '198001012005011001', 'password' => 'rahasia-staf'])
|
||||
->assertRedirect(route('operator.dashboard'));
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
(new ReflectionProperty(ReportRegistry::class, 'map'))->setValue($this->original);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
private function data(array $query = [])
|
||||
{
|
||||
return $this->getJson(route('operator.laporan.data', ['slug' => $this->slug] + $query));
|
||||
}
|
||||
|
||||
public function test_halaman_menjalankan_laporan_otomatis_tanpa_tombol_tampilkan(): void
|
||||
{
|
||||
$this->get(route('operator.halaman', ['slug' => $this->slug]))->assertOk()
|
||||
->assertSee('Parameter laporan')->assertSee('Gunakan KOP')->assertSee('laporanReport', false)
|
||||
->assertSee('Unduh (CSV)')->assertSee('Lihat di Tab Baru')->assertSee('Catatan uji laporan.')
|
||||
->assertSee('Lengkapi parameter yang wajib diisi')->assertDontSee('Tampilkan');
|
||||
|
||||
// Nilai awal dari alamat (bisa dibagikan): pilihan, teks, dan kotak centang
|
||||
$page = $this->get(route('operator.halaman', ['slug' => $this->slug, 'prodi' => '2', 'q' => 'Budi', 'kop' => '0']))->assertOk();
|
||||
// @js menulis tanda kutip JSON sebagai "
|
||||
$json = fn (string $text): string => str_replace('"', chr(92).'u0022', $text);
|
||||
$page->assertSee($json('"prodi":"2"'), false)->assertSee($json('"q":"Budi"'), false);
|
||||
$this->assertStringContainsString($json('"kop":false'), $page->getContent());
|
||||
}
|
||||
|
||||
public function test_json_berhalaman_dengan_penomoran(): void
|
||||
{
|
||||
$first = $this->data(['prodi' => '1'])->assertOk()
|
||||
->assertJsonPath('page', 1)->assertJsonPath('per_page', 25)->assertJsonPath('total', 1500)->assertJsonPath('last_page', 60)->assertJsonPath('from', 1)
|
||||
->assertJsonPath('capped', false)->assertJsonPath('note', 'Catatan hasil.')->assertJsonPath('columns.1.num', true);
|
||||
$this->assertCount(25, $first->json('rows'));
|
||||
$this->assertSame(['nama' => 'Prodi A', 'n' => 1], $first->json('rows.0'));
|
||||
$this->assertSame(26, FakeReportSource::$lastLimit, 'Sumber diminta halaman × per halaman + 1 baris.');
|
||||
|
||||
$second = $this->data(['prodi' => '1', 'page' => 2])->assertOk()->assertJsonPath('page', 2)->assertJsonPath('from', 26);
|
||||
$this->assertSame(26, $second->json('rows.0.n'));
|
||||
$this->assertSame(51, FakeReportSource::$lastLimit);
|
||||
|
||||
$this->data(['prodi' => '2', 'page' => 3, 'per' => 100])->assertOk()->assertJsonPath('per_page', 100)->assertJsonPath('from', 201)->assertJsonPath('rows.0.n', 201)->assertJsonPath('rows.0.nama', 'Prodi B');
|
||||
$this->data(['prodi' => '1', 'per' => 7])->assertOk()->assertJsonPath('per_page', 25);
|
||||
// Halaman di luar jangkauan dijepit ke halaman terakhir
|
||||
$last = $this->data(['prodi' => '1', 'page' => 9999])->assertOk()->assertJsonPath('page', 60)->assertJsonPath('from', 1476);
|
||||
$this->assertCount(25, $last->json('rows'));
|
||||
$this->data(['prodi' => '1', 'page' => 0])->assertOk()->assertJsonPath('page', 1);
|
||||
}
|
||||
|
||||
public function test_batas_baris_yang_bisa_dilihat_berhalaman(): void
|
||||
{
|
||||
$this->data(['prodi' => '1', 'q' => 'besar', 'per' => 100, 'page' => 999])->assertOk()
|
||||
->assertJsonPath('capped', true)->assertJsonPath('cap', 5000)->assertJsonPath('total', 9000)->assertJsonPath('last_page', 50)->assertJsonPath('page', 50);
|
||||
$this->assertSame(5001, FakeReportSource::$lastLimit, 'Pengambilan dibatasi 5.000 baris pertama.');
|
||||
}
|
||||
|
||||
public function test_ringkasan_dan_hasil_kosong(): void
|
||||
{
|
||||
$this->data(['prodi' => '1', 'q' => ' Budi '])->assertOk()->assertJsonPath('summary.0', 'Cari: Budi');
|
||||
$this->data(['prodi' => '2', 'q' => 'kosong'])->assertOk()->assertJsonPath('rows', [])->assertJsonPath('total', 0)->assertJsonPath('last_page', 1)->assertJsonPath('page', 1);
|
||||
}
|
||||
|
||||
public function test_parameter_wajib_dan_tidak_valid_ditolak_422(): void
|
||||
{
|
||||
$this->data()->assertStatus(422)->assertJsonPath('errors.prodi', 'Program Studi wajib diisi.')->assertJsonPath('message', 'Program Studi wajib diisi.');
|
||||
$this->data(['prodi' => '999'])->assertStatus(422)->assertJsonPath('errors.prodi', 'Program Studi tidak valid.');
|
||||
$this->data(['prodi' => '1', 'tgl' => '31-12-2024'])->assertStatus(422)->assertJsonPath('errors.tgl', 'Tanggal tidak valid.');
|
||||
$this->data(['prodi' => '1', 'n' => 'abc'])->assertStatus(422)->assertJsonPath('errors.n', 'Jumlah tidak valid.');
|
||||
$this->data(['prodi' => ['1']])->assertStatus(422)->assertJsonPath('errors.prodi', 'Program Studi wajib diisi.');
|
||||
$this->data(['prodi' => '1', 'tgl' => '2024-02-30'])->assertStatus(422);
|
||||
$this->data(['prodi' => '1', 'tgl' => '2024-02-29', 'n' => '5'])->assertOk();
|
||||
}
|
||||
|
||||
public function test_kesalahan_bisnis_dari_sumber_422(): void
|
||||
{
|
||||
$this->data(['prodi' => '1', 'q' => 'galat'])->assertStatus(422)->assertJsonPath('message', 'Periode belum dipilih.');
|
||||
}
|
||||
|
||||
public function test_konteks_berisi_prodi_akun(): void
|
||||
{
|
||||
$this->data(['prodi' => '1'])->assertOk();
|
||||
|
||||
$this->assertInstanceOf(ReportContext::class, FakeReportSource::$lastContext);
|
||||
$this->assertNotEmpty(FakeReportSource::$lastContext->prodi);
|
||||
$this->assertSame(FakeReportSource::$lastContext->prodi, array_keys(FakeReportSource::$lastContext->prodiNames));
|
||||
}
|
||||
|
||||
public function test_unduh_csv_dengan_bom_dan_semua_baris(): void
|
||||
{
|
||||
$response = $this->get(route('operator.laporan.unduh', ['slug' => $this->slug, 'prodi' => '1', 'q' => 'x']))->assertOk();
|
||||
$this->assertStringContainsString('text/csv', $response->headers->get('Content-Type'));
|
||||
$this->assertStringContainsString('attachment', $response->headers->get('Content-Disposition'));
|
||||
$body = $response->streamedContent();
|
||||
$this->assertStringStartsWith("\xEF\xBB\xBF", $body);
|
||||
$lines = explode("\n", trim(substr($body, 3)));
|
||||
$this->assertSame('Nama,Jumlah', $lines[0]);
|
||||
$this->assertCount(1 + 1500, $lines, 'Unduh memakai batas besar, bukan satu halaman.');
|
||||
$this->assertSame('"Prodi A",1', $lines[1]);
|
||||
}
|
||||
|
||||
public function test_unduh_dan_cetak_dengan_parameter_salah_kembali_ke_halaman(): void
|
||||
{
|
||||
$this->get(route('operator.laporan.unduh', ['slug' => $this->slug]))->assertRedirect(route('operator.halaman', ['slug' => $this->slug]));
|
||||
$this->get(route('operator.laporan.cetak', ['slug' => $this->slug, 'prodi' => '1', 'q' => 'galat']))->assertRedirect(route('operator.halaman', ['slug' => $this->slug, 'prodi' => '1', 'q' => 'galat']));
|
||||
}
|
||||
|
||||
public function test_cetak_dengan_dan_tanpa_kop(): void
|
||||
{
|
||||
$this->get(route('operator.laporan.cetak', ['slug' => $this->slug, 'prodi' => '1', 'kop' => 1]))->assertOk()
|
||||
->assertSee('Universitas Tanjungpura')->assertSee('Sistem Informasi Akademik (SIAKAD)')->assertSee('Program Studi')->assertSee('Prodi A')
|
||||
->assertSee('Dicetak oleh 198001012005011001');
|
||||
$this->get(route('operator.laporan.cetak', ['slug' => $this->slug, 'prodi' => '1']))->assertOk()
|
||||
->assertDontSee('Sistem Informasi Akademik (SIAKAD)');
|
||||
}
|
||||
|
||||
public function test_akses(): void
|
||||
{
|
||||
$query = ['slug' => $this->slug, 'prodi' => '1'];
|
||||
$urls = [route('operator.laporan.data', $query), route('operator.laporan.unduh', $query), route('operator.laporan.cetak', $query)];
|
||||
$page = route('operator.halaman', ['slug' => $this->slug]);
|
||||
|
||||
Auth::logout();
|
||||
foreach ([...$urls, $page] as $url) {
|
||||
$this->get($url)->assertRedirect(route('login'));
|
||||
}
|
||||
|
||||
$this->post(route('login.store'), ['username' => 'D1041191001', 'password' => 'rahasia-mhs']);
|
||||
foreach ([...$urls, $page] as $url) {
|
||||
$this->get($url)->assertForbidden();
|
||||
}
|
||||
|
||||
// Operator akun demo tidak memegang data asli: data/unduh/cetak 404, halamannya tetap prototipe
|
||||
Auth::logout();
|
||||
config(['auth.guards.web.provider' => 'users']);
|
||||
Auth::forgetGuards();
|
||||
$this->actingAs(User::factory()->operator()->create());
|
||||
foreach ($urls as $url) {
|
||||
$this->get($url)->assertNotFound();
|
||||
}
|
||||
$this->get($page)->assertOk()->assertDontSee('Unduh (CSV)')->assertDontSee('laporanReport', false);
|
||||
}
|
||||
|
||||
public function test_slug_tak_terdaftar_404(): void
|
||||
{
|
||||
$this->get('/operator/repp_tidakada/hasil')->assertNotFound();
|
||||
$this->get('/operator/repp_tidakada/cetak')->assertNotFound();
|
||||
$this->get('/operator/repp_tidakada/unduh')->assertNotFound();
|
||||
$this->assertTrue(ReportRegistry::has($this->slug));
|
||||
$this->assertFalse(ReportRegistry::has('repp_tidakada'));
|
||||
}
|
||||
}
|
||||
|
||||
/** Sumber laporan tiruan untuk menguji mesin: satu parameter wajib, teks, tanggal, angka, dan hasil berbatas. */
|
||||
final class FakeReportSource implements ReportSource
|
||||
{
|
||||
/** @var list<string> */
|
||||
public static array $slugs = [];
|
||||
|
||||
public static ?ReportContext $lastContext = null;
|
||||
|
||||
public static ?int $lastLimit = null;
|
||||
|
||||
public function slugs(): array
|
||||
{
|
||||
return self::$slugs;
|
||||
}
|
||||
|
||||
public function definition(string $slug, ReportContext $context): array
|
||||
{
|
||||
return [
|
||||
'note' => 'Catatan uji laporan.',
|
||||
'params' => [
|
||||
['name' => 'prodi', 'label' => 'Program Studi', 'type' => 'select', 'options' => [1 => 'Prodi A', 2 => 'Prodi B'], 'required' => true],
|
||||
['name' => 'q', 'label' => 'Cari', 'type' => 'text'],
|
||||
['name' => 'tgl', 'label' => 'Tanggal', 'type' => 'date'],
|
||||
['name' => 'n', 'label' => 'Jumlah', 'type' => 'number'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function run(string $slug, array $params, ReportContext $context, int $limit): ReportResult
|
||||
{
|
||||
self::$lastContext = $context;
|
||||
self::$lastLimit = $limit;
|
||||
if (($params['q'] ?? null) === 'galat') {
|
||||
throw new PortalException('Periode belum dipilih.');
|
||||
}
|
||||
$columns = [['key' => 'nama', 'label' => 'Nama'], ['key' => 'n', 'label' => 'Jumlah', 'num' => true]];
|
||||
if (($params['q'] ?? null) === 'kosong') {
|
||||
return new ReportResult($columns, []);
|
||||
}
|
||||
|
||||
$total = ($params['q'] ?? null) === 'besar' ? 9000 : 1500;
|
||||
$label = [1 => 'Prodi A', 2 => 'Prodi B'][$params['prodi']];
|
||||
$rows = [];
|
||||
foreach (range(1, min($limit, $total)) as $i) {
|
||||
$rows[] = ['nama' => $label, 'n' => $i];
|
||||
}
|
||||
|
||||
return new ReportResult($columns, $rows, $total, ($params['q'] ?? null) ? ['Cari: '.$params['q']] : [], 'Catatan hasil.');
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,8 @@ class LegacyPerkuliahanCrudTest extends TestCase
|
||||
public function test_mata_kuliah_crud(): void
|
||||
{
|
||||
$this->get(route('operator.halaman', 'list_matakuliah'))->assertOk()
|
||||
->assertSee('Tambah mata kuliah')->assertSee('startInsert()', false)->assertSee('Nilai lulus minimal');
|
||||
->assertSee('Tambah mata kuliah')->assertSee('startInsert()', false)->assertSee('Nilai lulus minimal')
|
||||
->assertSee('placeholder="Masukkan Kode MK"', false)->assertSee('placeholder="Masukkan Nama Mata Kuliah"', false);
|
||||
|
||||
$course = ['kurikulum' => 900, 'jenis' => 1, 'kode' => ' IF399 ', 'nama' => 'Etika Profesi', 'sks' => 2, 'semester' => 6, 'tipe' => 0, 'nilailulus' => 2];
|
||||
$id = $this->postJson(route('operator.matakuliah.store'), $course)->assertCreated()->assertJsonPath('message', 'Mata kuliah ditambahkan.')->json('id');
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Operator;
|
||||
|
||||
use App\Http\Controllers\Operator\PlaceholderPageController;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Tests\Concerns\FakesLegacyDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
/** Halaman SATU tanpa sumber data di DB lama: akun DB lama melihat keterangan menunggu data, akun demo tetap prototipe. */
|
||||
class LegacyPortalPlaceholderTest extends TestCase
|
||||
{
|
||||
use FakesLegacyDatabase;
|
||||
use RefreshDatabase;
|
||||
|
||||
private const string MESSAGE = 'Halaman sedang menunggu informasi terkait isi kontennya yang dimuat';
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->useLegacyDatabase();
|
||||
$this->post(route('login.store'), ['username' => '198001012005011001', 'password' => 'rahasia-staf'])
|
||||
->assertRedirect(route('operator.dashboard'));
|
||||
}
|
||||
|
||||
public function test_pages_without_data_source_show_the_waiting_message(): void
|
||||
{
|
||||
$titles = [
|
||||
'ms_perusahaan' => 'Instansi', 'list_cp' => 'Contact Person', 'ms_kampus' => 'Lokasi Kampus',
|
||||
'ms_bidangilmu' => 'Bidang Ilmu', 'ms_refnilai' => 'Unsur Nilai', 'ms_kelasperkuliahan' => 'Kelas Perkuliahan', 'ms_slotwaktu' => 'Slot Waktu',
|
||||
'ms_statushadir' => 'Status Hadir', 'ms_jenispertemuan' => 'Jenis Pertemuan', 'ms_kelompokperkuliahan' => 'Kel. Perkuliahan',
|
||||
'ms_jeniskegiatan' => 'Jenis Kegiatan Pendukung', 'ms_jenissertifikat' => 'Jenis Sertifikat', 'ms_penyelenggarasertifikat' => 'Penyelenggara Sertifikat',
|
||||
'ms_suku' => 'Suku', 'ms_almamater' => 'Jas Almamater', 'ms_jenistinggal' => 'Jenis Tinggal', 'ms_transport' => 'Transportasi', 'ms_kebutuhankhusus' => 'Kebutuhan Khusus',
|
||||
'ms_predikatdosen' => 'Predikat Dosen', 'ms_honor' => 'Jenis Honor', 'list_honortarif' => 'Tarif Honor', 'ms_kecamatan' => 'Kecamatan',
|
||||
];
|
||||
$this->assertSame(array_keys($titles), PlaceholderPageController::SLUGS);
|
||||
|
||||
foreach ($titles as $slug => $title) {
|
||||
$this->get(route('operator.halaman', $slug))->assertOk()
|
||||
->assertSee(self::MESSAGE)
|
||||
->assertSee('Data belum tersedia di DB')
|
||||
->assertSee('<h1>'.e($title).'</h1>', false)
|
||||
->assertDontSee('satuRemoteTable');
|
||||
}
|
||||
}
|
||||
|
||||
public function test_menu_lists_a_placeholder_page_under_data_pelengkap(): void
|
||||
{
|
||||
$this->get(route('operator.dashboard'))->assertOk()
|
||||
->assertSee(route('operator.halaman', 'ms_perusahaan'))
|
||||
->assertSee('Instansi');
|
||||
}
|
||||
|
||||
public function test_demo_operator_still_sees_the_prototype(): void
|
||||
{
|
||||
Auth::logout();
|
||||
config(['auth.guards.web.provider' => 'users']);
|
||||
Auth::forgetGuards();
|
||||
|
||||
$this->actingAs(User::factory()->operator()->create())
|
||||
->get(route('operator.halaman', 'ms_perusahaan'))->assertOk()
|
||||
->assertDontSee(self::MESSAGE)
|
||||
->assertSee('Daftar Instansi')->assertSee('Nama Instansi');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Operator;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Support\Legacy\ReferenceCrud;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Tests\Concerns\FakesLegacyDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
/** Tambah/ubah/hapus Data Pelengkap (tabel referensi tunggal) untuk akun DB lama, termasuk penjaga rujukan. */
|
||||
class LegacyReferenceCrudTest extends TestCase
|
||||
{
|
||||
use FakesLegacyDatabase;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->useLegacyDatabase();
|
||||
$this->seedLegacyReference();
|
||||
$this->post(route('login.store'), ['username' => '198001012005011001', 'password' => 'rahasia-staf'])
|
||||
->assertRedirect(route('operator.dashboard'));
|
||||
}
|
||||
|
||||
private function db(): ConnectionInterface
|
||||
{
|
||||
return DB::connection('untan');
|
||||
}
|
||||
|
||||
private function store(string $slug, array $data)
|
||||
{
|
||||
return $this->postJson(route('operator.pelengkap.store', $slug), $data);
|
||||
}
|
||||
|
||||
private function update(string $slug, int $id, array $data)
|
||||
{
|
||||
return $this->putJson(route('operator.pelengkap.update', [$slug, $id]), $data);
|
||||
}
|
||||
|
||||
private function destroy(string $slug, array $ids)
|
||||
{
|
||||
return $this->postJson(route('operator.pelengkap.destroy', $slug), ['ids' => $ids]);
|
||||
}
|
||||
|
||||
public function test_gedung_tambah_ubah_hapus(): void
|
||||
{
|
||||
$id = $this->store('list_gedung', ['nama' => ' Gedung Baru ', 'unit' => '5'])->assertCreated()->json('id');
|
||||
$this->assertSame(['namagedung' => 'Gedung Baru', 'idbagian' => 5], (array) $this->db()->table('t_gedung')->where('idgedung', $id)->first(['namagedung', 'idbagian']));
|
||||
|
||||
$this->update('list_gedung', $id, ['nama' => 'Gedung Utama', 'unit' => null])->assertOk();
|
||||
$this->assertSame('Gedung Utama', $this->db()->table('t_gedung')->where('idgedung', $id)->value('namagedung'));
|
||||
$this->assertNull($this->db()->table('t_gedung')->where('idgedung', $id)->value('idbagian'));
|
||||
|
||||
$this->destroy('list_gedung', [$id])->assertOk()->assertJson(['message' => '1 data dihapus.']);
|
||||
$this->assertFalse($this->db()->table('t_gedung')->where('idgedung', $id)->exists());
|
||||
}
|
||||
|
||||
public function test_gedung_menolak_nama_ganda_unit_tak_dikenal_dan_hapus_bila_punya_ruang(): void
|
||||
{
|
||||
$this->store('list_gedung', ['nama' => 'gedung b'])->assertStatus(422)->assertJson(['message' => 'Nama gedung "gedung b" sudah ada.']);
|
||||
$this->store('list_gedung', ['nama' => 'Gedung X', 'unit' => '999'])->assertStatus(422)->assertJsonFragment(['message' => 'Lokasi kampus (unit pemilik) yang dipilih tidak valid.']);
|
||||
$this->store('list_gedung', ['nama' => ''])->assertStatus(422);
|
||||
$this->store('list_gedung', ['nama' => str_repeat('a', 51)])->assertStatus(422);
|
||||
|
||||
$this->destroy('list_gedung', [1])->assertStatus(422)->assertJsonFragment(['message' => 'Gedung "Gedung B" masih dipakai di t_ruang (idgedung), sehingga tidak boleh dihapus.']);
|
||||
$this->assertTrue($this->db()->table('t_gedung')->where('idgedung', 1)->exists());
|
||||
}
|
||||
|
||||
public function test_ruang_unik_per_gedung_dan_batas_angka(): void
|
||||
{
|
||||
$this->store('ms_ruang', ['nama' => 'B.2.1', 'gedung' => '1', 'lantai' => 2, 'kapasitas' => 10])->assertStatus(422)->assertJsonFragment(['message' => 'Nama ruang "B.2.1" sudah ada pada gedung yang sama.']);
|
||||
$this->store('ms_ruang', ['nama' => 'B.2.1', 'gedung' => '2', 'lantai' => 1, 'kapasitas' => 10])->assertCreated();
|
||||
$this->store('ms_ruang', ['nama' => 'Z', 'gedung' => '2', 'lantai' => 1, 'kapasitas' => -5])->assertStatus(422);
|
||||
$this->store('ms_ruang', ['nama' => 'Z', 'gedung' => '2', 'lantai' => 1, 'kapasitas' => 1.5])->assertStatus(422);
|
||||
$this->store('ms_ruang', ['nama' => 'Z', 'lantai' => 1, 'kapasitas' => 5])->assertStatus(422);
|
||||
}
|
||||
|
||||
public function test_pekerjaan_memakai_id_maks_di_bawah_99_dan_melindungi_id_khusus(): void
|
||||
{
|
||||
$this->db()->table('t_pekerjaan')->insert(['idpekerjaan' => 99, 'pekerjaan' => 'Lainnya']);
|
||||
|
||||
$this->assertSame(5, $this->store('ms_pekerjaan', ['nama' => 'Petani'])->assertCreated()->json('id'));
|
||||
$this->store('ms_pekerjaan', ['nama' => 'PETANI'])->assertStatus(422);
|
||||
|
||||
$this->destroy('ms_pekerjaan', [0])->assertStatus(422)->assertJsonFragment(['message' => 'Pekerjaan "-" dilindungi karena dipakai sebagai nilai khusus, sehingga tidak boleh dihapus.']);
|
||||
$this->destroy('ms_pekerjaan', [99])->assertStatus(422);
|
||||
$this->destroy('ms_pekerjaan', [5])->assertOk();
|
||||
}
|
||||
|
||||
public function test_tingkat_pendidikan_dan_status_mahasiswa_hanya_bisa_diubah(): void
|
||||
{
|
||||
$this->store('ms_tingkatpendidikan', ['nama' => 'Doktor'])->assertNotFound();
|
||||
$this->destroy('ms_tingkatpendidikan', [8])->assertNotFound();
|
||||
$this->update('ms_tingkatpendidikan', 8, ['nama' => 'Sarjana (S1)'])->assertOk();
|
||||
$this->assertSame('Sarjana (S1)', $this->db()->table('t_tingkat_pendidikan')->where('idtingkat', 8)->value('tingkatpendidikan'));
|
||||
|
||||
$this->store('ms_statusmhs', ['nama' => 'Baru'])->assertNotFound();
|
||||
$this->update('ms_statusmhs', 6, ['nama' => 'Tugas Akhir', 'kode_pddikti' => null])->assertOk();
|
||||
$this->assertSame('Tugas Akhir', $this->db()->table('t_stat_akademik')->where('idstat_akd', 6)->value('status_akademik'));
|
||||
$this->update('ms_statusmhs', 999, ['nama' => 'X'])->assertStatus(422)->assertJson(['message' => 'Status mahasiswa tidak ditemukan.']);
|
||||
}
|
||||
|
||||
public function test_tanpa_hapus_untuk_tabel_yang_dikunci(): void
|
||||
{
|
||||
foreach (['ms_sistemkuliah', 'ms_agama', 'ms_jenispeg', 'ms_jabfung', 'ms_jabstruktural', 'ms_statusaktif', 'ms_propinsi', 'ms_jenjang'] as $slug) {
|
||||
$this->destroy($slug, [1])->assertNotFound();
|
||||
}
|
||||
}
|
||||
|
||||
public function test_negara_dan_kota_menjaga_rujukan_dan_provinsi(): void
|
||||
{
|
||||
// Negara 18 dipakai t_universitas; negara baru boleh dihapus
|
||||
$this->destroy('ms_negara', [18])->assertStatus(422)->assertJsonFragment(['message' => 'Negara "INDONESIA" masih dipakai di t_universitas (idnegara), sehingga tidak boleh dihapus.']);
|
||||
$this->destroy('ms_negara', [0])->assertStatus(422);
|
||||
$id = $this->store('ms_negara', ['nama' => 'Malaysia', 'kode' => 'MY', 'benua' => 95])->assertCreated()->json('id');
|
||||
$this->store('ms_negara', ['nama' => 'Malaysia 2', 'kode' => 'MY', 'benua' => 95])->assertStatus(422);
|
||||
$this->store('ms_negara', ['nama' => 'Mali', 'kode' => 'MY', 'benua' => 96])->assertCreated();
|
||||
$this->destroy('ms_negara', [$id])->assertOk();
|
||||
|
||||
// Kota: id maks+1, unik per provinsi, tidak boleh pindah provinsi, hapus ditolak bila dipakai universitas
|
||||
$kota = $this->store('ms_kota', ['nama' => 'KOTA BARU', 'kode' => '99', 'provinsi' => '12'])->assertCreated()->json('id');
|
||||
$this->assertSame(301, $kota);
|
||||
$this->store('ms_kota', ['nama' => 'Kota Lain', 'kode' => '99', 'provinsi' => '12'])->assertStatus(422);
|
||||
$this->store('ms_kota', ['nama' => 'Kota Lain', 'kode' => '99', 'provinsi' => '1'])->assertCreated();
|
||||
$this->store('ms_kota', ['nama' => 'Kota Lain', 'kode' => '98', 'provinsi' => '0'])->assertStatus(422);
|
||||
$this->update('ms_kota', $kota, ['nama' => 'KOTA BARU 2', 'kode' => '97', 'provinsi' => '1'])->assertStatus(422)
|
||||
->assertJsonFragment(['message' => 'Kota tidak boleh dipindahkan ke provinsi lain karena memengaruhi laporan asal daerah.']);
|
||||
$this->update('ms_kota', $kota, ['nama' => 'KOTA BARU 2', 'kode' => '99', 'provinsi' => '12'])->assertOk();
|
||||
$this->destroy('ms_kota', [7])->assertStatus(422)->assertJsonFragment(['message' => 'Kota "JAKARTA SELATAN" masih dipakai di t_universitas (idkota), sehingga tidak boleh dihapus.']);
|
||||
$this->destroy('ms_kota', [$kota])->assertOk();
|
||||
}
|
||||
|
||||
public function test_jenjang_menyimpan_tahun_dan_menampilkan_semester(): void
|
||||
{
|
||||
$id = $this->store('ms_jenjang', ['jenjang' => 'S3', 'maks_smt' => 14, 'min_sks' => 42, 'keterangan' => null])->assertCreated()->json('id');
|
||||
$this->assertSame(7, (int) $this->db()->table('t_jenjangprogdi')->where('idjenjang', $id)->value('mstudimax'));
|
||||
$this->store('ms_jenjang', ['jenjang' => 'S4', 'maks_smt' => 7])->assertStatus(422)->assertJsonFragment(['message' => 'Max. studi (semester) harus kelipatan 2 karena disimpan dalam tahun.']);
|
||||
|
||||
$rows = $this->getJson(route('operator.pelengkap.data', 'ms_jenjang'))->assertOk()->json('rows');
|
||||
$row = collect($rows)->firstWhere('id', $id);
|
||||
$this->assertSame(14, $row['form']['maks_smt']);
|
||||
$this->assertSame('S3', $row['form']['jenjang']);
|
||||
}
|
||||
|
||||
public function test_penghasilan_memeriksa_rentang_dan_kode_unik(): void
|
||||
{
|
||||
$this->store('ms_penghasilan', ['kode' => '2', 'nama' => 'Menengah', 'min' => 5000, 'maks' => 1000])->assertStatus(422)
|
||||
->assertJsonFragment(['message' => 'Penghasilan maksimum tidak boleh lebih kecil dari minimum.']);
|
||||
$this->store('ms_penghasilan', ['kode' => '1', 'nama' => 'Lain', 'min' => 0, 'maks' => 0])->assertStatus(422);
|
||||
$this->store('ms_penghasilan', ['kode' => '2', 'nama' => 'Menengah', 'min' => 5000, 'maks' => 0])->assertCreated();
|
||||
}
|
||||
|
||||
public function test_kolom_audit_diisi_bila_ada_di_tabel(): void
|
||||
{
|
||||
Schema::connection('untan')->table('t_gedung', function (Blueprint $table): void {
|
||||
$table->string('cname')->nullable();
|
||||
$table->string('cip')->nullable();
|
||||
$table->string('uname')->nullable();
|
||||
$table->timestamp('tanggal')->nullable();
|
||||
});
|
||||
|
||||
$id = $this->store('list_gedung', ['nama' => 'Gedung Audit'])->assertCreated()->json('id');
|
||||
$row = $this->db()->table('t_gedung')->where('idgedung', $id)->first();
|
||||
$this->assertSame('SIAKAD', $row->cname);
|
||||
$this->assertSame('198001012005011', $row->uname);
|
||||
$this->assertNotNull($row->tanggal);
|
||||
}
|
||||
|
||||
public function test_daftar_menampilkan_tombol_sesuai_kemampuan(): void
|
||||
{
|
||||
$this->get(route('operator.halaman', 'list_gedung'))->assertOk()
|
||||
->assertSee('Tambah')->assertSee('Hapus')->assertSee('Ubah')
|
||||
->assertSee(str_replace('/', '\\\\\\/', route('operator.pelengkap.store', 'list_gedung')), false)
|
||||
->assertDontSee('demo(');
|
||||
|
||||
// Hanya ubah: tanpa tombol Tambah dan Hapus
|
||||
$this->get(route('operator.halaman', 'ms_tingkatpendidikan'))->assertOk()
|
||||
->assertDontSee('startInsert()', false)->assertDontSee('Hapus')->assertSee('Ubah');
|
||||
$row = collect($this->getJson(route('operator.pelengkap.data', 'ms_tingkatpendidikan'))->json('rows'))->firstWhere('id', 8);
|
||||
$this->assertSame(['nama' => 'Sarjana / S1'], $row['form']);
|
||||
|
||||
// Halaman turunan: hanya baca
|
||||
$this->get(route('operator.halaman', 'ms_kelompokmk'))->assertOk()->assertSee('hanya menampilkan data')->assertDontSee('startInsert()', false);
|
||||
$this->postJson(route('operator.halaman', 'ms_kelompokmk'))->assertStatus(405);
|
||||
}
|
||||
|
||||
public function test_jurusan_lewat_http_dan_tanpa_hapus_untuk_unit(): void
|
||||
{
|
||||
$id = $this->store('list_jurusan', ['kode' => 'H9', 'nama' => 'Statistika Terapan', 'singkat' => 'STT', 'fakultas' => '6'])->assertCreated()->json('id');
|
||||
$this->assertSame(2, (int) $this->db()->table('t_bagian')->where('idbagian', $id)->value('idjenisbagian'));
|
||||
$this->store('list_jurusan', ['kode' => 'H10', 'nama' => 'statistika terapan', 'singkat' => 'STX', 'fakultas' => '6'])->assertStatus(422);
|
||||
$this->update('list_jurusan', $id, ['kode' => 'H9', 'nama' => 'Statistika', 'singkat' => 'STT', 'fakultas' => '6'])->assertOk();
|
||||
|
||||
foreach (['list_fakultas', 'list_jurusan', 'list_prodi'] as $slug) {
|
||||
$this->destroy($slug, [$id])->assertNotFound();
|
||||
$this->get(route('operator.halaman', $slug))->assertOk()->assertSee('Tambah')->assertDontSee('demo(')->assertDontSee('startRemove', false);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_nilai_formulir_ubah_bisa_dikirim_kembali_apa_adanya(): void
|
||||
{
|
||||
// Pilihan (gedung, unit, negara, kota, provinsi) dikirim klien persis seperti row.form, termasuk bila berupa angka
|
||||
foreach (['ms_ruang', 'list_gedung', 'ms_universitas', 'ms_kota'] as $slug) {
|
||||
foreach ($this->getJson(route('operator.pelengkap.data', $slug))->assertOk()->json('rows') as $row) {
|
||||
if ($row['id'] === 0 || ($slug === 'ms_ruang' && $row['id'] === 1)) {
|
||||
continue;
|
||||
}
|
||||
$form = array_map(fn ($v) => $v === '' ? null : $v, $row['form']);
|
||||
$this->update($slug, $row['id'], $form)->assertOk();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function test_isian_kosong_pada_kolom_not_null_dan_nilai_lama_di_luar_pilihan(): void
|
||||
{
|
||||
// Universitas id 2 punya negara 0 (bukan pilihan); singkatan dikosongkan tersimpan '' (kolom asli NOT NULL)
|
||||
$this->update('ms_universitas', 2, ['nama' => 'UNIVERSITAS INDONESIA', 'kode' => '001002', 'singkatan' => null, 'negara' => '0', 'kota' => null])->assertOk();
|
||||
$this->assertSame('', $this->db()->table('t_universitas')->where('iduniversitas', 2)->value('singkatan'));
|
||||
$this->assertSame(0, (int) $this->db()->table('t_universitas')->where('iduniversitas', 2)->value('idnegara'));
|
||||
// Negara 0 tidak boleh dipilih untuk data baru
|
||||
$this->store('ms_universitas', ['nama' => 'Baru', 'kode' => '009', 'negara' => '0'])->assertStatus(422);
|
||||
}
|
||||
|
||||
public function test_id_khusus_tidak_bisa_diubah_dan_batas_hapus_massal(): void
|
||||
{
|
||||
$this->update('ms_kota', 0, ['nama' => 'X', 'kode' => '1', 'provinsi' => '1'])->assertStatus(422);
|
||||
$this->update('ms_propinsi', 0, ['nama' => 'X', 'kode' => '1', 'urutan' => 5, 'negara' => '18'])->assertStatus(422)
|
||||
->assertJsonFragment(['message' => 'Provinsi dengan kode 0 dilindungi karena dipakai sebagai nilai khusus, sehingga tidak boleh diubah.']);
|
||||
$this->update('ms_pekerjaan', 0, ['nama' => 'Dicoba'])->assertStatus(422);
|
||||
|
||||
$this->postJson(route('operator.pelengkap.destroy', 'ms_pekerjaan'), ['ids' => range(1, 101)])->assertStatus(422)->assertJsonValidationErrors(['ids']);
|
||||
$this->postJson(route('operator.pelengkap.destroy', 'ms_pekerjaan'), ['ids' => [4, 4]])->assertStatus(422)->assertJsonValidationErrors(['ids.0']);
|
||||
}
|
||||
|
||||
public function test_masukan_aneh_tidak_menjatuhkan_server(): void
|
||||
{
|
||||
$this->getJson(route('operator.pelengkap.data', ['slug' => 'ms_agama', 'q' => ['x']]))->assertOk();
|
||||
$this->getJson(route('operator.pelengkap.data', ['slug' => 'ms_kota', 'provinsi' => ['1']]))->assertOk();
|
||||
// Byte NUL dibuang, bukan dikirim ke PostgreSQL
|
||||
$id = $this->store('ms_agama', ['nama' => "Ab\0c"])->assertCreated()->json('id');
|
||||
$this->assertSame('Abc', $this->db()->table('xs_agama')->where('idagama', $id)->value('agama'));
|
||||
$this->putJson('/operator/ms_ruang/99999999999999999999', [])->assertStatus(405);
|
||||
}
|
||||
|
||||
public function test_kolom_teks_dan_angka_di_modal_punya_placeholder(): void
|
||||
{
|
||||
$this->get(route('operator.halaman', 'list_gedung'))->assertOk()->assertSee('placeholder="Contoh: Gedung Kuliah Bersama"', false);
|
||||
$this->get(route('operator.halaman', 'ms_ruang'))->assertOk()->assertSee('placeholder="Contoh: B.2.1"', false)->assertSee('placeholder="Contoh: 40"', false);
|
||||
// Tanpa contoh khusus: petunjuk umum dari label (huruf awal tiap kata kapital)
|
||||
$this->get(route('operator.halaman', 'list_fakultas'))->assertOk()->assertSee('placeholder="Contoh: Fakultas Teknik"', false)->assertSee('placeholder="Masukkan Urutan"', false);
|
||||
$this->get(route('operator.halaman', 'list_prodi'))->assertOk()->assertSee('placeholder="Contoh: Teknik Informatika"', false);
|
||||
}
|
||||
|
||||
public function test_akses(): void
|
||||
{
|
||||
$this->assertSame(ReferenceCrud::SLUGS, (new ReferenceCrud)->slugs());
|
||||
|
||||
Auth::logout();
|
||||
$this->postJson(route('operator.pelengkap.store', 'list_gedung'), ['nama' => 'X'])->assertUnauthorized();
|
||||
|
||||
config(['auth.guards.web.provider' => 'users']);
|
||||
Auth::forgetGuards();
|
||||
$this->actingAs(User::factory()->operator()->create())
|
||||
->postJson(route('operator.pelengkap.store', 'list_gedung'), ['nama' => 'X'])->assertNotFound();
|
||||
$this->actingAs(User::factory()->dosen()->create())
|
||||
->postJson(route('operator.pelengkap.store', 'list_gedung'), ['nama' => 'X'])->assertForbidden();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,476 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Operator;
|
||||
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Legacy\UnitCrud;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use InvalidArgumentException;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Tests\Concerns\FakesLegacyDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
/** Penulis Data Pelengkap organisasi (Fakultas, Jurusan, Program Studi) pada DB lama tiruan. */
|
||||
class LegacyUnitCrudTest extends TestCase
|
||||
{
|
||||
use FakesLegacyDatabase;
|
||||
use RefreshDatabase;
|
||||
|
||||
private UnitCrud $crud;
|
||||
|
||||
/** Skema organisasi dibuat ulang selengkap DB asli (tiruan umum hanya memuat sebagian kolom) beserta contoh data. */
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->useLegacyDatabase();
|
||||
$schema = Schema::connection('untan');
|
||||
|
||||
foreach (['t_progdi', 't_fakultas', 't_bagian', 't_jenjangprogdi', 't_kelompokfakultas', 't_akreditasiprogdi'] as $table) {
|
||||
$schema->dropIfExists($table);
|
||||
}
|
||||
$schema->create('t_bagian', function (Blueprint $table) {
|
||||
$table->integer('idbagian')->primary();
|
||||
$table->integer('idbagian_induk')->nullable();
|
||||
$table->string('kodebagian', 10)->nullable()->unique();
|
||||
$table->string('singkatan', 20)->nullable();
|
||||
$table->string('namabagian', 50)->nullable();
|
||||
$table->string('keterangan', 200)->nullable();
|
||||
$table->string('skpendirian', 50)->nullable();
|
||||
$table->smallInteger('idjenisbagian')->nullable();
|
||||
$table->string('cname', 20)->nullable();
|
||||
$table->string('cip', 20)->nullable();
|
||||
$table->string('uname', 15)->nullable();
|
||||
$table->timestamp('tanggal')->nullable();
|
||||
$table->boolean('stat_aktif')->nullable();
|
||||
});
|
||||
$schema->create('t_fakultas', function (Blueprint $table) {
|
||||
$table->integer('idbagian')->primary();
|
||||
$table->smallInteger('idkelompok')->nullable();
|
||||
$table->smallInteger('urutan')->nullable()->unique();
|
||||
$table->string('cname', 20)->nullable();
|
||||
$table->string('cip', 20);
|
||||
$table->string('uname', 15)->nullable();
|
||||
$table->timestamp('tanggal')->useCurrent();
|
||||
});
|
||||
$schema->create('t_progdi', function (Blueprint $table) {
|
||||
$table->integer('idbagian')->primary();
|
||||
$table->smallInteger('idjenjang')->nullable();
|
||||
$table->smallInteger('idakreditasi')->nullable();
|
||||
$table->string('skakreditasi', 50)->nullable();
|
||||
$table->smallInteger('urutan')->nullable();
|
||||
$table->boolean('ubahbobot')->default(true);
|
||||
$table->boolean('jadwal_published')->default(false);
|
||||
$table->string('bypass_jadwal', 50)->default('');
|
||||
$table->string('cname', 20)->nullable();
|
||||
$table->string('cip', 20)->nullable();
|
||||
$table->string('uname', 15)->nullable();
|
||||
$table->timestamp('tanggal')->nullable();
|
||||
});
|
||||
$schema->create('t_jenjangprogdi', function (Blueprint $table) {
|
||||
$table->smallInteger('idjenjang')->primary();
|
||||
$table->string('kdjenjang', 20)->nullable();
|
||||
});
|
||||
$schema->create('t_kelompokfakultas', function (Blueprint $table) {
|
||||
$table->smallInteger('idkelompok')->primary();
|
||||
$table->string('kdkelompok', 10)->nullable();
|
||||
});
|
||||
$schema->create('t_akreditasiprogdi', function (Blueprint $table) {
|
||||
$table->smallInteger('idakreditasi')->primary();
|
||||
$table->string('akreditasi', 50)->nullable();
|
||||
});
|
||||
|
||||
$db = DB::connection('untan');
|
||||
$db->table('t_jenjangprogdi')->insert([['idjenjang' => 1, 'kdjenjang' => 'S1'], ['idjenjang' => 2, 'kdjenjang' => 'S2']]);
|
||||
$db->table('t_kelompokfakultas')->insert([['idkelompok' => 1, 'kdkelompok' => 'IPA'], ['idkelompok' => 2, 'kdkelompok' => 'IPS']]);
|
||||
$db->table('t_akreditasiprogdi')->insert([['idakreditasi' => 1, 'akreditasi' => 'A'], ['idakreditasi' => 2, 'akreditasi' => 'B']]);
|
||||
// Fakultas 216 bertipe Biro (5) seperti tiga fakultas lama di DB asli.
|
||||
$db->table('t_bagian')->insert([
|
||||
['idbagian' => 0, 'idbagian_induk' => null, 'kodebagian' => '001022', 'singkatan' => 'UNTAN', 'namabagian' => 'Universitas Tanjungpura', 'idjenisbagian' => 0],
|
||||
['idbagian' => 2, 'idbagian_induk' => 0, 'kodebagian' => 'FT', 'singkatan' => 'FT', 'namabagian' => 'Teknik', 'idjenisbagian' => 1],
|
||||
['idbagian' => 3, 'idbagian_induk' => 0, 'kodebagian' => 'FH', 'singkatan' => 'FH', 'namabagian' => 'Hukum', 'idjenisbagian' => 1],
|
||||
['idbagian' => 216, 'idbagian_induk' => 0, 'kodebagian' => 'FIK', 'singkatan' => 'FIK', 'namabagian' => 'Ilmu Komputer', 'idjenisbagian' => 5],
|
||||
['idbagian' => 20, 'idbagian_induk' => 2, 'kodebagian' => 'MSIPIL', 'singkatan' => 'Sipil', 'namabagian' => 'Teknik Sipil', 'idjenisbagian' => 2],
|
||||
['idbagian' => 21, 'idbagian_induk' => 2, 'kodebagian' => 'MELEK', 'singkatan' => 'Elektro', 'namabagian' => 'Teknik Elektro', 'idjenisbagian' => 2],
|
||||
['idbagian' => 30, 'idbagian_induk' => 20, 'kodebagian' => 'PSIPIL', 'singkatan' => 'S1 Sipil', 'namabagian' => 'Teknik Sipil', 'idjenisbagian' => 3],
|
||||
]);
|
||||
$db->table('t_bagian')->where('idbagian', 30)->update(['stat_aktif' => true]);
|
||||
$db->table('t_fakultas')->insert([
|
||||
['idbagian' => 2, 'idkelompok' => 1, 'urutan' => 1, 'cip' => ''], ['idbagian' => 3, 'idkelompok' => 2, 'urutan' => 2, 'cip' => ''],
|
||||
['idbagian' => 216, 'idkelompok' => 1, 'urutan' => 3, 'cip' => ''],
|
||||
]);
|
||||
$db->table('t_progdi')->insert(['idbagian' => 30, 'idjenjang' => 1, 'idakreditasi' => 1, 'urutan' => 10]);
|
||||
$this->crud = new UnitCrud;
|
||||
}
|
||||
|
||||
private function unitRow(int $id): object
|
||||
{
|
||||
return DB::connection('untan')->table('t_bagian')->where('idbagian', $id)->first();
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function facultyInput(array $override = []): array
|
||||
{
|
||||
return $override + ['kode' => 'FK', 'nama' => 'Kedokteran', 'singkat' => 'FK', 'pendirian' => 'SK 123', 'kelompok' => '1', 'urutan' => '4', 'aktif' => '1'];
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function programInput(array $override = []): array
|
||||
{
|
||||
return $override + ['kode' => 'MSI', 'nama' => 'Sistem Informasi', 'singkat' => 'SI', 'jurusan' => '21', 'jenjang' => '1', 'akreditasi' => '2', 'urutan' => '11', 'aktif' => '1'];
|
||||
}
|
||||
|
||||
/** @param callable(): mixed $callback */
|
||||
private function assertRejected(callable $callback, string $message): void
|
||||
{
|
||||
try {
|
||||
$callback();
|
||||
} catch (PortalException $e) {
|
||||
$this->assertStringContainsString($message, $e->getMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail("PortalException berpesan \"{$message}\" tidak dilempar.");
|
||||
}
|
||||
|
||||
/** @return array<string, list<string>> */
|
||||
public static function slugs(): array
|
||||
{
|
||||
return ['fakultas' => ['list_fakultas'], 'jurusan' => ['list_jurusan'], 'prodi' => ['list_prodi']];
|
||||
}
|
||||
|
||||
public function test_melayani_tiga_slug_tanpa_hak_hapus(): void
|
||||
{
|
||||
$this->assertSame(['list_fakultas', 'list_jurusan', 'list_prodi'], $this->crud->slugs());
|
||||
|
||||
foreach ($this->crud->slugs() as $slug) {
|
||||
$this->assertSame(['create' => true, 'update' => true, 'delete' => false], $this->crud->abilities($slug));
|
||||
}
|
||||
}
|
||||
|
||||
#[DataProvider('slugs')]
|
||||
public function test_hapus_ditolak_untuk_semua_halaman(string $slug): void
|
||||
{
|
||||
$this->assertRejected(fn () => $this->crud->delete($slug, [2]), 'tidak dapat dihapus');
|
||||
$this->assertNotNull($this->unitRow(2));
|
||||
}
|
||||
|
||||
public function test_menambah_fakultas_ke_t_bagian_dan_t_fakultas_dengan_audit(): void
|
||||
{
|
||||
$id = $this->crud->create('list_fakultas', $this->facultyInput(['kode' => ' FK ', 'nama' => ' Kedokteran ']), 'operator-dengan-nama-panjang', null);
|
||||
|
||||
$bagian = $this->unitRow($id);
|
||||
$this->assertSame(0, $bagian->idbagian_induk);
|
||||
$this->assertSame(1, $bagian->idjenisbagian);
|
||||
$this->assertSame('FK', $bagian->kodebagian);
|
||||
$this->assertSame('Kedokteran', $bagian->namabagian);
|
||||
$this->assertSame('Fakultas Kedokteran', $bagian->keterangan);
|
||||
$this->assertSame('SK 123', $bagian->skpendirian);
|
||||
$this->assertTrue((bool) $bagian->stat_aktif);
|
||||
$this->assertSame('SIAKAD', $bagian->cname);
|
||||
$this->assertSame('operator-dengan', $bagian->uname);
|
||||
$this->assertNotNull($bagian->tanggal);
|
||||
|
||||
$fakultas = DB::connection('untan')->table('t_fakultas')->where('idbagian', $id)->first();
|
||||
$this->assertSame(1, $fakultas->idkelompok);
|
||||
$this->assertSame(4, $fakultas->urutan);
|
||||
$this->assertSame('', $fakultas->cip);
|
||||
$this->assertSame('SIAKAD', $fakultas->cname);
|
||||
}
|
||||
|
||||
public function test_ip_audit_dipotong_menjadi_20_karakter(): void
|
||||
{
|
||||
$id = $this->crud->create('list_fakultas', $this->facultyInput(), 'op', '2001:0db8:85a3:0000:0000:8a2e:0370:7334');
|
||||
|
||||
$this->assertSame('2001:0db8:85a3:0000:', $this->unitRow($id)->cip);
|
||||
$this->assertSame('2001:0db8:85a3:0000:', DB::connection('untan')->table('t_fakultas')->where('idbagian', $id)->value('cip'));
|
||||
}
|
||||
|
||||
public function test_fakultas_atomik_t_bagian_dibatalkan_bila_t_fakultas_gagal(): void
|
||||
{
|
||||
DB::connection('untan')->unprepared("create trigger gagal before insert on t_fakultas begin select raise(abort, 'gagal'); end");
|
||||
$before = DB::connection('untan')->table('t_bagian')->count();
|
||||
|
||||
try {
|
||||
$this->crud->create('list_fakultas', $this->facultyInput(), 'op', null);
|
||||
$this->fail('QueryException tidak dilempar.');
|
||||
} catch (QueryException) {
|
||||
$this->assertSame($before, DB::connection('untan')->table('t_bagian')->count());
|
||||
}
|
||||
}
|
||||
|
||||
public function test_prodi_atomik_t_bagian_dibatalkan_bila_t_progdi_gagal(): void
|
||||
{
|
||||
DB::connection('untan')->unprepared("create trigger gagal before insert on t_progdi begin select raise(abort, 'gagal'); end");
|
||||
$before = DB::connection('untan')->table('t_bagian')->count();
|
||||
|
||||
try {
|
||||
$this->crud->create('list_prodi', $this->programInput(), 'op', null);
|
||||
$this->fail('QueryException tidak dilempar.');
|
||||
} catch (QueryException) {
|
||||
$this->assertSame($before, DB::connection('untan')->table('t_bagian')->count());
|
||||
}
|
||||
}
|
||||
|
||||
public function test_menolak_urutan_fakultas_ganda_dan_duplikat_tak_peka_huruf_serta_spasi(): void
|
||||
{
|
||||
$this->assertRejected(fn () => $this->crud->create('list_fakultas', $this->facultyInput(['urutan' => '2']), 'op', null), 'Urutan 2 sudah dipakai');
|
||||
$this->assertRejected(fn () => $this->crud->create('list_fakultas', $this->facultyInput(['nama' => ' tEKNIK ']), 'op', null), 'Nama tEKNIK sudah dipakai fakultas lain');
|
||||
$this->assertRejected(fn () => $this->crud->create('list_fakultas', $this->facultyInput(['singkat' => ' fh ']), 'op', null), 'Singkatan fh sudah dipakai');
|
||||
// Fakultas bertipe Biro (216) tetap dihitung sebagai fakultas.
|
||||
$this->assertRejected(fn () => $this->crud->create('list_fakultas', $this->facultyInput(['nama' => 'ilmu komputer']), 'op', null), 'sudah dipakai fakultas lain');
|
||||
$this->assertSame(3, DB::connection('untan')->table('t_fakultas')->count());
|
||||
}
|
||||
|
||||
public function test_menolak_kelompok_tak_ada_dan_isian_tak_lengkap(): void
|
||||
{
|
||||
$this->assertRejected(fn () => $this->crud->create('list_fakultas', $this->facultyInput(['kelompok' => '9']), 'op', null), 'Kelompok tidak ditemukan');
|
||||
$this->assertRejected(fn () => $this->crud->create('list_fakultas', $this->facultyInput(['kode' => ' ']), 'op', null), 'Kode wajib diisi');
|
||||
$this->assertRejected(fn () => $this->crud->create('list_fakultas', $this->facultyInput(['kode' => 'ABCDEFGHIJK']), 'op', null), 'maksimal 10');
|
||||
$this->assertRejected(fn () => $this->crud->create('list_fakultas', $this->facultyInput(['urutan' => '0']), 'op', null), 'Urutan harus');
|
||||
}
|
||||
|
||||
public function test_mengubah_fakultas_bertipe_biro_tanpa_mengubah_jenis_dan_induk(): void
|
||||
{
|
||||
DB::connection('untan')->table('t_bagian')->where('idbagian', 216)->update(['idbagian_induk' => null]);
|
||||
|
||||
$this->crud->update('list_fakultas', 216, $this->facultyInput(['kode' => 'FIK', 'nama' => ' Ilmu Komputer Baru ', 'singkat' => 'FIK', 'kelompok' => '2', 'urutan' => '3', 'aktif' => '0']), 'budi', '10.0.0.5');
|
||||
|
||||
$bagian = $this->unitRow(216);
|
||||
$this->assertSame(5, $bagian->idjenisbagian);
|
||||
$this->assertNull($bagian->idbagian_induk);
|
||||
$this->assertSame('Ilmu Komputer Baru', $bagian->namabagian);
|
||||
$this->assertSame('Fakultas Ilmu Komputer Baru', $bagian->keterangan);
|
||||
$this->assertNotNull($bagian->stat_aktif);
|
||||
$this->assertFalse((bool) $bagian->stat_aktif);
|
||||
$this->assertSame('budi', $bagian->uname);
|
||||
$this->assertSame('10.0.0.5', $bagian->cip);
|
||||
|
||||
$fakultas = DB::connection('untan')->table('t_fakultas')->where('idbagian', 216)->first();
|
||||
$this->assertSame(2, $fakultas->idkelompok);
|
||||
$this->assertSame('10.0.0.5', $fakultas->cip);
|
||||
}
|
||||
|
||||
public function test_fakultas_boleh_mempertahankan_urutannya_sendiri_tetapi_tidak_urutan_fakultas_lain(): void
|
||||
{
|
||||
$same = $this->facultyInput(['kode' => 'FT', 'nama' => 'Teknik', 'singkat' => 'FT', 'urutan' => '1']);
|
||||
$this->crud->update('list_fakultas', 2, $same, 'op', null);
|
||||
$this->assertSame('Teknik', $this->unitRow(2)->namabagian);
|
||||
|
||||
$this->assertRejected(fn () => $this->crud->update('list_fakultas', 2, ['urutan' => '2'] + $same, 'op', null), 'Urutan 2 sudah dipakai');
|
||||
}
|
||||
|
||||
public function test_status_aktif_fakultas_tidak_berubah_bila_isian_tidak_dikirim(): void
|
||||
{
|
||||
DB::connection('untan')->table('t_bagian')->where('idbagian', 2)->update(['stat_aktif' => true]);
|
||||
$input = $this->facultyInput(['kode' => 'FT', 'nama' => 'Teknik', 'singkat' => 'FT', 'urutan' => '1']);
|
||||
unset($input['aktif']);
|
||||
|
||||
$this->crud->update('list_fakultas', 2, $input, 'op', null);
|
||||
$this->assertTrue((bool) $this->unitRow(2)->stat_aktif);
|
||||
|
||||
$this->crud->update('list_fakultas', 2, $input + ['aktif' => null], 'op', null);
|
||||
$this->assertNull($this->unitRow(2)->stat_aktif);
|
||||
}
|
||||
|
||||
public function test_menolak_mengubah_unit_yang_bukan_jenis_halamannya(): void
|
||||
{
|
||||
$this->assertRejected(fn () => $this->crud->update('list_fakultas', 20, $this->facultyInput(), 'op', null), 'Fakultas tidak ditemukan.');
|
||||
$this->assertRejected(fn () => $this->crud->update('list_jurusan', 2, ['kode' => 'X', 'nama' => 'X', 'singkat' => 'X', 'fakultas' => '2'], 'op', null), 'Jurusan tidak ditemukan.');
|
||||
$this->assertRejected(fn () => $this->crud->update('list_prodi', 20, $this->programInput(), 'op', null), 'Program studi tidak ditemukan.');
|
||||
$this->assertRejected(fn () => $this->crud->update('list_prodi', 9999, $this->programInput(), 'op', null), 'tidak ditemukan');
|
||||
}
|
||||
|
||||
public function test_menambah_jurusan_hanya_ke_t_bagian_dengan_induk_fakultas(): void
|
||||
{
|
||||
$id = $this->crud->create('list_jurusan', ['kode' => 'MMES', 'nama' => 'Teknik Mesin', 'singkat' => 'Mesin', 'fakultas' => '2'], 'op', '10.0.0.1');
|
||||
|
||||
$row = $this->unitRow($id);
|
||||
$this->assertSame(2, $row->idjenisbagian);
|
||||
$this->assertSame(2, $row->idbagian_induk);
|
||||
$this->assertSame('Jurusan Teknik Mesin', $row->keterangan);
|
||||
$this->assertNull($row->stat_aktif);
|
||||
$this->assertNull($row->skpendirian);
|
||||
$this->assertFalse(DB::connection('untan')->table('t_fakultas')->where('idbagian', $id)->exists());
|
||||
$this->assertFalse(DB::connection('untan')->table('t_progdi')->where('idbagian', $id)->exists());
|
||||
}
|
||||
|
||||
public function test_menolak_jurusan_dengan_induk_yang_bukan_fakultas(): void
|
||||
{
|
||||
$input = ['kode' => 'MMES', 'nama' => 'Teknik Mesin', 'singkat' => 'Mesin'];
|
||||
|
||||
$this->assertRejected(fn () => $this->crud->create('list_jurusan', $input + ['fakultas' => '20'], 'op', null), 'Fakultas tidak ditemukan');
|
||||
$this->assertRejected(fn () => $this->crud->create('list_jurusan', $input + ['fakultas' => null], 'op', null), 'Fakultas harus dipilih');
|
||||
$this->assertSame(7, DB::connection('untan')->table('t_bagian')->count());
|
||||
}
|
||||
|
||||
public function test_menolak_kode_jurusan_yang_bentrok_termasuk_beda_huruf_dan_kode_jenis_lain(): void
|
||||
{
|
||||
$input = ['nama' => 'Teknik Mesin', 'singkat' => 'Mesin', 'fakultas' => '2'];
|
||||
|
||||
$this->assertRejected(fn () => $this->crud->create('list_jurusan', ['kode' => 'MSIPIL'] + $input, 'op', null), 'Kode MSIPIL sudah dipakai');
|
||||
// Beda huruf besar-kecil dari jurusan lain: ditolak per jenis.
|
||||
$this->assertRejected(fn () => $this->crud->create('list_jurusan', ['kode' => 'msipil'] + $input, 'op', null), 'Kode msipil sudah dipakai jurusan lain');
|
||||
// Sama persis dengan kode prodi (indeks unik DB peka huruf): pesan menyebut jenis unit lain.
|
||||
$this->assertRejected(fn () => $this->crud->create('list_jurusan', ['kode' => 'PSIPIL', 'nama' => 'Beda Nama', 'singkat' => 'Beda', 'fakultas' => '2'], 'op', null), 'Kode PSIPIL sudah dipakai unit lain (Program Studi).');
|
||||
}
|
||||
|
||||
public function test_nama_boleh_sama_antar_jenis_tetapi_tidak_dalam_satu_jenis(): void
|
||||
{
|
||||
// Prodi baru bernama jurusan lain boleh (nama tidak unik lintas jenis).
|
||||
$id = $this->crud->create('list_prodi', $this->programInput(['nama' => 'Teknik Elektro']), 'op', null);
|
||||
$this->assertSame('Teknik Elektro', $this->unitRow($id)->namabagian);
|
||||
|
||||
$this->assertRejected(
|
||||
fn () => $this->crud->create('list_prodi', $this->programInput(['kode' => 'MSI2', 'singkat' => 'SI2', 'urutan' => '12', 'nama' => 'teknik sipil ']), 'op', null),
|
||||
'sudah dipakai program studi lain',
|
||||
);
|
||||
}
|
||||
|
||||
public function test_mengubah_jurusan_dan_boleh_pindah_fakultas(): void
|
||||
{
|
||||
$this->crud->update('list_jurusan', 21, ['kode' => 'MELEK', 'nama' => ' Elektro Baru ', 'singkat' => 'Elektro', 'fakultas' => '3', 'aktif' => '1'], 'op', null);
|
||||
|
||||
$row = $this->unitRow(21);
|
||||
$this->assertSame(3, $row->idbagian_induk);
|
||||
$this->assertSame('Elektro Baru', $row->namabagian);
|
||||
$this->assertSame('Jurusan Elektro Baru', $row->keterangan);
|
||||
$this->assertSame(2, $row->idjenisbagian);
|
||||
$this->assertTrue((bool) $row->stat_aktif);
|
||||
|
||||
$this->assertRejected(
|
||||
fn () => $this->crud->update('list_jurusan', 21, ['kode' => 'MELEK', 'nama' => 'Teknik Sipil', 'singkat' => 'Elektro', 'fakultas' => '3'], 'op', null),
|
||||
'sudah dipakai jurusan lain',
|
||||
);
|
||||
}
|
||||
|
||||
public function test_menambah_prodi_dengan_dua_tabel_status_eksplisit_dan_kolom_bypass_default(): void
|
||||
{
|
||||
$id = $this->crud->create('list_prodi', $this->programInput(['aktif' => '0', 'akreditasi' => null]), 'op', '10.0.0.9');
|
||||
|
||||
$bagian = $this->unitRow($id);
|
||||
$this->assertSame(3, $bagian->idjenisbagian);
|
||||
$this->assertSame(21, $bagian->idbagian_induk);
|
||||
$this->assertSame('Program Studi Sistem Informasi', $bagian->keterangan);
|
||||
$this->assertNotNull($bagian->stat_aktif);
|
||||
$this->assertFalse((bool) $bagian->stat_aktif);
|
||||
|
||||
$progdi = DB::connection('untan')->table('t_progdi')->where('idbagian', $id)->first();
|
||||
$this->assertSame(1, $progdi->idjenjang);
|
||||
$this->assertNull($progdi->idakreditasi);
|
||||
$this->assertSame(11, $progdi->urutan);
|
||||
$this->assertSame('SIAKAD', $progdi->cname);
|
||||
$this->assertSame('10.0.0.9', $progdi->cip);
|
||||
$this->assertTrue((bool) $progdi->ubahbobot);
|
||||
$this->assertFalse((bool) $progdi->jadwal_published);
|
||||
$this->assertSame('', $progdi->bypass_jadwal);
|
||||
}
|
||||
|
||||
public function test_menolak_prodi_dengan_isian_tidak_valid(): void
|
||||
{
|
||||
$this->assertRejected(fn () => $this->crud->create('list_prodi', $this->programInput(['jurusan' => '2']), 'op', null), 'Jurusan tidak ditemukan');
|
||||
$this->assertRejected(fn () => $this->crud->create('list_prodi', $this->programInput(['jurusan' => null]), 'op', null), 'Jurusan harus dipilih');
|
||||
$this->assertRejected(fn () => $this->crud->create('list_prodi', $this->programInput(['jenjang' => '99']), 'op', null), 'Jenjang tidak ditemukan');
|
||||
$this->assertRejected(fn () => $this->crud->create('list_prodi', $this->programInput(['akreditasi' => '99']), 'op', null), 'Akreditasi tidak ditemukan');
|
||||
$this->assertRejected(fn () => $this->crud->create('list_prodi', $this->programInput(['urutan' => '10']), 'op', null), 'Urutan 10 sudah dipakai program studi lain');
|
||||
$this->assertRejected(fn () => $this->crud->create('list_prodi', $this->programInput(['aktif' => null]), 'op', null), 'Status aktif harus dipilih');
|
||||
$this->assertSame(1, DB::connection('untan')->table('t_progdi')->count());
|
||||
}
|
||||
|
||||
public function test_mengubah_prodi_pindah_jurusan_jenjang_nonaktif_tanpa_menyentuh_bypass(): void
|
||||
{
|
||||
DB::connection('untan')->table('t_progdi')->where('idbagian', 30)->update(['bypass_jadwal' => 'rahasia', 'ubahbobot' => false]);
|
||||
|
||||
$this->crud->update('list_prodi', 30, ['kode' => 'PSIPIL', 'nama' => 'Teknik Sipil ', 'singkat' => 'S1 Sipil', 'jurusan' => '21', 'jenjang' => '2', 'akreditasi' => null, 'urutan' => '10', 'aktif' => '0'], 'siti', null);
|
||||
|
||||
$bagian = $this->unitRow(30);
|
||||
$this->assertSame(21, $bagian->idbagian_induk);
|
||||
$this->assertSame(3, $bagian->idjenisbagian);
|
||||
$this->assertNotNull($bagian->stat_aktif);
|
||||
$this->assertFalse((bool) $bagian->stat_aktif);
|
||||
$this->assertSame('siti', $bagian->uname);
|
||||
|
||||
$progdi = DB::connection('untan')->table('t_progdi')->where('idbagian', 30)->first();
|
||||
$this->assertSame(2, $progdi->idjenjang);
|
||||
$this->assertNull($progdi->idakreditasi);
|
||||
$this->assertSame('rahasia', $progdi->bypass_jadwal);
|
||||
$this->assertFalse((bool) $progdi->ubahbobot);
|
||||
}
|
||||
|
||||
public function test_menyusun_formulir_tiap_halaman_dengan_opsi_bernomor_dan_urutan_awal(): void
|
||||
{
|
||||
$faculty = $this->crud->form('list_fakultas');
|
||||
$byName = collect($faculty['fields'])->keyBy('name');
|
||||
$this->assertSame('fakultas', $faculty['title']);
|
||||
$this->assertSame(['kode', 'nama', 'singkat', 'pendirian', 'kelompok', 'urutan', 'aktif'], array_column($faculty['fields'], 'name'));
|
||||
$this->assertSame([1 => 'IPA', 2 => 'IPS'], $byName['kelompok']['options']);
|
||||
$this->assertSame(4, $byName['urutan']['default']);
|
||||
$this->assertSame(10, $byName['kode']['max']);
|
||||
$this->assertSame(50, $byName['nama']['max']);
|
||||
$this->assertSame(20, $byName['singkat']['max']);
|
||||
|
||||
$department = $this->crud->form('list_jurusan');
|
||||
$this->assertSame('jurusan', $department['title']);
|
||||
$this->assertSame(['kode', 'nama', 'singkat', 'fakultas', 'aktif'], array_column($department['fields'], 'name'));
|
||||
$this->assertSame([2 => 'Teknik', 3 => 'Hukum', 216 => 'Ilmu Komputer'], collect($department['fields'])->keyBy('name')['fakultas']['options']);
|
||||
|
||||
$program = $this->crud->form('list_prodi');
|
||||
$byName = collect($program['fields'])->keyBy('name');
|
||||
$this->assertSame('program studi', $program['title']);
|
||||
$this->assertSame(['kode', 'nama', 'singkat', 'jurusan', 'jenjang', 'akreditasi', 'urutan', 'aktif'], array_column($program['fields'], 'name'));
|
||||
$this->assertSame([21 => 'Teknik Elektro — Teknik', 20 => 'Teknik Sipil — Teknik'], $byName['jurusan']['options']);
|
||||
$this->assertSame([1 => 'S1', 2 => 'S2'], $byName['jenjang']['options']);
|
||||
$this->assertSame([1 => 'A', 2 => 'B'], $byName['akreditasi']['options']);
|
||||
$this->assertFalse($byName['akreditasi']['required']);
|
||||
$this->assertTrue($byName['aktif']['required']);
|
||||
$this->assertSame(11, $byName['urutan']['default']);
|
||||
}
|
||||
|
||||
#[DataProvider('slugs')]
|
||||
public function test_aturan_validasi_berkunci_sama_dengan_nama_field_formulir(string $slug): void
|
||||
{
|
||||
[$rules, $attributes] = $this->crud->rules($slug);
|
||||
$names = array_column($this->crud->form($slug)['fields'], 'name');
|
||||
|
||||
$this->assertEqualsCanonicalizing($names, array_keys($rules));
|
||||
$this->assertEqualsCanonicalizing($names, array_keys($attributes));
|
||||
$this->assertStringContainsString('max:10', $rules['kode']);
|
||||
$this->assertStringContainsString('max:50', $rules['nama']);
|
||||
$this->assertStringContainsString('max:20', $rules['singkat']);
|
||||
}
|
||||
|
||||
public function test_memetakan_nilai_formulir_dari_id_bagian_ke_nama_field_yang_sama(): void
|
||||
{
|
||||
DB::connection('untan')->table('t_bagian')->where('idbagian', 2)->update(['skpendirian' => 'SK 1', 'stat_aktif' => true, 'namabagian' => 'Teknik ']);
|
||||
|
||||
$faculty = $this->crud->formValues('list_fakultas', [2, 216, 20, 999]);
|
||||
$this->assertEqualsCanonicalizing([2, 216], array_keys($faculty));
|
||||
$this->assertSame(['kode' => 'FT', 'nama' => 'Teknik', 'singkat' => 'FT', 'pendirian' => 'SK 1', 'kelompok' => 1, 'urutan' => 1, 'aktif' => '1'], $faculty[2]);
|
||||
$this->assertSame('', $faculty[216]['aktif']);
|
||||
|
||||
$department = $this->crud->formValues('list_jurusan', ['20', 2]);
|
||||
$this->assertSame([20], array_keys($department));
|
||||
$this->assertSame(['kode' => 'MSIPIL', 'nama' => 'Teknik Sipil', 'singkat' => 'Sipil', 'fakultas' => 2, 'aktif' => ''], $department[20]);
|
||||
|
||||
$program = $this->crud->formValues('list_prodi', [30]);
|
||||
$this->assertSame(['kode' => 'PSIPIL', 'nama' => 'Teknik Sipil', 'singkat' => 'S1 Sipil', 'jurusan' => 20, 'jenjang' => 1, 'akreditasi' => 1, 'urutan' => 10, 'aktif' => '1'], $program[30]);
|
||||
|
||||
DB::connection('untan')->table('t_bagian')->where('idbagian', 30)->update(['stat_aktif' => false]);
|
||||
DB::connection('untan')->table('t_progdi')->where('idbagian', 30)->update(['idakreditasi' => null]);
|
||||
$again = $this->crud->formValues('list_prodi', [30])[30];
|
||||
$this->assertSame('0', $again['aktif']);
|
||||
$this->assertSame('', $again['akreditasi']);
|
||||
}
|
||||
|
||||
public function test_menolak_slug_yang_tidak_dilayani(): void
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
$this->crud->form('ms_agama');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,536 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Operator\Reports;
|
||||
|
||||
use App\Support\Legacy\Reports\AkademikReports;
|
||||
use App\Support\Legacy\Reports\ReportContext;
|
||||
use App\Support\Legacy\Reports\ReportResult;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use InvalidArgumentException;
|
||||
use Tests\Concerns\FakesLegacyDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Laporan akademik (KHS, KRS, transkrip, IPK, konversi, mengulang, KKN) dari DB lama tiruan.
|
||||
*
|
||||
* Prodi 21 (Teknik Informatika) dan 22 (Teknik Sipil), periode 368. Mahasiswa 500 (D1041191001, angkatan 2019),
|
||||
* 501 cuti, 502 (2020), 503, 504 (2021), 505 lulus, 506 keluar; 510 dan 511 prodi 22 (2020).
|
||||
*/
|
||||
class AkademikReportsTest extends TestCase
|
||||
{
|
||||
use FakesLegacyDatabase;
|
||||
use RefreshDatabase;
|
||||
|
||||
private AkademikReports $reports;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->useLegacyDatabase();
|
||||
$this->seedLegacyOverview();
|
||||
$this->seedLegacyGrades();
|
||||
$this->extendSchema();
|
||||
$this->reports = app(AkademikReports::class);
|
||||
}
|
||||
|
||||
private function extendSchema(): void
|
||||
{
|
||||
$schema = Schema::connection('untan');
|
||||
|
||||
foreach (['ipk' => 'double', 'skstranskrip' => 'smallInteger', 'skstranskriplulus' => 'smallInteger'] as $column => $type) {
|
||||
if (! $schema->hasColumn('t_histori_mahasiswa', $column)) {
|
||||
$schema->table('t_histori_mahasiswa', fn (Blueprint $table) => $table->{$type}($column)->nullable());
|
||||
}
|
||||
}
|
||||
|
||||
foreach (['nilaihuruf' => 'string', 'nilaimutu' => 'double', 'tanggal' => 'timestamp'] as $column => $type) {
|
||||
if (! $schema->hasColumn('t_kst_konversi_log', $column)) {
|
||||
$schema->table('t_kst_konversi_log', fn (Blueprint $table) => $table->{$type}($column)->nullable());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** IPK tersimpan periode 368: idmahasiswa => [ipk, SKS transkrip]. */
|
||||
private function seedIpk(): void
|
||||
{
|
||||
$db = DB::connection('untan');
|
||||
$db->table('t_histori_mahasiswa')->insert([
|
||||
['idmahasiswa' => 504, 'idperiode' => 368, 'stat_akd_akhir' => 1, 'ips' => 0],
|
||||
['idmahasiswa' => 506, 'idperiode' => 368, 'stat_akd_akhir' => 1, 'ips' => 3],
|
||||
]);
|
||||
|
||||
foreach ([500 => [3.6, 30], 501 => [2.9, 40], 502 => [1.8, 20], 505 => [3.9, 140], 506 => [3.6, 10], 510 => [2.5, 25], 504 => [0, 0]] as $id => [$ipk, $sks]) {
|
||||
$db->table('t_histori_mahasiswa')->where('idmahasiswa', $id)->where('idperiode', 368)
|
||||
->update(['ipk' => $ipk, 'skstranskrip' => $sks, 'skstranskriplulus' => max(0, $sks - 2)]);
|
||||
}
|
||||
}
|
||||
|
||||
private function context(array $prodi = [21]): ReportContext
|
||||
{
|
||||
$names = DB::connection('untan')->table('t_bagian')->whereIn('idbagian', $prodi)->pluck('namabagian', 'idbagian')->all();
|
||||
|
||||
return new ReportContext(1, 'staf', $prodi, $names);
|
||||
}
|
||||
|
||||
private function report(string $slug, array $params = [], ?ReportContext $context = null, int $limit = 100): ReportResult
|
||||
{
|
||||
return $this->reports->run($slug, $params, $context ?? $this->context(), $limit);
|
||||
}
|
||||
|
||||
/** @return list<string> */
|
||||
private function keys(ReportResult $result): array
|
||||
{
|
||||
return array_column($result->columns, 'key');
|
||||
}
|
||||
|
||||
/** @return list<mixed> */
|
||||
private function col(ReportResult $result, string $key): array
|
||||
{
|
||||
return array_column($result->rows, $key);
|
||||
}
|
||||
|
||||
/** Setiap baris harus memiliki kunci persis sama dengan kolom. */
|
||||
private function assertShape(ReportResult $result): void
|
||||
{
|
||||
foreach ($result->rows as $row) {
|
||||
$this->assertSame($this->keys($result), array_keys($row));
|
||||
}
|
||||
}
|
||||
|
||||
public function test_slugs_hanya_yang_bersumber(): void
|
||||
{
|
||||
$this->assertSame([
|
||||
'repp_khsmahasiswa', 'repp_krsmahasiswa', 'repp_khsmhskolektif', 'repp_transkrip', 'repp_transkripsmt',
|
||||
'repp_nilaikonversi', 'repp_krsmhs', 'repp_rekapkrs', 'repp_distribusikrsmhs', 'repp_mkmengulang',
|
||||
'repp_rekapipk', 'repp_ipk', 'repp_ipktertinggi', 'repp_nilaikkn',
|
||||
], $this->reports->slugs());
|
||||
$this->assertNotContains('repp_transkripobemhs', $this->reports->slugs());
|
||||
}
|
||||
|
||||
public function test_definisi_valid(): void
|
||||
{
|
||||
foreach ($this->reports->slugs() as $slug) {
|
||||
$params = $this->reports->definition($slug, $this->context([21, 22]))['params'];
|
||||
$names = array_column($params, 'name');
|
||||
|
||||
$this->assertSame($names, array_values(array_unique($names)), $slug);
|
||||
$this->assertNotContains('tampil', $names, $slug);
|
||||
$this->assertNotContains('kop', $names, $slug);
|
||||
|
||||
foreach ($params as $param) {
|
||||
$this->assertContains($param['type'], ['select', 'text', 'number', 'date', 'check'], $slug.'.'.$param['name']);
|
||||
$this->assertNotSame('', $param['label']);
|
||||
|
||||
if ($param['type'] === 'select') {
|
||||
$this->assertIsArray($param['options'], $slug.'.'.$param['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function test_opsi_berasal_dari_db(): void
|
||||
{
|
||||
$params = collect($this->reports->definition('repp_rekapipk', $this->context([21, 22]))['params'])->keyBy('name');
|
||||
|
||||
$this->assertSame([368 => '2020/2021 Ganjil', 366 => '2019/2020 Genap (pendek)', 365 => '2019/2020 Genap', 362 => '2019/2020 Ganjil'], $params['periode']['options']);
|
||||
$this->assertSame(368, $params['periode']['default']);
|
||||
$this->assertSame([21 => 'Teknik Informatika', 22 => 'Teknik Sipil'], $params['prodi']['options']);
|
||||
$this->assertSame([2021 => '2021', 2020 => '2020', 2019 => '2019'], $params['angkatan']['options']);
|
||||
$this->assertSame([3 => 'MANDIRI', 1 => 'SNMPTN'], $params['jalur']['options']);
|
||||
|
||||
$kosong = $this->reports->definition('repp_rekapipk', $this->context([]))['params'];
|
||||
$this->assertSame([], collect($kosong)->firstWhere('name', 'periode')['options']);
|
||||
}
|
||||
|
||||
public function test_slug_tak_dikenal_ditolak(): void
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
$this->reports->definition('repp_transkripobemhs', $this->context());
|
||||
}
|
||||
|
||||
public function test_khs_mahasiswa_per_periode(): void
|
||||
{
|
||||
DB::connection('untan')->table('t_histori_mahasiswa')->where('idmahasiswa', 500)->where('idperiode', 365)->update(['ips' => 1.95]);
|
||||
|
||||
$result = $this->report('repp_khsmahasiswa', ['periode' => 365]);
|
||||
|
||||
$this->assertSame(['nim', 'nama', 'kode', 'mk', 'sks', 'kelas', 'nilai', 'huruf', 'bobot', 'ips', 'ipk'], $this->keys($result));
|
||||
$this->assertShape($result);
|
||||
// Skripsi (tipe 2 tanpa nilai) dan Statistika (batal) tidak ikut; Kalkulus belum terbit.
|
||||
$this->assertSame(['IF201', 'IF202', 'IF999'], $this->col($result, 'kode'));
|
||||
$this->assertSame(3, $result->total);
|
||||
$this->assertSame(['Periode: 2019/2020 Genap', 'Jumlah: 2 mahasiswa, 3 mata kuliah'], $result->summary);
|
||||
|
||||
$jaringan = $result->rows[0];
|
||||
$this->assertSame(['D1041191001', 'Rina Lestari', 3, 78.0, 'B+', 3.25, 1.95], [$jaringan['nim'], $jaringan['nama'], $jaringan['sks'], $jaringan['nilai'], $jaringan['huruf'], $jaringan['bobot'], $jaringan['ips']]);
|
||||
|
||||
$kalkulus = $result->rows[1];
|
||||
$this->assertNull($kalkulus['nilai']);
|
||||
$this->assertNull($kalkulus['huruf']);
|
||||
$this->assertNull($kalkulus['bobot']);
|
||||
}
|
||||
|
||||
public function test_khs_filter_dan_cakupan_prodi(): void
|
||||
{
|
||||
$this->assertSame(['D1041191001'], array_unique($this->col($this->report('repp_khsmahasiswa', ['periode' => 365, 'mahasiswa' => 'rina']), 'nim')));
|
||||
$this->assertSame(['X501'], array_unique($this->col($this->report('repp_khsmahasiswa', ['periode' => 365, 'angkatan' => 2019, 'mahasiswa' => 'X5']), 'nim')));
|
||||
|
||||
// Periode 368: prodi 21 hanya 500 dan 502; prodi 22 hanya 510.
|
||||
$this->assertSame(['D1041191001', 'X502'], $this->col($this->report('repp_khsmahasiswa', ['periode' => 368]), 'nim'));
|
||||
$this->assertSame(['X510'], $this->col($this->report('repp_khsmahasiswa', ['periode' => 368], $this->context([22])), 'nim'));
|
||||
|
||||
$semua = $this->report('repp_khsmahasiswa', ['periode' => 368], $this->context([21, 22]));
|
||||
$this->assertContains('prodi', $this->keys($semua));
|
||||
$this->assertSame(['Teknik Informatika', 'Teknik Informatika', 'Teknik Sipil'], $this->col($semua, 'prodi'));
|
||||
|
||||
// Prodi dipilih menyempit; prodi di luar akun diabaikan (tetap cakupan akun).
|
||||
$this->assertSame(['X510'], $this->col($this->report('repp_khsmahasiswa', ['periode' => 368, 'prodi' => 22], $this->context([21, 22])), 'nim'));
|
||||
$this->assertSame(['D1041191001', 'X502'], $this->col($this->report('repp_khsmahasiswa', ['periode' => 368, 'prodi' => 99]), 'nim'));
|
||||
|
||||
$kosong = $this->report('repp_khsmahasiswa', ['periode' => 368], $this->context([]));
|
||||
$this->assertSame([], $kosong->rows);
|
||||
$this->assertSame(0, $kosong->total);
|
||||
}
|
||||
|
||||
public function test_krs_mahasiswa_dan_status(): void
|
||||
{
|
||||
$result = $this->report('repp_krsmahasiswa', ['periode' => 368]);
|
||||
|
||||
$this->assertSame(['nim', 'nama', 'kode', 'mk', 'sks', 'kelas', 'status'], $this->keys($result));
|
||||
$this->assertShape($result);
|
||||
// 501 membatalkan KRS: tidak muncul. 510 prodi lain.
|
||||
$this->assertSame(['D1041191001', 'X502', 'X502'], $this->col($result, 'nim'));
|
||||
$this->assertSame(['Menunggu persetujuan', 'Disetujui', 'Disetujui'], $this->col($result, 'status'));
|
||||
$this->assertSame(['MK601', 'MK601', 'MK604'], $this->col($result, 'kode'));
|
||||
$this->assertSame('Jumlah: 2 mahasiswa, 3 mata kuliah, 6 SKS', $result->summary[1]);
|
||||
|
||||
$this->assertSame(['X502', 'X502'], $this->col($this->report('repp_krsmahasiswa', ['periode' => 368, 'angkatan' => 2020]), 'nim'));
|
||||
$this->assertSame(['X510'], $this->col($this->report('repp_krsmahasiswa', ['periode' => 368], $this->context([22])), 'nim'));
|
||||
$this->assertSame([], $this->report('repp_krsmahasiswa', ['periode' => 368], $this->context([]))->rows);
|
||||
}
|
||||
|
||||
public function test_khs_kolektif_ringkasan_per_semester(): void
|
||||
{
|
||||
$this->seedIpk();
|
||||
|
||||
$result = $this->report('repp_khsmhskolektif', ['angkatan' => 2019, 'periode' => 368, 'status' => 1]);
|
||||
|
||||
$this->assertSame(['nim', 'nama', 'periode', 'smt', 'status', 'ips', 'sks_kum', 'sks_lulus', 'ipk'], $this->keys($result));
|
||||
$this->assertShape($result);
|
||||
$this->assertSame(['D1041191001', 'X506'], $this->col($result, 'nim'));
|
||||
$this->assertSame(['2020/2021 Ganjil', 3, 'Aktif', 3.5, 30, 28, 3.6], [
|
||||
$result->rows[0]['periode'], $result->rows[0]['smt'], $result->rows[0]['status'], $result->rows[0]['ips'],
|
||||
$result->rows[0]['sks_kum'], $result->rows[0]['sks_lulus'], $result->rows[0]['ipk'],
|
||||
]);
|
||||
|
||||
// Tanpa periode: semua semester sampai periode aktif prodi.
|
||||
$semua = $this->report('repp_khsmhskolektif', ['angkatan' => 2019]);
|
||||
$this->assertSame(['D1041191001', 'D1041191001', 'X501', 'X505', 'X505', 'X506'], $this->col($semua, 'nim'));
|
||||
$this->assertSame(6, $semua->total);
|
||||
|
||||
$this->assertSame([], $this->report('repp_khsmhskolektif', ['angkatan' => 2019], $this->context([22]))->rows);
|
||||
$this->assertSame([], $this->report('repp_khsmhskolektif', ['angkatan' => 2019], $this->context([]))->rows);
|
||||
$this->assertSame([], $this->report('repp_khsmhskolektif', [])->rows);
|
||||
}
|
||||
|
||||
public function test_transkrip_lulusan(): void
|
||||
{
|
||||
$db = DB::connection('untan');
|
||||
$db->table('t_mahasiswa')->where('idmahasiswa', 500)->update(['stataktif' => 2, 'idperiodewisuda' => 111]);
|
||||
$db->table('t_mahasiswa')->where('idmahasiswa', 505)->update(['idperiodewisuda' => 112]);
|
||||
$db->table('t_mahasiswa')->insert(['idmahasiswa' => 507, 'nim' => 'X507', 'nama' => 'Mahasiswa 507', 'idprogdi' => 22, 'idangkatan' => 160, 'stataktif' => 2, 'idperiodewisuda' => 111]);
|
||||
$db->table('t_periodewisuda')->insert([
|
||||
['idperiode' => 111, 'namaperiode' => '2020/2021 Periode I', 'kdperiode' => '20201'],
|
||||
['idperiode' => 112, 'namaperiode' => '2020/2021 Periode II', 'kdperiode' => '20202'],
|
||||
]);
|
||||
|
||||
$definition = collect($this->reports->definition('repp_transkrip', $this->context([21, 22]))['params'])->keyBy('name');
|
||||
$this->assertSame([112 => '20202 (2020/2021 Periode II)', 111 => '20201 (2020/2021 Periode I)'], $definition['yudisium']['options']);
|
||||
|
||||
$result = $this->report('repp_transkrip', ['yudisium' => 111]);
|
||||
|
||||
$this->assertSame(['nim', 'nama', 'smt', 'kode', 'mk', 'sks', 'huruf', 'bobot', 'mutu', 'ket'], $this->keys($result));
|
||||
$this->assertShape($result);
|
||||
// Nilai terbaik per mata kuliah; Kalkulus belum terbit dan Skripsi/Statistika tidak ikut.
|
||||
$this->assertSame(['Algoritma', 'Basis Data', 'Jaringan Komputer', 'Etika Profesi', 'Jumlah'], $this->col($result, 'mk'));
|
||||
$this->assertSame(['A', 'B', 'B+', 'C', null], $this->col($result, 'huruf'));
|
||||
$this->assertSame(['Lulus', 'Lulus', 'Lulus', 'Tidak lulus', 'IPK 3,07; SKS lulus 8'], $this->col($result, 'ket'));
|
||||
$jumlah = $result->rows[count($result->rows) - 1];
|
||||
$this->assertSame([11, 33.75], [$jumlah['sks'], $jumlah['mutu']]);
|
||||
|
||||
// Tanpa filter yudisium: 505 (tanpa nilai) ikut, 507 (prodi 22) tidak.
|
||||
$semua = $this->report('repp_transkrip');
|
||||
$this->assertSame(['D1041191001', 'X505'], array_values(array_unique($this->col($semua, 'nim'))));
|
||||
$this->assertSame('Belum ada nilai yang diterbitkan', $semua->rows[count($semua->rows) - 1]['mk']);
|
||||
$this->assertSame(['X507'], array_values(array_unique($this->col($this->report('repp_transkrip', [], $this->context([22])), 'nim'))));
|
||||
$this->assertSame([], $this->report('repp_transkrip', [], $this->context([]))->rows);
|
||||
$this->assertSame([], $this->report('repp_transkrip', ['mahasiswa' => 'tidak ada'])->rows);
|
||||
}
|
||||
|
||||
public function test_transkrip_sementara_dan_cadangan_t_transkrip(): void
|
||||
{
|
||||
$db = DB::connection('untan');
|
||||
// 503 mahasiswa lama: nilai hanya di t_transkrip (Algoritma B).
|
||||
$db->table('t_transkrip')->insert(['idmahasiswa' => 503, 'idmatakuliah' => 1, 'nilaimutu' => 3, 'nilaihuruf' => 'B']);
|
||||
|
||||
$result = $this->report('repp_transkripsmt', ['angkatan' => 2019, 'status' => 'aktif', 'tidak_lulus' => false]);
|
||||
|
||||
$this->assertShape($result);
|
||||
$this->assertSame(['D1041191001', 'D1041191001', 'D1041191001', 'D1041191001', 'X501', 'X501', 'X503', 'X503'], $this->col($result, 'nim'));
|
||||
// MK tidak lulus (Etika Profesi) disembunyikan, tetapi jumlah dan IPK tetap menghitung seluruh mata kuliah.
|
||||
$this->assertSame(['Algoritma', 'Basis Data', 'Jaringan Komputer', 'Jumlah'], array_slice($this->col($result, 'mk'), 0, 4));
|
||||
$this->assertSame('IPK 3,07; SKS lulus 8', $result->rows[3]['ket']);
|
||||
$this->assertSame(['Nilai Mahasiswa Lain', 'Jumlah', 'Algoritma', 'Jumlah'], array_slice($this->col($result, 'mk'), 4));
|
||||
$this->assertSame('IPK 3,00; SKS lulus 3', $result->rows[7]['ket']);
|
||||
|
||||
$lengkap = $this->report('repp_transkripsmt', ['mahasiswa' => 'D1041191001']);
|
||||
$this->assertContains('Etika Profesi', $this->col($lengkap, 'mk'));
|
||||
|
||||
// 505 lulus: tidak termasuk status aktif.
|
||||
$this->assertNotContains('X505', $this->col($result, 'nim'));
|
||||
$this->assertSame(['X505'], array_values(array_unique($this->col($this->report('repp_transkripsmt', ['status' => 'lulus']), 'nim'))));
|
||||
}
|
||||
|
||||
public function test_nilai_konversi(): void
|
||||
{
|
||||
$db = DB::connection('untan');
|
||||
$db->table('t_kst_konversi_log')->insert([
|
||||
['idmahasiswa' => 504, 'idperiode' => 368, 'idmatakuliahlama' => 602, 'idmatakuliahbaru' => 601, 'nilaihuruf' => 'A', 'nilaimutu' => 4, 'tanggal' => '2021-02-14 10:00:00'],
|
||||
['idmahasiswa' => 504, 'idperiode' => 368, 'idmatakuliahlama' => 603, 'idmatakuliahbaru' => null, 'nilaihuruf' => 'B', 'nilaimutu' => 3, 'tanggal' => null],
|
||||
['idmahasiswa' => 510, 'idperiode' => 368, 'idmatakuliahlama' => 601, 'idmatakuliahbaru' => 602, 'nilaihuruf' => 'C', 'nilaimutu' => 2, 'tanggal' => null],
|
||||
]);
|
||||
|
||||
$result = $this->report('repp_nilaikonversi', ['angkatan' => 2021]);
|
||||
|
||||
$this->assertSame(['nim', 'nama', 'periode', 'kode_lama', 'mk_lama', 'sks_lama', 'kode', 'mk', 'sks', 'huruf', 'bobot', 'tanggal'], $this->keys($result));
|
||||
$this->assertShape($result);
|
||||
$this->assertSame(2, $result->total);
|
||||
$this->assertSame(['X504', 'Mahasiswa 504', '2020/2021 Ganjil', 'MK602', 'Kelas 602', 2, 'MK601', 'Kelas 601', 2, 'A', 4.0, '14-02-2021'], array_values($result->rows[0]));
|
||||
// Mata kuliah konversi tidak tercatat: tampil kosong, bukan karangan.
|
||||
$this->assertSame([null, null, null, 'B', 3.0, null], [$result->rows[1]['kode'], $result->rows[1]['mk'], $result->rows[1]['sks'], $result->rows[1]['huruf'], $result->rows[1]['bobot'], $result->rows[1]['tanggal']]);
|
||||
$this->assertSame(['Angkatan: 2021', 'Jumlah: 1 mahasiswa, 2 mata kuliah'], $result->summary);
|
||||
|
||||
// Cakupan prodi: 510 hanya terlihat oleh prodi 22; angkatan lain kosong.
|
||||
$this->assertSame([], $this->report('repp_nilaikonversi', ['angkatan' => 2020])->rows);
|
||||
$this->assertSame(['X510'], $this->col($this->report('repp_nilaikonversi', ['angkatan' => 2020], $this->context([22])), 'nim'));
|
||||
$this->assertSame([], $this->report('repp_nilaikonversi', ['angkatan' => 2021], $this->context([22]))->rows);
|
||||
$this->assertSame([], $this->report('repp_nilaikonversi', ['angkatan' => 2021], $this->context([]))->rows);
|
||||
$this->assertSame(['X504'], array_unique($this->col($this->report('repp_nilaikonversi', ['angkatan' => 2021, 'mahasiswa' => '504']), 'nim')));
|
||||
$this->assertSame([], $this->report('repp_nilaikonversi', ['angkatan' => 2021, 'mahasiswa' => 'rina'])->rows);
|
||||
}
|
||||
|
||||
public function test_status_krs_mahasiswa_aktif(): void
|
||||
{
|
||||
DB::connection('untan')->table('t_histori_mahasiswa')->insert(['idmahasiswa' => 504, 'idperiode' => 368, 'stat_akd_akhir' => 1]);
|
||||
|
||||
$result = $this->report('repp_krsmhs', ['periode' => 368]);
|
||||
|
||||
$this->assertSame(['nim', 'nama', 'angkatan', 'sistem', 'mk', 'sks', 'status'], $this->keys($result));
|
||||
$this->assertShape($result);
|
||||
// 501 cuti, 505 lulus, 511 tanpa status, 510 prodi lain: hanya yang berstatus aktif di prodi 21.
|
||||
$this->assertSame(['D1041191001', 'X502', 'X504'], $this->col($result, 'nim'));
|
||||
$this->assertSame(['KRS Diajukan', 'KRS Disetujui', 'Belum Mengisi KRS'], $this->col($result, 'status'));
|
||||
$this->assertSame([2019, 2020, 2021], $this->col($result, 'angkatan'));
|
||||
$this->assertSame([2, 4, 0], $this->col($result, 'sks'));
|
||||
$this->assertSame('Reguler A', $result->rows[0]['sistem']);
|
||||
$this->assertSame(3, $result->total);
|
||||
|
||||
$this->assertSame(['D1041191001'], $this->col($this->report('repp_krsmhs', ['periode' => 368, 'status_krs' => 'diajukan']), 'nim'));
|
||||
$this->assertSame(['X502'], $this->col($this->report('repp_krsmhs', ['periode' => 368, 'status_krs' => 'disetujui']), 'nim'));
|
||||
$this->assertSame(['X504'], $this->col($this->report('repp_krsmhs', ['periode' => 368, 'status_krs' => 'belum']), 'nim'));
|
||||
$this->assertSame(['X502'], $this->col($this->report('repp_krsmhs', ['periode' => 368, 'angkatan' => 2020]), 'nim'));
|
||||
$this->assertSame(['X510'], $this->col($this->report('repp_krsmhs', ['periode' => 368], $this->context([22])), 'nim'));
|
||||
$this->assertSame([], $this->report('repp_krsmhs', ['periode' => 368], $this->context([]))->rows);
|
||||
|
||||
// Limit memotong baris, total tetap jumlah sebenarnya.
|
||||
$dibatasi = $this->report('repp_krsmhs', ['periode' => 368], null, 2);
|
||||
$this->assertCount(2, $dibatasi->rows);
|
||||
$this->assertSame(3, $dibatasi->total);
|
||||
$this->assertTrue($dibatasi->truncated());
|
||||
}
|
||||
|
||||
public function test_rekap_krs_per_prodi_dan_angkatan(): void
|
||||
{
|
||||
DB::connection('untan')->table('t_histori_mahasiswa')->insert(['idmahasiswa' => 504, 'idperiode' => 368, 'stat_akd_akhir' => 1]);
|
||||
|
||||
$result = $this->report('repp_rekapkrs', ['periode' => 368], $this->context([21, 22]));
|
||||
|
||||
$this->assertSame(['prodi', 'angkatan', 'aktif', 'belum', 'diajukan', 'disetujui', 'sks', 'rata'], $this->keys($result));
|
||||
$this->assertShape($result);
|
||||
$this->assertSame([
|
||||
['Teknik Informatika', 2021, 1, 1, 0, 0, 0, null],
|
||||
['Teknik Informatika', 2020, 1, 0, 0, 1, 4, 4.0],
|
||||
['Teknik Informatika', 2019, 1, 0, 1, 0, 2, 2.0],
|
||||
['Teknik Sipil', 2020, 1, 0, 0, 1, 2, 2.0],
|
||||
], array_map('array_values', $result->rows));
|
||||
$this->assertSame(4, $result->total);
|
||||
$this->assertSame('Jumlah: 4 mahasiswa aktif, 1 belum mengisi KRS', $result->summary[1]);
|
||||
|
||||
$this->assertSame(['Teknik Sipil'], array_unique($this->col($this->report('repp_rekapkrs', ['periode' => 368, 'prodi' => 22], $this->context([21, 22])), 'prodi')));
|
||||
$this->assertSame(['Teknik Informatika'], array_unique($this->col($this->report('repp_rekapkrs', ['periode' => 368]), 'prodi')));
|
||||
$this->assertSame([], $this->report('repp_rekapkrs', ['periode' => 368], $this->context([]))->rows);
|
||||
}
|
||||
|
||||
public function test_distribusi_sks_krs(): void
|
||||
{
|
||||
DB::connection('untan')->table('t_histori_mahasiswa')->insert(['idmahasiswa' => 504, 'idperiode' => 368, 'stat_akd_akhir' => 1]);
|
||||
|
||||
$result = $this->report('repp_distribusikrsmhs', ['periode' => 368]);
|
||||
|
||||
$this->assertSame(['sks', 'jumlah', 'persen'], $this->keys($result));
|
||||
$this->assertSame([[0, 1, 33.3], [2, 1, 33.3], [4, 1, 33.3]], array_map('array_values', $result->rows));
|
||||
$this->assertSame('Jumlah: 3 mahasiswa aktif, rata-rata 2,00 SKS', $result->summary[1]);
|
||||
|
||||
$this->assertSame([[4, 1, 100.0]], array_map('array_values', $this->report('repp_distribusikrsmhs', ['periode' => 368, 'angkatan' => 2020])->rows));
|
||||
$this->assertSame([[2, 1, 100.0]], array_map('array_values', $this->report('repp_distribusikrsmhs', ['periode' => 368], $this->context([22]))->rows));
|
||||
$this->assertSame([], $this->report('repp_distribusikrsmhs', ['periode' => 368], $this->context([]))->rows);
|
||||
}
|
||||
|
||||
public function test_mata_kuliah_mengulang(): void
|
||||
{
|
||||
$db = DB::connection('untan');
|
||||
$db->table('t_kst')->insert([
|
||||
// 500 mengulang Algoritma (sebelumnya A pada 362) dan Skripsi (tugas akhir: tidak dihitung).
|
||||
['idmahasiswa' => 500, 'idjadwal' => 1, 'idmatakuliah' => 1, 'idperiode' => 368, 'nilaihuruf' => null, 'stat' => 1],
|
||||
['idmahasiswa' => 500, 'idjadwal' => 5, 'idmatakuliah' => 5, 'idperiode' => 368, 'nilaihuruf' => null, 'stat' => 1],
|
||||
// 510 (prodi 22) mengulang MK 602 di periode 371.
|
||||
['idmahasiswa' => 510, 'idjadwal' => 602, 'idmatakuliah' => 602, 'idperiode' => 371, 'nilaihuruf' => null, 'stat' => 1],
|
||||
]);
|
||||
$db->table('t_kst')->where('idmahasiswa', 510)->where('idperiode', 368)->update(['nilaihuruf' => 'D']);
|
||||
|
||||
$result = $this->report('repp_mkmengulang', ['periode' => 368]);
|
||||
|
||||
$this->assertSame(['nim', 'nama', 'angkatan', 'kode', 'mk', 'sks', 'kelas', 'ke', 'lalu'], $this->keys($result));
|
||||
$this->assertShape($result);
|
||||
$this->assertSame([['D1041191001', 'IF101', 'Algoritma', 2, 'A']], array_map(fn (array $r): array => [$r['nim'], $r['kode'], $r['mk'], $r['ke'], $r['lalu']], $result->rows));
|
||||
$this->assertSame(1, $result->total);
|
||||
|
||||
$this->assertSame([], $this->report('repp_mkmengulang', ['periode' => 371])->rows);
|
||||
$sipil = $this->report('repp_mkmengulang', ['periode' => 371], $this->context([22]));
|
||||
$this->assertSame([['X510', 'MK602', 2, 'D']], array_map(fn (array $r): array => [$r['nim'], $r['kode'], $r['ke'], $r['lalu']], $sipil->rows));
|
||||
$this->assertSame([], $this->report('repp_mkmengulang', ['periode' => 368], $this->context([]))->rows);
|
||||
}
|
||||
|
||||
public function test_rekap_ipk(): void
|
||||
{
|
||||
$this->seedIpk();
|
||||
|
||||
$result = $this->report('repp_rekapipk', ['periode' => 368], $this->context([21, 22]));
|
||||
|
||||
$this->assertSame(['prodi', 'angkatan', 'jumlah', 'rata', 'min', 'maks', 'k1', 'k2', 'k3', 'k4'], $this->keys($result));
|
||||
$this->assertShape($result);
|
||||
// 504 (SKS 0) dan 511 (tanpa IPK) tidak dihitung.
|
||||
$this->assertSame([
|
||||
['Teknik Informatika', 2020, 1, 1.8, 1.8, 1.8, 1, 0, 0, 0],
|
||||
['Teknik Informatika', 2019, 4, 3.5, 2.9, 3.9, 0, 0, 1, 3],
|
||||
['Teknik Sipil', 2020, 1, 2.5, 2.5, 2.5, 0, 1, 0, 0],
|
||||
], array_map('array_values', $result->rows));
|
||||
$this->assertSame('Jumlah: 6 mahasiswa, rata-rata IPK 3,05', $result->summary[1]);
|
||||
|
||||
$aktif = $this->report('repp_rekapipk', ['periode' => 368, 'status' => 1], $this->context([21, 22]));
|
||||
$this->assertSame([1, 2, 1], $this->col($aktif, 'jumlah'));
|
||||
|
||||
DB::connection('untan')->table('t_progdi')->insert([['idbagian' => 21, 'idjenjang' => 2], ['idbagian' => 22, 'idjenjang' => 1]]);
|
||||
$this->assertSame([1 => 'D3', 2 => 'S1'], collect($this->reports->definition('repp_rekapipk', $this->context([21, 22]))['params'])->firstWhere('name', 'jenjang')['options']);
|
||||
$this->assertSame(['Teknik Sipil'], $this->col($this->report('repp_rekapipk', ['periode' => 368, 'jenjang' => 1], $this->context([21, 22])), 'prodi'));
|
||||
$this->assertSame([2020], $this->col($this->report('repp_rekapipk', ['periode' => 368, 'angkatan' => 2020, 'prodi' => 21], $this->context([21, 22])), 'angkatan'));
|
||||
$this->assertSame([2020], $this->col($this->report('repp_rekapipk', ['periode' => 368, 'jalur' => 3]), 'angkatan'));
|
||||
|
||||
DB::connection('untan')->table('t_kurikulum')->insert(['idkurikulum' => 900, 'idprogdi' => 21, 'idprogram' => 1, 'namakurikulum' => 'Kurikulum 2020']);
|
||||
DB::connection('untan')->table('t_mahasiswa')->where('idmahasiswa', 500)->update(['idkurikulum' => 900]);
|
||||
$this->assertSame([900 => 'Kurikulum 2020'], collect($this->reports->definition('repp_rekapipk', $this->context())['params'])->firstWhere('name', 'kurikulum')['options']);
|
||||
$this->assertSame([1], $this->col($this->report('repp_rekapipk', ['periode' => 368, 'kurikulum' => 900]), 'jumlah'));
|
||||
|
||||
$this->assertSame([], $this->report('repp_rekapipk', ['periode' => 368], $this->context([]))->rows);
|
||||
}
|
||||
|
||||
public function test_daftar_ipk_dan_cakupan(): void
|
||||
{
|
||||
$this->seedIpk();
|
||||
|
||||
$result = $this->report('repp_ipk', ['periode' => 368, 'prodi' => 21]);
|
||||
|
||||
$this->assertSame(['nim', 'nama', 'angkatan', 'sistem', 'jalur', 'sks', 'ips', 'ipk'], $this->keys($result));
|
||||
$this->assertShape($result);
|
||||
$this->assertSame(['D1041191001', 'X501', 'X502', 'X505', 'X506'], $this->col($result, 'nim'));
|
||||
$this->assertSame(['Reguler A', 'SNMPTN'], [$result->rows[0]['sistem'], $result->rows[0]['jalur']]);
|
||||
$this->assertSame([3.5, 30, 3.6], [$result->rows[0]['ips'], $result->rows[0]['sks'], $result->rows[0]['ipk']]);
|
||||
|
||||
$this->assertSame(['X502'], $this->col($this->report('repp_ipk', ['periode' => 368, 'ipk_maks' => '2,0']), 'nim'));
|
||||
$this->assertSame(['D1041191001', 'X505', 'X506'], $this->col($this->report('repp_ipk', ['periode' => 368, 'ipk_min' => 3.5]), 'nim'));
|
||||
$this->assertSame(['X501'], $this->col($this->report('repp_ipk', ['periode' => 368, 'ipk_min' => 2, 'ipk_maks' => 3]), 'nim'));
|
||||
$this->assertSame(['X505'], $this->col($this->report('repp_ipk', ['periode' => 368, 'status' => 3]), 'nim'));
|
||||
$this->assertSame(['X502'], $this->col($this->report('repp_ipk', ['periode' => 368, 'angkatan' => 2020]), 'nim'));
|
||||
$this->assertSame(['X502'], $this->col($this->report('repp_ipk', ['periode' => 368, 'jalur' => 3]), 'nim'));
|
||||
|
||||
// Prodi dipilih dari akun dengan dua prodi; prodi lain tidak terlihat.
|
||||
$this->assertSame(['X510'], $this->col($this->report('repp_ipk', ['periode' => 368, 'prodi' => 22], $this->context([21, 22])), 'nim'));
|
||||
$this->assertNotContains('X510', $this->col($this->report('repp_ipk', ['periode' => 368, 'prodi' => 22]), 'nim'));
|
||||
$this->assertSame([], $this->report('repp_ipk', ['periode' => 368], $this->context([]))->rows);
|
||||
|
||||
// Limit dan total.
|
||||
$dibatasi = $this->report('repp_ipk', ['periode' => 368], null, 2);
|
||||
$this->assertSame(['D1041191001', 'X501'], $this->col($dibatasi, 'nim'));
|
||||
$this->assertSame(5, $dibatasi->total);
|
||||
$this->assertTrue($dibatasi->truncated());
|
||||
}
|
||||
|
||||
public function test_peringkat_ipk(): void
|
||||
{
|
||||
$this->seedIpk();
|
||||
|
||||
$result = $this->report('repp_ipktertinggi', ['periode' => 368]);
|
||||
|
||||
$this->assertSame(['rank', 'nim', 'nama', 'angkatan', 'sistem', 'sks', 'ips', 'ipk'], $this->keys($result));
|
||||
$this->assertShape($result);
|
||||
// IPK sama (500 dan 506) berbagi peringkat; urutan berikutnya melompat.
|
||||
$this->assertSame(['X505', 'D1041191001', 'X506', 'X501', 'X502'], $this->col($result, 'nim'));
|
||||
$this->assertSame([1, 2, 2, 4, 5], $this->col($result, 'rank'));
|
||||
$this->assertSame([3.9, 3.6, 3.6, 2.9, 1.8], $this->col($result, 'ipk'));
|
||||
|
||||
$this->assertSame(['X505'], $this->col($this->report('repp_ipktertinggi', ['periode' => 368, 'status' => 3]), 'nim'));
|
||||
$this->assertSame(['X510'], $this->col($this->report('repp_ipktertinggi', ['periode' => 368], $this->context([22])), 'nim'));
|
||||
$this->assertSame([], $this->report('repp_ipktertinggi', ['periode' => 368], $this->context([]))->rows);
|
||||
|
||||
$teratas = $this->report('repp_ipktertinggi', ['periode' => 368], null, 1);
|
||||
$this->assertSame(['X505'], $this->col($teratas, 'nim'));
|
||||
$this->assertSame(5, $teratas->total);
|
||||
}
|
||||
|
||||
public function test_nilai_kkn(): void
|
||||
{
|
||||
$db = DB::connection('untan');
|
||||
$db->table('t_matakuliah')->insert([
|
||||
['idmatakuliah' => 800, 'kodemk' => 'UN800', 'namamk' => 'Kuliah Kerja Nyata (KKN)', 'sks' => 3, 'tipe' => 0],
|
||||
['idmatakuliah' => 801, 'kodemk' => 'UN801', 'namamk' => 'Kuliah Kerja Mahasiswa', 'sks' => 2, 'tipe' => 0],
|
||||
]);
|
||||
$db->table('t_jadwal')->insert([
|
||||
['idjadwal' => 800, 'idmatakuliah' => 800, 'idperiode' => 368, 'flag_cetak' => true],
|
||||
['idjadwal' => 801, 'idmatakuliah' => 801, 'idperiode' => 365, 'flag_cetak' => false],
|
||||
]);
|
||||
$db->table('t_kst')->insert([
|
||||
['idmahasiswa' => 500, 'idjadwal' => 800, 'idmatakuliah' => 800, 'idperiode' => 368, 'nilaitotal' => 85, 'nilaimutu' => 4, 'nilaihuruf' => 'A', 'stat' => 1],
|
||||
['idmahasiswa' => 502, 'idjadwal' => 801, 'idmatakuliah' => 801, 'idperiode' => 365, 'nilaitotal' => 70, 'nilaimutu' => 3, 'nilaihuruf' => 'B', 'stat' => 1],
|
||||
['idmahasiswa' => 510, 'idjadwal' => 800, 'idmatakuliah' => 800, 'idperiode' => 368, 'nilaitotal' => 60, 'nilaimutu' => 2, 'nilaihuruf' => 'C', 'stat' => 1],
|
||||
]);
|
||||
|
||||
$result = $this->report('repp_nilaikkn');
|
||||
|
||||
$this->assertSame(['nim', 'nama', 'angkatan', 'periode', 'kode', 'mk', 'sks', 'nilai', 'huruf', 'bobot'], $this->keys($result));
|
||||
$this->assertShape($result);
|
||||
$this->assertSame(['D1041191001', 'X502'], $this->col($result, 'nim'));
|
||||
$this->assertSame(['2020/2021 Ganjil', 85.0, 'A', 4.0], [$result->rows[0]['periode'], $result->rows[0]['nilai'], $result->rows[0]['huruf'], $result->rows[0]['bobot']]);
|
||||
// Nilai belum terbit tidak ditampilkan.
|
||||
$this->assertSame([null, null, null], [$result->rows[1]['nilai'], $result->rows[1]['huruf'], $result->rows[1]['bobot']]);
|
||||
$this->assertSame(2, $result->total);
|
||||
|
||||
$this->assertSame(['D1041191001'], $this->col($this->report('repp_nilaikkn', ['periode' => 368]), 'nim'));
|
||||
$this->assertSame(['X510'], $this->col($this->report('repp_nilaikkn', [], $this->context([22])), 'nim'));
|
||||
$this->assertSame([], $this->report('repp_nilaikkn', [], $this->context([]))->rows);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,575 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Operator\Reports;
|
||||
|
||||
use App\Support\Legacy\Reports\DosenReports;
|
||||
use App\Support\Legacy\Reports\ReportContext;
|
||||
use App\Support\Legacy\Reports\ReportResult;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Tests\Concerns\FakesLegacyDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Laporan dosen dan pegawai dari DB lama (tiruan). Prodi 21 dan 22 milik akun; dosen Joko (22) ber-home base di prodi 99.
|
||||
* Kelas periode 368: 601 (prodi 21, kurikulum 70, 3 SKS), 602 (prodi 22), 603 dan 604 (prodi 21, 2 SKS).
|
||||
*/
|
||||
class DosenReportsTest extends TestCase
|
||||
{
|
||||
use FakesLegacyDatabase;
|
||||
use RefreshDatabase;
|
||||
|
||||
private const string SITI = '197501012000031002';
|
||||
|
||||
private const string ANDI = '198502022010121001';
|
||||
|
||||
private const string DEWI = '199003032015032001';
|
||||
|
||||
private const string JOKO = '197001012000011099';
|
||||
|
||||
private DosenReports $reports;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->useLegacyDatabase();
|
||||
$this->seedLegacyOverview();
|
||||
$this->seedLegacyEmployees();
|
||||
$this->extendSchema();
|
||||
$this->seedReportData();
|
||||
$this->reports = app(DosenReports::class);
|
||||
}
|
||||
|
||||
/** Kolom/tabel yang belum ada di DB tiruan bersama. */
|
||||
private function extendSchema(): void
|
||||
{
|
||||
$schema = Schema::connection('untan');
|
||||
$add = function (string $table, array $columns) use ($schema): void {
|
||||
$missing = array_filter($columns, fn (string $type, string $name): bool => ! $schema->hasColumn($table, $name), ARRAY_FILTER_USE_BOTH);
|
||||
if ($missing === []) {
|
||||
return;
|
||||
}
|
||||
$schema->table($table, function (Blueprint $t) use ($missing): void {
|
||||
foreach ($missing as $name => $type) {
|
||||
match ($type) {
|
||||
'integer' => $t->integer($name)->nullable(),
|
||||
'date' => $t->date($name)->nullable(),
|
||||
default => $t->string($name)->nullable(),
|
||||
};
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$add('t_pegawai', ['idjenispegawai' => 'integer', 'pendidikanterakhir' => 'integer', 'agama' => 'integer', 'tgllahir' => 'date',
|
||||
'tempatlahir' => 'string', 'identitas' => 'string', 'alamat' => 'string', 'npwp' => 'string']);
|
||||
$add('t_dosen', ['idpangkatdosen' => 'integer']);
|
||||
$add('t_jabatanbagian', ['idjenisjabatan' => 'integer']);
|
||||
|
||||
if (! $schema->hasTable('pdpt_tran_aktivitas_mengajar_dosen')) {
|
||||
$schema->create('pdpt_tran_aktivitas_mengajar_dosen', function (Blueprint $table) {
|
||||
$table->integer('kode_mengajar_dosen')->primary();
|
||||
$table->integer('idjadwaldosen')->nullable();
|
||||
$table->string('jml_tatap_muka_rencana')->nullable();
|
||||
$table->string('jml_tatap_muka_realisasi')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private function seedReportData(): void
|
||||
{
|
||||
$db = DB::connection('untan');
|
||||
|
||||
$db->table('t_jenispegawai')->insert([['idjenispegawai' => 1, 'jenispegawai' => 'Dosen'], ['idjenispegawai' => 2, 'jenispegawai' => 'Staff']]);
|
||||
$db->table('t_pangkatdosen')->insert([['idpangkatdosen' => 2, 'pangkatdosen' => 'Penata Muda'], ['idpangkatdosen' => 36, 'pangkatdosen' => 'Pembina']]);
|
||||
$db->table('t_tingkat_pendidikan')->insert([['idtingkat' => 8, 'tingkatpendidikan' => 'Sarjana / S1'], ['idtingkat' => 9, 'tingkatpendidikan' => 'Magister / S2']]);
|
||||
$db->table('t_jabatanfungsional')->insertOrIgnore([['idjabatanfungsional' => 2, 'jabatan' => 'Asisten Ahli']]);
|
||||
$db->table('t_jenisjabatan')->insert([['idjenisjabatan' => 5, 'namajabatan' => 'Dekan', 'urut' => 1], ['idjenisjabatan' => 8, 'namajabatan' => 'Ketua Program Studi', 'urut' => 2]]);
|
||||
|
||||
// Biodata: Siti (11) lengkap; Lina (24) kosong; Andi (20) sebagian dan tidak aktif; Joko (22) home base prodi lain.
|
||||
$db->table('t_pegawai')->where('idpegawai', 11)->update([
|
||||
'idjenispegawai' => 1, 'pendidikanterakhir' => 9, 'agama' => 1, 'tgllahir' => '1975-01-01', 'tempatlahir' => 'Pontianak',
|
||||
'identitas' => '6171010101750001', 'alamat' => 'Jl. Contoh 1', 'npwp' => '12.345',
|
||||
]);
|
||||
$db->table('t_pegawai')->where('idpegawai', 24)->update(['idjenispegawai' => 1, 'pendidikanterakhir' => 0, 'gelardepan' => '-']);
|
||||
$db->table('t_pegawai')->where('idpegawai', 20)->update(['idjenispegawai' => 1, 'pendidikanterakhir' => 8]);
|
||||
$db->table('t_pegawai')->where('idpegawai', 22)->update(['idjenispegawai' => 1]);
|
||||
$db->table('t_pegawai')->where('idpegawai', 21)->update(['idjenispegawai' => 2]);
|
||||
$db->table('t_dosen')->where('idpegawai', 11)->update(['idpangkatdosen' => 2]);
|
||||
$db->table('t_dosen')->where('idpegawai', 24)->update(['idpangkatdosen' => 36, 'idjabatanfungsional' => 2]);
|
||||
// Jabatan aktif: Dekan fakultas 5 (Dewi, 21) dan Ketua Program Studi 21 (Siti, 11).
|
||||
$db->table('t_jabatanbagian')->where('idjabatanbagian', 1)->update(['idjenisjabatan' => 5]);
|
||||
$db->table('t_jabatanbagian')->insert(['idjabatanbagian' => 3, 'idbagian' => 21, 'idjenisjabatan' => 8]);
|
||||
$db->table('t_jabatanpegawai')->insert(['idpegawai' => 11, 'idjabatanbagian' => 3, 'aktif' => 1]);
|
||||
|
||||
// Pengajar kelas periode 368.
|
||||
$db->table('t_matakuliah')->where('idmatakuliah', 601)->update(['idkurikulum' => 70, 'sks' => 3]);
|
||||
$db->table('t_kurikulum')->insert(['idkurikulum' => 70, 'idprogdi' => 21, 'idprogram' => 1, 'idperiode' => 368, 'namakurikulum' => 'KBK']);
|
||||
$db->table('t_jadwal')->where('idjadwal', 601)->update(['kelas' => 'A']);
|
||||
$db->table('t_jadwaldosen')->insert([
|
||||
['idjadwaldosen' => 1, 'idjadwal' => 601, 'iddosen' => 11, 'dosenke' => 1],
|
||||
['idjadwaldosen' => 2, 'idjadwal' => 601, 'iddosen' => 22, 'dosenke' => 2],
|
||||
['idjadwaldosen' => 3, 'idjadwal' => 602, 'iddosen' => 20, 'dosenke' => 1],
|
||||
['idjadwaldosen' => 4, 'idjadwal' => 603, 'iddosen' => 11, 'dosenke' => 1],
|
||||
['idjadwaldosen' => 5, 'idjadwal' => 604, 'iddosen' => 24, 'dosenke' => 1],
|
||||
]);
|
||||
$db->table('t_ruang')->insert(['idruang' => 1, 'namaruang' => 'R.101']);
|
||||
$db->table('t_jadwalruangkuliah')->insert(['idjadwaltemu' => $db->table('t_jadwaltemu')->where('idjadwal', 601)->value('idjadwaltemu'), 'idruang' => 1]);
|
||||
|
||||
// Rencana/realisasi tatap muka (data pelaporan); kelas 604 belum dilaporkan.
|
||||
$db->table('pdpt_tran_aktivitas_mengajar_dosen')->insert([
|
||||
['kode_mengajar_dosen' => 1, 'idjadwaldosen' => 1, 'jml_tatap_muka_rencana' => '16', 'jml_tatap_muka_realisasi' => '14'],
|
||||
['kode_mengajar_dosen' => 2, 'idjadwaldosen' => 2, 'jml_tatap_muka_rencana' => '16', 'jml_tatap_muka_realisasi' => '16'],
|
||||
['kode_mengajar_dosen' => 3, 'idjadwaldosen' => 3, 'jml_tatap_muka_rencana' => '16', 'jml_tatap_muka_realisasi' => '10'],
|
||||
['kode_mengajar_dosen' => 4, 'idjadwaldosen' => 4, 'jml_tatap_muka_rencana' => '0', 'jml_tatap_muka_realisasi' => '0'],
|
||||
]);
|
||||
|
||||
// PA: Siti membimbing 500, 501, 503 (505 sudah lulus); 502 belum ber-PA; Lina membimbing 504; Andi membimbing 510 (prodi 22).
|
||||
foreach ([500 => 11, 501 => 11, 502 => null, 503 => 11, 504 => 24, 505 => 11, 510 => 20] as $id => $pa) {
|
||||
$db->table('t_mahasiswa')->where('idmahasiswa', $id)->update(['idpa' => $pa]);
|
||||
}
|
||||
// Tugas akhir: 500 dibimbing Siti dan Lina (berjalan); 505 dibimbing Siti (lulus); 510 prodi lain.
|
||||
$db->table('t_skripsi')->insert([
|
||||
['idmahasiswa' => 500, 'judul' => 'Sistem Informasi Akademik', 'pembimbing1' => 11, 'pembimbing2' => 24, 'tgllulus' => null],
|
||||
['idmahasiswa' => 505, 'judul' => 'Aplikasi Perpustakaan', 'pembimbing1' => 11, 'pembimbing2' => null, 'tgllulus' => '2020-09-01'],
|
||||
['idmahasiswa' => 510, 'judul' => 'Jembatan Beton', 'pembimbing1' => 20, 'pembimbing2' => null, 'tgllulus' => null],
|
||||
]);
|
||||
|
||||
// Jurnal perwalian; periode 368 = Agustus 2020 sampai Januari 2021.
|
||||
$db->table('x_message')->insert([
|
||||
['idmhs' => 500, 'iddosen' => 11, 'message' => 'Segera isi KRS', 'tgl' => '2020-09-10 10:30:00', 'deleted_at' => null],
|
||||
['idmhs' => 501, 'iddosen' => 11, 'message' => 'Konsultasi judul', 'tgl' => '2019-03-01 08:00:00', 'deleted_at' => null],
|
||||
['idmhs' => 500, 'iddosen' => 11, 'message' => 'Pesan dihapus', 'tgl' => '2020-09-11 08:00:00', 'deleted_at' => '2020-10-01 00:00:00'],
|
||||
['idmhs' => 510, 'iddosen' => 20, 'message' => 'Prodi lain', 'tgl' => '2020-09-12 08:00:00', 'deleted_at' => null],
|
||||
]);
|
||||
}
|
||||
|
||||
private function context(array $prodi = [21, 22]): ReportContext
|
||||
{
|
||||
$names = DB::connection('untan')->table('t_bagian')->whereIn('idbagian', $prodi)->orderBy('namabagian')->pluck('namabagian', 'idbagian')->all();
|
||||
|
||||
return new ReportContext(1, 'staf', $prodi, $names);
|
||||
}
|
||||
|
||||
private function report(string $slug, array $params = [], ?ReportContext $context = null, int $limit = 100): ReportResult
|
||||
{
|
||||
return $this->reports->run($slug, $params, $context ?? $this->context(), $limit);
|
||||
}
|
||||
|
||||
/** @return list<mixed> */
|
||||
private function column(ReportResult $result, string $key): array
|
||||
{
|
||||
return array_column($result->rows, $key);
|
||||
}
|
||||
|
||||
private function keys(ReportResult $result): array
|
||||
{
|
||||
return array_column($result->columns, 'key');
|
||||
}
|
||||
|
||||
public function test_slugs_hanya_yang_bersumber(): void
|
||||
{
|
||||
$slugs = $this->reports->slugs();
|
||||
|
||||
$this->assertCount(12, $slugs);
|
||||
foreach (['repp_honordosen', 'repp_isiabsensidosen', 'repp_rekapedomdosen'] as $none) {
|
||||
$this->assertNotContains($none, $slugs);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_definisi_valid(): void
|
||||
{
|
||||
foreach ($this->reports->slugs() as $slug) {
|
||||
$params = $this->reports->definition($slug, $this->context())['params'];
|
||||
$names = array_column($params, 'name');
|
||||
$this->assertSame($names, array_values(array_unique($names)), $slug);
|
||||
$this->assertEmpty(array_intersect($names, ['tampil', 'kop']), $slug);
|
||||
foreach ($params as $param) {
|
||||
$this->assertContains($param['type'], ['select', 'text', 'number', 'date', 'check'], $slug);
|
||||
if ($param['type'] === 'select') {
|
||||
$this->assertIsArray($param['options'], $slug);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rekap = collect($this->reports->definition('repp_rekapmengajar', $this->context())['params'])->keyBy('name');
|
||||
$this->assertTrue($rekap['periode']['required']);
|
||||
$this->assertTrue($rekap['prodi']['required']);
|
||||
$this->assertSame([21, 22], array_keys($rekap['prodi']['options']));
|
||||
$this->assertSame(368, $rekap['periode']['default']);
|
||||
$this->assertSame([70 => 'Teknik Informatika - KBK 2020'], $rekap['kurikulum']['options']);
|
||||
$this->assertSame([1 => 'Reguler A'], $rekap['program']['options']);
|
||||
|
||||
$daftar = collect($this->reports->definition('repp_daftardosen', $this->context())['params'])->keyBy('name');
|
||||
$this->assertSame([1 => 'Dosen', 2 => 'Staff'], $daftar['jenis']['options']);
|
||||
$this->assertSame([5 => 'Dekan', 8 => 'Ketua Program Studi'], $daftar['struktural']['options']);
|
||||
$this->assertSame(['aktif', 'nonaktif'], array_keys($daftar['aktif']['options']));
|
||||
}
|
||||
|
||||
public function test_jadwal_semester_dosen(): void
|
||||
{
|
||||
$result = $this->report('repp_jadwalajar', ['periode' => 368]);
|
||||
|
||||
$this->assertSame(['nip', 'dosen', 'hari', 'jam', 'kode', 'mk', 'kelas', 'sks', 'ruang'], $this->keys($result));
|
||||
// Kelas 601 diampu dua dosen, ditambah 602, 603, dan 604: lima baris.
|
||||
$this->assertSame(5, $result->count());
|
||||
$row = collect($result->rows)->firstWhere('kode', 'MK601');
|
||||
$this->assertSame(['Senin', '07.30–09.10', 'R.101', 3], [$row['hari'], $row['jam'], $row['ruang'], $row['sks']]);
|
||||
$this->assertNull(collect($result->rows)->firstWhere('kode', 'MK603')['hari']);
|
||||
$this->assertSame(['Periode: 2020/2021 Ganjil', 'Jumlah: 5 baris jadwal'], $result->summary);
|
||||
|
||||
$siti = $this->report('repp_jadwalajar', ['periode' => 368, 'dosen' => 'siti']);
|
||||
$this->assertEqualsCanonicalizing(['MK601', 'MK603'], $this->column($siti, 'kode'));
|
||||
}
|
||||
|
||||
public function test_jadwal_semester_dosen_cakupan_prodi(): void
|
||||
{
|
||||
$only21 = $this->report('repp_jadwalajar', ['periode' => 368], $this->context([21]));
|
||||
|
||||
$this->assertNotContains('MK602', $this->column($only21, 'kode'));
|
||||
$this->assertSame(4, $only21->count());
|
||||
$this->assertSame([], $this->report('repp_jadwalajar', ['periode' => 368], $this->context([]))->rows);
|
||||
}
|
||||
|
||||
public function test_batas_dan_total(): void
|
||||
{
|
||||
$result = $this->report('repp_jadwalajar', ['periode' => 368], null, 2);
|
||||
|
||||
$this->assertCount(2, $result->rows);
|
||||
$this->assertSame(5, $result->total);
|
||||
$this->assertTrue($result->truncated());
|
||||
}
|
||||
|
||||
public function test_jadwal_mengajar_dosen(): void
|
||||
{
|
||||
$plain = $this->report('repp_jadwalmengajar', ['periode' => 368]);
|
||||
$this->assertSame(['nip', 'dosen', 'kode', 'mk', 'kelas', 'prodi', 'sks', 'jadwal'], $this->keys($plain));
|
||||
$this->assertSame(5, $plain->count());
|
||||
|
||||
$full = $this->report('repp_jadwalmengajar', ['periode' => 368, 'unit' => 21, 'peserta' => true, 'homebase' => true]);
|
||||
$this->assertSame(['peserta', 'homebase'], array_slice($this->keys($full), -2));
|
||||
$this->assertSame(4, $full->count());
|
||||
|
||||
// Kelas 601: KRS 500 dan 502 (2 peserta). Kelas 603 hanya punya KRS batal.
|
||||
$mk601 = collect($full->rows)->where('kode', 'MK601')->values();
|
||||
$this->assertSame([2, 2], $mk601->pluck('peserta')->all());
|
||||
$this->assertSame('Senin 07.30–09.10', $mk601[0]['jadwal']);
|
||||
$this->assertEqualsCanonicalizing([null, 'Teknik Informatika'], $mk601->pluck('homebase')->all());
|
||||
$mk603 = collect($full->rows)->firstWhere('kode', 'MK603');
|
||||
$this->assertSame([0, null], [$mk603['peserta'], $mk603['jadwal']]);
|
||||
}
|
||||
|
||||
public function test_jadwal_mengajar_dosen_cakupan(): void
|
||||
{
|
||||
$this->assertSame([], $this->report('repp_jadwalmengajar', ['periode' => 368], $this->context([]))->rows);
|
||||
$this->assertNotContains('MK602', $this->column($this->report('repp_jadwalmengajar', ['periode' => 368], $this->context([21])), 'kode'));
|
||||
$this->assertSame(['MK602'], $this->column($this->report('repp_jadwalmengajar', ['periode' => 368, 'unit' => 22]), 'kode'));
|
||||
}
|
||||
|
||||
public function test_rekap_jadwal_mengajar(): void
|
||||
{
|
||||
$result = $this->report('repp_rekapmengajar', ['periode' => 368, 'prodi' => 21, 'totalsks' => true]);
|
||||
|
||||
$this->assertSame(['nip', 'dosen', 'kelas', 'sks', 'mk'], $this->keys($result));
|
||||
$byNip = collect($result->rows)->keyBy('nip');
|
||||
// Siti: 601 (3 SKS) dan 603 (2 SKS); Joko (home base prodi lain) hanya 601; Lina 604 (2 SKS).
|
||||
$this->assertCount(3, $result->rows);
|
||||
$this->assertSame([2, 5], [$byNip[self::SITI]['kelas'], $byNip[self::SITI]['sks']]);
|
||||
$this->assertStringContainsString('MK601 Kelas 601 (A)', $byNip[self::SITI]['mk']);
|
||||
$this->assertSame([1, 3], [$byNip[self::JOKO]['kelas'], $byNip[self::JOKO]['sks']]);
|
||||
$this->assertSame(3, $result->count());
|
||||
|
||||
$noSks = $this->report('repp_rekapmengajar', ['periode' => 368, 'prodi' => 21, 'totalsks' => false]);
|
||||
$this->assertSame(['nip', 'dosen', 'kelas', 'mk'], $this->keys($noSks));
|
||||
}
|
||||
|
||||
public function test_rekap_jadwal_mengajar_filter_dan_cakupan(): void
|
||||
{
|
||||
$nips = fn (array $params, ?ReportContext $c = null): array => $this->column($this->report('repp_rekapmengajar', ['periode' => 368, 'prodi' => 21] + $params, $c), 'nip');
|
||||
|
||||
$this->assertEqualsCanonicalizing([self::JOKO, self::SITI], $nips(['kurikulum' => 70]));
|
||||
$this->assertEqualsCanonicalizing([self::JOKO, self::SITI], $nips(['program' => 1]));
|
||||
$this->assertSame(['lina'], $nips(['kelas' => 'Kelas 604']));
|
||||
$this->assertSame(['lina'], $nips(['pegawai' => 'LINA']));
|
||||
|
||||
// Prodi 22 bukan milik akun ini; prodi akun kosong tidak punya data.
|
||||
$this->assertSame([], $this->report('repp_rekapmengajar', ['periode' => 368, 'prodi' => 22], $this->context([21]))->rows);
|
||||
$this->assertSame([], $nips([], $this->context([])));
|
||||
}
|
||||
|
||||
public function test_daftar_dosen(): void
|
||||
{
|
||||
$result = $this->report('repp_daftardosen');
|
||||
|
||||
// Home base prodi 21 dan 22: Andi, Lina, Siti (urut nama). Joko (home base 99) tidak ikut.
|
||||
$this->assertSame([self::ANDI, 'lina', self::SITI], $this->column($result, 'nip'));
|
||||
$this->assertSame(3, $result->count());
|
||||
$siti = collect($result->rows)->firstWhere('nip', self::SITI);
|
||||
$this->assertSame(
|
||||
['P', 'Dosen', 'Tetap', 'Penata Muda', 'Magister / S2', 'Lektor', 'Ketua Program Studi (Teknik Informatika)', 'Aktif', 'Teknik Informatika'],
|
||||
[$siti['kelamin'], $siti['jenis'], $siti['status'], $siti['pangkat'], $siti['pendidikan'], $siti['jabfung'], $siti['struktural'], $siti['aktif'], $siti['homebase']],
|
||||
);
|
||||
$this->assertSame('Tidak aktif', collect($result->rows)->firstWhere('nip', self::ANDI)['aktif']);
|
||||
$lina = collect($result->rows)->firstWhere('nip', 'lina');
|
||||
$this->assertNull($lina['pendidikan']);
|
||||
$this->assertSame('Lina', $lina['nama']);
|
||||
}
|
||||
|
||||
public function test_daftar_dosen_filter_dan_cakupan(): void
|
||||
{
|
||||
$nips = fn (array $params, ?ReportContext $c = null): array => $this->column($this->report('repp_daftardosen', $params, $c), 'nip');
|
||||
|
||||
$this->assertSame([self::ANDI], $nips(['aktif' => 'nonaktif']));
|
||||
$this->assertCount(2, $nips(['aktif' => 'aktif']));
|
||||
$this->assertSame([self::SITI], $nips(['pangkat' => 2]));
|
||||
$this->assertSame([self::ANDI], $nips(['pendidikan' => 8]));
|
||||
$this->assertSame(['lina'], $nips(['jabfung' => 2]));
|
||||
$this->assertSame([self::SITI], $nips(['struktural' => 8]));
|
||||
$this->assertSame([], $nips(['struktural' => 5]));
|
||||
$this->assertCount(3, $nips(['jenis' => 1]));
|
||||
// Prodi 22 saja: hanya Andi.
|
||||
$this->assertSame([self::ANDI], $nips([], $this->context([22])));
|
||||
$this->assertSame([], $nips([], $this->context([])));
|
||||
|
||||
$this->assertNotContains('homebase', $this->keys($this->report('repp_daftardosen', ['homebase' => false])));
|
||||
}
|
||||
|
||||
public function test_daftar_pegawai(): void
|
||||
{
|
||||
$result = $this->report('repp_daftarpeg');
|
||||
|
||||
// Dosen prodi 21/22 (Siti, Andi, Lina) dan pemegang jabatan aktif: Dewi (Dekan). Rudi jabatannya nonaktif.
|
||||
$this->assertEqualsCanonicalizing([self::SITI, self::ANDI, 'lina', self::DEWI], $this->column($result, 'nip'));
|
||||
$dewi = collect($result->rows)->firstWhere('nip', self::DEWI);
|
||||
$this->assertSame(['Staff', 'Dekan (Fakultas Teknik)', 'P'], [$dewi['jenis'], $dewi['jabatan'], $dewi['kelamin']]);
|
||||
$this->assertNull($dewi['homebase']);
|
||||
$this->assertSame('Teknik Informatika', collect($result->rows)->firstWhere('nip', self::SITI)['homebase']);
|
||||
}
|
||||
|
||||
public function test_daftar_pegawai_filter_dan_cakupan(): void
|
||||
{
|
||||
$nips = fn (array $params, ?ReportContext $c = null): array => $this->column($this->report('repp_daftarpeg', $params, $c), 'nip');
|
||||
|
||||
$this->assertEqualsCanonicalizing([self::SITI, 'lina'], $nips(['homebase' => 21]));
|
||||
$this->assertSame([self::DEWI], $nips(['jenis' => 2]));
|
||||
$this->assertEqualsCanonicalizing([self::SITI, self::DEWI], $nips(['kelamin' => 2]));
|
||||
$this->assertSame([self::ANDI], $nips(['aktif' => 'nonaktif']));
|
||||
// Prodi 22 saja: Andi, ditambah Dewi lewat jabatan fakultas 5.
|
||||
$this->assertEqualsCanonicalizing([self::ANDI, self::DEWI], $nips([], $this->context([22])));
|
||||
$this->assertSame([], $nips([], $this->context([])));
|
||||
}
|
||||
|
||||
public function test_kelengkapan_biodata_dosen(): void
|
||||
{
|
||||
$result = $this->report('repp_kelengkapanbiodosen');
|
||||
|
||||
$this->assertSame(['nip', 'nama', 'homebase', 'terisi', 'dari', 'persen', 'kurang'], $this->keys($result));
|
||||
$siti = collect($result->rows)->firstWhere('nip', self::SITI);
|
||||
$this->assertSame([11, 100.0, null], [$siti['terisi'], $siti['persen'], $siti['kurang']]);
|
||||
|
||||
$lina = collect($result->rows)->firstWhere('nip', 'lina');
|
||||
$this->assertSame(0, $lina['terisi']);
|
||||
$this->assertSame('NIDN, Tempat Lahir, Tanggal Lahir, Jenis Kelamin, Agama, NIK, Alamat, No. HP/Telepon, Email, Pendidikan Terakhir, NPWP', $lina['kurang']);
|
||||
// Andi: NIDN, jenis kelamin, dan pendidikan terisi.
|
||||
$this->assertSame(3, collect($result->rows)->firstWhere('nip', self::ANDI)['terisi']);
|
||||
$this->assertSame(['Jumlah: 3 dosen', 'Lengkap: 1 dosen (33.3%)'], $result->summary);
|
||||
|
||||
$onlyMissing = $this->report('repp_kelengkapanbiodosen', ['kurang' => true]);
|
||||
$this->assertCount(2, $onlyMissing->rows);
|
||||
$this->assertNotContains(self::SITI, $this->column($onlyMissing, 'nip'));
|
||||
}
|
||||
|
||||
public function test_kelengkapan_biodata_cakupan_dan_filter(): void
|
||||
{
|
||||
$nips = fn (array $params, ?ReportContext $c = null): array => $this->column($this->report('repp_kelengkapanbiodosen', $params, $c), 'nip');
|
||||
|
||||
$this->assertSame([self::ANDI], $nips(['unit' => 22]));
|
||||
$this->assertSame([self::ANDI], $nips(['aktif' => 'nonaktif']));
|
||||
$this->assertSame([], $nips([], $this->context([])));
|
||||
$this->assertEqualsCanonicalizing(['lina', self::SITI], $nips([], $this->context([21])));
|
||||
// Unit di luar prodi akun diabaikan (kembali ke semua prodi akun).
|
||||
$this->assertEqualsCanonicalizing(['lina', self::SITI], $nips(['unit' => 22], $this->context([21])));
|
||||
}
|
||||
|
||||
public function test_rasio_dosen(): void
|
||||
{
|
||||
$now = $this->report('repp_rasiodosenins');
|
||||
$rows = collect($now->rows)->keyBy('prodi');
|
||||
$pick = fn (string $prodi): array => array_values(array_diff_key($rows[$prodi], ['prodi' => 1]));
|
||||
|
||||
$this->assertSame(['prodi', 'dosen', 'tetap', 'tidaktetap', 'mahasiswa', 'rasio'], $this->keys($now));
|
||||
// Prodi 21: Siti (tetap) dan Lina aktif; mahasiswa aktif 500 sampai 504. Prodi 22: Andi tidak aktif; mahasiswa 510 dan 511.
|
||||
$this->assertSame([2, 1, 0, 5, 2.5], $pick('Teknik Informatika'));
|
||||
$this->assertSame([0, 0, 0, 2, null], $pick('Teknik Sipil'));
|
||||
$this->assertSame([2, 1, 0, 7, 3.5], $pick('Jumlah'));
|
||||
}
|
||||
|
||||
public function test_rasio_dosen_per_periode(): void
|
||||
{
|
||||
$result = $this->report('repp_rasiodosenins', ['periode' => 368]);
|
||||
$rows = collect($result->rows)->keyBy('prodi');
|
||||
|
||||
$this->assertSame('mengajar', $this->keys($result)[6]);
|
||||
// Aktif pada 368: 500 dan 502 (prodi 21), 510 (prodi 22). Pengajar kelas prodi 21: Siti, Joko, Lina.
|
||||
$this->assertSame([2, 1.0, 3], [$rows['Teknik Informatika']['mahasiswa'], $rows['Teknik Informatika']['rasio'], $rows['Teknik Informatika']['mengajar']]);
|
||||
$this->assertSame([1, 1], [$rows['Teknik Sipil']['mahasiswa'], $rows['Teknik Sipil']['mengajar']]);
|
||||
$this->assertStringContainsString('2020/2021 Ganjil', $result->summary[0]);
|
||||
}
|
||||
|
||||
public function test_rasio_dosen_cakupan(): void
|
||||
{
|
||||
$this->assertSame(['Teknik Informatika'], $this->column($this->report('repp_rasiodosenins', ['unit' => 21]), 'prodi'));
|
||||
$this->assertSame([], $this->report('repp_rasiodosenins', [], $this->context([]))->rows);
|
||||
}
|
||||
|
||||
public function test_distribusi_dosen_wali(): void
|
||||
{
|
||||
$result = $this->report('repp_distribusidosenwali', ['unit' => 21]);
|
||||
|
||||
$this->assertSame(['nip', 'dosen', 'homebase', 'jumlah'], $this->keys($result));
|
||||
// Urut nama: Lina (504) lalu Siti (500, 501, 503).
|
||||
$this->assertSame(['lina', self::SITI], $this->column($result, 'nip'));
|
||||
$this->assertSame([1, 3], $this->column($result, 'jumlah'));
|
||||
$this->assertSame('Teknik Informatika', $result->rows[0]['homebase']);
|
||||
$this->assertSame(['Jumlah: 2 dosen wali membimbing 4 mahasiswa aktif', 'Mahasiswa aktif tanpa dosen wali: 1'], $result->summary);
|
||||
|
||||
$this->assertSame([self::ANDI, 'lina', self::SITI], $this->column($this->report('repp_distribusidosenwali'), 'nip'));
|
||||
$this->assertSame([self::SITI], $this->column($this->report('repp_distribusidosenwali', ['dosen' => 'siti']), 'nip'));
|
||||
}
|
||||
|
||||
public function test_distribusi_dosen_wali_angkatan_dan_cakupan(): void
|
||||
{
|
||||
// Angkatan 2019: 500, 501, 503 dibimbing Siti.
|
||||
$this->assertSame([3], $this->column($this->report('repp_distribusidosenwali', ['angkatan' => 2019]), 'jumlah'));
|
||||
$this->assertSame([], $this->report('repp_distribusidosenwali', [], $this->context([]))->rows);
|
||||
$this->assertNotContains(self::ANDI, $this->column($this->report('repp_distribusidosenwali', [], $this->context([21])), 'nip'));
|
||||
}
|
||||
|
||||
public function test_mahasiswa_bimbingan_akademik(): void
|
||||
{
|
||||
$result = $this->report('repp_dpa', ['bimbingan' => 'pa', 'unit' => 21]);
|
||||
|
||||
$this->assertSame(['nip', 'dosen', 'nim', 'mahasiswa', 'angkatan', 'prodi'], $this->keys($result));
|
||||
// Aktif dan ber-PA di prodi 21: Lina (X504), Siti (500, X501, X503). 502 tanpa PA, 505 lulus.
|
||||
$this->assertSame(['X504', 'D1041191001', 'X501', 'X503'], $this->column($result, 'nim'));
|
||||
$this->assertSame(2021, $result->rows[0]['angkatan']);
|
||||
$this->assertSame(4, $result->count());
|
||||
|
||||
$this->assertSame(['X504'], $this->column($this->report('repp_dpa', ['bimbingan' => 'pa', 'dosen' => 'lina']), 'nim'));
|
||||
$this->assertSame([], $this->report('repp_dpa', ['bimbingan' => 'pa'], $this->context([]))->rows);
|
||||
$this->assertNotContains('X510', $this->column($this->report('repp_dpa', ['bimbingan' => 'pa'], $this->context([21])), 'nim'));
|
||||
}
|
||||
|
||||
public function test_mahasiswa_bimbingan_akademik_status_semester(): void
|
||||
{
|
||||
$result = $this->report('repp_dpa', ['bimbingan' => 'pa', 'periode' => 368, 'unit' => 21]);
|
||||
|
||||
$this->assertSame('semester', $this->keys($result)[6]);
|
||||
$this->assertEquals(['D1041191001' => 'Aktif', 'X501' => 'Cuti', 'X503' => null, 'X504' => null], array_column($result->rows, 'semester', 'nim'));
|
||||
}
|
||||
|
||||
public function test_mahasiswa_bimbingan_tugas_akhir(): void
|
||||
{
|
||||
$result = $this->report('repp_dpa', ['bimbingan' => 'ta'], $this->context([21]));
|
||||
|
||||
$this->assertSame(['nip', 'dosen', 'peran', 'nim', 'mahasiswa', 'angkatan', 'prodi', 'judul', 'status'], $this->keys($result));
|
||||
$this->assertSame(
|
||||
[['lina', 'Pembimbing 2', 'D1041191001', 'Belum lulus ujian'], [self::SITI, 'Pembimbing 1', 'D1041191001', 'Belum lulus ujian'], [self::SITI, 'Pembimbing 1', 'X505', 'Lulus ujian 01-09-2020']],
|
||||
array_map(fn (array $r): array => [$r['nip'], $r['peran'], $r['nim'], $r['status']], $result->rows),
|
||||
);
|
||||
$this->assertSame(3, $result->count());
|
||||
|
||||
$this->assertSame(2, $this->report('repp_dpa', ['bimbingan' => 'ta', 'statusta' => 'berjalan'], $this->context([21]))->count());
|
||||
$this->assertSame(['X505'], $this->column($this->report('repp_dpa', ['bimbingan' => 'ta', 'statusta' => 'lulus'], $this->context([21])), 'nim'));
|
||||
$this->assertSame(['X510'], $this->column($this->report('repp_dpa', ['bimbingan' => 'ta', 'unit' => 22]), 'nim'));
|
||||
$this->assertSame([], $this->report('repp_dpa', ['bimbingan' => 'ta'], $this->context([]))->rows);
|
||||
}
|
||||
|
||||
public function test_jurnal_perwalian(): void
|
||||
{
|
||||
$result = $this->report('repp_jurnalperwalian');
|
||||
|
||||
$this->assertSame(['tanggal', 'dosen', 'nim', 'mahasiswa', 'angkatan', 'pesan'], $this->keys($result));
|
||||
// Pesan terhapus lunak tidak ikut; terbaru lebih dulu.
|
||||
$this->assertSame(['Prodi lain', 'Segera isi KRS', 'Konsultasi judul'], $this->column($result, 'pesan'));
|
||||
$this->assertSame(['10-09-2020 10:30', 2019], [$result->rows[1]['tanggal'], $result->rows[1]['angkatan']]);
|
||||
$this->assertSame(3, $result->count());
|
||||
}
|
||||
|
||||
public function test_jurnal_perwalian_filter_dan_cakupan(): void
|
||||
{
|
||||
$pesan = fn (array $params, ?ReportContext $c = null): array => $this->column($this->report('repp_jurnalperwalian', $params, $c), 'pesan');
|
||||
|
||||
$this->assertSame(['Prodi lain', 'Segera isi KRS'], $pesan(['periode' => 368]));
|
||||
$this->assertSame(['Segera isi KRS'], $pesan(['periode' => 368, 'unit' => 21]));
|
||||
$this->assertSame(['Konsultasi judul'], $pesan(['mahasiswa' => 'X501']));
|
||||
$this->assertSame(['Prodi lain'], $pesan(['dosen' => 'andi']));
|
||||
$this->assertSame(['Segera isi KRS', 'Konsultasi judul'], $pesan(['angkatan' => 2019]));
|
||||
$this->assertSame(['Segera isi KRS', 'Konsultasi judul'], $pesan([], $this->context([21])));
|
||||
$this->assertSame([], $pesan([], $this->context([])));
|
||||
}
|
||||
|
||||
public function test_distribusi_pengajar_home_base(): void
|
||||
{
|
||||
// Pengajar kelas prodi 21 pada 368: Siti (601 + 603 = 5 SKS), Joko (601 = 3 SKS), Lina (604 = 2 SKS).
|
||||
$result = $this->report('repp_distribusipengajar', ['periode' => 368, 'unit' => 21, 'kelompok' => 'homebase']);
|
||||
|
||||
$this->assertSame(['kelompok', 'dosen', 'persen', 'kelas', 'sks'], $this->keys($result));
|
||||
$this->assertSame('Home base', $result->columns[0]['label']);
|
||||
$rows = collect($result->rows)->keyBy('kelompok');
|
||||
$pick = fn (string $group): array => array_values(array_diff_key($rows[$group], ['kelompok' => 1]));
|
||||
$this->assertSame([2, 66.7, 3, 7], $pick('Teknik Informatika'));
|
||||
// Joko ber-home base prodi 99 yang tidak ada di t_bagian.
|
||||
$this->assertSame([1, 33.3, 1, 3], $pick('Tanpa home base'));
|
||||
$this->assertSame('Teknik Informatika', $result->rows[0]['kelompok']);
|
||||
$this->assertSame(['Periode: 2020/2021 Ganjil', 'Jumlah: 3 dosen pengajar'], $result->summary);
|
||||
$this->assertSame(2, $result->count());
|
||||
}
|
||||
|
||||
public function test_distribusi_pengajar_kelompok_lain(): void
|
||||
{
|
||||
$group = fn (string $kelompok, array $extra = []): array => collect($this->report('repp_distribusipengajar', ['periode' => 368, 'kelompok' => $kelompok] + $extra)->rows)->pluck('dosen', 'kelompok')->all();
|
||||
|
||||
$this->assertEquals(['Tetap' => 2, 'Tanpa status' => 1, 'Tidak Tetap' => 1], $group('status'));
|
||||
$this->assertEquals(['Lektor' => 1, 'Asisten Ahli' => 1, 'Belum diisi' => 1], $group('jabfung', ['unit' => 21]));
|
||||
$this->assertEquals(['Magister / S2' => 1, 'Belum diisi' => 2], $group('pendidikan', ['unit' => 21]));
|
||||
$this->assertEquals(['Penata Muda' => 1, 'Pembina' => 1, 'Belum diisi' => 1], $group('pangkat', ['unit' => 21]));
|
||||
}
|
||||
|
||||
public function test_distribusi_pengajar_cakupan(): void
|
||||
{
|
||||
$this->assertSame([], $this->report('repp_distribusipengajar', ['periode' => 368], $this->context([]))->rows);
|
||||
$this->assertSame(1, array_sum($this->column($this->report('repp_distribusipengajar', ['periode' => 368, 'unit' => 21, 'dosen' => 'lina']), 'dosen')));
|
||||
$this->assertSame(1, array_sum($this->column($this->report('repp_distribusipengajar', ['periode' => 368, 'unit' => 22], $this->context([22])), 'dosen')));
|
||||
// Prodi 22 tidak dimiliki akun: hanya dosen prodi 21 yang terhitung.
|
||||
$this->assertSame(3, array_sum($this->column($this->report('repp_distribusipengajar', ['periode' => 368], $this->context([21])), 'dosen')));
|
||||
}
|
||||
|
||||
public function test_rekap_presensi_dosen(): void
|
||||
{
|
||||
$result = $this->report('repp_rekapabsendosen', ['periode' => 368, 'prodi' => 21]);
|
||||
|
||||
$this->assertSame(['nip', 'dosen', 'kode', 'mk', 'kelas', 'rencana', 'realisasi', 'persen'], $this->keys($result));
|
||||
// Kelas 601 (Siti 14 dari 16, Joko 16 dari 16) dan 603 (0 dari 0); 604 belum dilaporkan; 602 milik prodi lain.
|
||||
$this->assertSame(3, $result->count());
|
||||
$siti = collect($result->rows)->firstWhere('realisasi', 14);
|
||||
$this->assertSame([16, 87.5, 'MK601'], [$siti['rencana'], $siti['persen'], $siti['kode']]);
|
||||
$this->assertNull(collect($result->rows)->firstWhere('kode', 'MK603')['persen']);
|
||||
$this->assertSame(['Periode: 2020/2021 Ganjil', 'Program studi: Teknik Informatika', 'Jumlah: 3 penugasan (rencana 32 tatap muka, realisasi 30)'], $result->summary);
|
||||
$this->assertNull($result->note);
|
||||
}
|
||||
|
||||
public function test_rekap_presensi_dosen_filter_dan_cakupan(): void
|
||||
{
|
||||
$this->assertCount(2, $this->report('repp_rekapabsendosen', ['periode' => 368, 'prodi' => 21, 'kelas' => 'MK601'])->rows);
|
||||
$this->assertCount(1, $this->report('repp_rekapabsendosen', ['periode' => 368, 'prodi' => 21, 'dosen' => 'siti', 'kelas' => 'MK601'])->rows);
|
||||
$this->assertSame([], $this->report('repp_rekapabsendosen', ['periode' => 368, 'prodi' => 22], $this->context([21]))->rows);
|
||||
$this->assertSame([], $this->report('repp_rekapabsendosen', ['periode' => 368, 'prodi' => 21], $this->context([]))->rows);
|
||||
|
||||
$kosong = $this->report('repp_rekapabsendosen', ['periode' => 371, 'prodi' => 21]);
|
||||
$this->assertSame([], $kosong->rows);
|
||||
$this->assertStringContainsString('terakhir tercatat pada periode 2020/2021 Ganjil', (string) $kosong->note);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,474 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Operator\Reports;
|
||||
|
||||
use App\Support\Legacy\Reports\KelasReports;
|
||||
use App\Support\Legacy\Reports\ReportContext;
|
||||
use App\Support\Legacy\Reports\ReportResult;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Tests\Concerns\FakesLegacyDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Laporan kelas (presensi, jadwal, ujian, nilai, kunci nilai, kapasitas).
|
||||
*
|
||||
* Periode 900 (2020/2021 Ganjil). Prodi 21 punya kelas 7001 (IF101 A, dikunci, 16 pertemuan, dosen Siti, 2 sesi
|
||||
* mingguan, UTS + UAS) dan 7002 (IF102 B, belum dikunci, 14 pertemuan, tanpa jadwal); prodi 22 punya kelas 7003.
|
||||
* Peserta 7001: N710 (hadir 16, nilai A) dan N711 (hadir 8, nilai E, KRS stat 3); N712 batal. 7002: N710 (presensi
|
||||
* dan nilai kosong) dan N711 (KRS menunggu, tidak dihitung). 7003: N712 (prodi 22).
|
||||
*/
|
||||
class KelasReportsTest extends TestCase
|
||||
{
|
||||
use FakesLegacyDatabase;
|
||||
use RefreshDatabase;
|
||||
|
||||
private KelasReports $reports;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->useLegacyDatabase();
|
||||
$this->seedClassData();
|
||||
$this->reports = new KelasReports;
|
||||
}
|
||||
|
||||
private function seedClassData(): void
|
||||
{
|
||||
$schema = Schema::connection('untan');
|
||||
$addColumns = function (string $table, array $columns) use ($schema): void {
|
||||
foreach ($columns as $name => $type) {
|
||||
if (! $schema->hasColumn($table, $name)) {
|
||||
$schema->table($table, fn (Blueprint $t) => $t->{$type}($name)->nullable());
|
||||
}
|
||||
}
|
||||
};
|
||||
$addColumns('t_jadwal', ['jmlpertemuan' => 'smallInteger', 'tglpubnilai' => 'dateTime']);
|
||||
$addColumns('t_kst', ['absen' => 'double', 'tugas' => 'double', 'uts' => 'double', 'uas' => 'double']);
|
||||
|
||||
$db = DB::connection('untan');
|
||||
$db->table('t_bagian')->insert(['idbagian' => 22, 'idbagian_induk' => 5, 'idjenisbagian' => 3, 'namabagian' => 'Teknik Sipil']);
|
||||
$db->table('t_periodekuliah')->insert(['idperiode' => 900, 'thakad' => '2020/2021', 'semester' => 1, 'perkuliahan' => 1]);
|
||||
$db->table('t_periodekuliahaktif')->insert(['idprogdi' => 21, 'idperiode' => 900]);
|
||||
$db->table('t_angkatanmhs')->insert([['idangkatan' => 710, 'tahun' => 2019, 'semester' => 1], ['idangkatan' => 711, 'tahun' => 2020, 'semester' => 1]]);
|
||||
$db->table('t_jenisprogram')->insert(['idprogram' => 1, 'program' => 'Reguler A']);
|
||||
$db->table('t_kurikulum')->insert(['idkurikulum' => 700, 'idprogdi' => 21, 'idprogram' => 1, 'idperiode' => 900, 'namakurikulum' => 'Kurikulum 2020']);
|
||||
$db->table('t_matakuliah')->insert([
|
||||
['idmatakuliah' => 701, 'idkurikulum' => 700, 'kodemk' => 'IF101', 'namamk' => 'Algoritma', 'sks' => 3, 'semester' => 1, 'nilailulus' => 2],
|
||||
['idmatakuliah' => 702, 'idkurikulum' => 700, 'kodemk' => 'IF102', 'namamk' => 'Basis Data', 'sks' => 2, 'semester' => 2, 'nilailulus' => 2],
|
||||
['idmatakuliah' => 703, 'idkurikulum' => null, 'kodemk' => 'TS101', 'namamk' => 'Statika', 'sks' => 3, 'semester' => 1, 'nilailulus' => 2],
|
||||
]);
|
||||
$db->table('t_jadwal')->insert([
|
||||
['idjadwal' => 7001, 'idmatakuliah' => 701, 'idperiode' => 900, 'idprogdi' => 21, 'kelas' => 'A', 'kapasitas' => 30, 'jmlpertemuan' => 16, 'flag_cetak' => true, 'tglpubnilai' => '2021-01-20 10:00:00'],
|
||||
['idjadwal' => 7002, 'idmatakuliah' => 702, 'idperiode' => 900, 'idprogdi' => 21, 'kelas' => 'B', 'kapasitas' => 2, 'jmlpertemuan' => 14, 'flag_cetak' => false, 'tglpubnilai' => null],
|
||||
['idjadwal' => 7003, 'idmatakuliah' => 703, 'idperiode' => 900, 'idprogdi' => 22, 'kelas' => 'A', 'kapasitas' => 0, 'jmlpertemuan' => 16, 'flag_cetak' => false, 'tglpubnilai' => null],
|
||||
]);
|
||||
$db->table('t_jadwaldosen')->insert([
|
||||
['idjadwal' => 7001, 'iddosen' => 11, 'dosenke' => 1],
|
||||
['idjadwal' => 7002, 'iddosen' => 10, 'dosenke' => 1],
|
||||
['idjadwal' => 7003, 'iddosen' => 14, 'dosenke' => 1],
|
||||
]);
|
||||
$db->table('t_mahasiswa')->insert([
|
||||
['idmahasiswa' => 710, 'nim' => 'N710', 'nama' => 'Andi Budi', 'idprogdi' => 21, 'idangkatan' => 710, 'idprogram' => 1, 'hp' => '0812000'],
|
||||
['idmahasiswa' => 711, 'nim' => 'N711', 'nama' => 'Citra Dewi', 'idprogdi' => 21, 'idangkatan' => 711, 'idprogram' => 1, 'hp' => null],
|
||||
['idmahasiswa' => 712, 'nim' => 'N712', 'nama' => 'Dedi Sipil', 'idprogdi' => 22, 'idangkatan' => 711, 'idprogram' => 1, 'hp' => null],
|
||||
]);
|
||||
$kst = fn (int $mhs, int $jadwal, int $mk, int $stat, array $extra = []): array => $extra + [
|
||||
'idmahasiswa' => $mhs, 'idjadwal' => $jadwal, 'idmatakuliah' => $mk, 'idperiode' => 900, 'stat' => $stat,
|
||||
'absen' => null, 'tugas' => null, 'uts' => null, 'uas' => null, 'nilaitotal' => null, 'nilaimutu' => null, 'nilaihuruf' => null,
|
||||
];
|
||||
$db->table('t_kst')->insert([
|
||||
$kst(710, 7001, 701, 1, ['absen' => 16, 'tugas' => 80, 'uts' => 70, 'uas' => 90, 'nilaitotal' => 80, 'nilaimutu' => 4, 'nilaihuruf' => 'A']),
|
||||
$kst(711, 7001, 701, 3, ['absen' => 8, 'tugas' => 60, 'uts' => 50, 'uas' => 40, 'nilaitotal' => 49, 'nilaimutu' => 0, 'nilaihuruf' => 'E']),
|
||||
$kst(712, 7001, 701, 2),
|
||||
$kst(710, 7002, 702, 1),
|
||||
$kst(711, 7002, 702, 0),
|
||||
$kst(712, 7003, 703, 1, ['absen' => 10, 'nilaitotal' => 70, 'nilaimutu' => 3, 'nilaihuruf' => 'B']),
|
||||
]);
|
||||
|
||||
// Jadwal mingguan 7001: Senin di R1, Rabu tanpa ruang. Ujian 7001: UTS dan UAS; 7003: UTS.
|
||||
$senin = $db->table('t_jadwaltemu')->insertGetId(['idjadwal' => 7001, 'hari' => 1, 'mulai' => '07:30:00', 'selesai' => '09:10:00']);
|
||||
$db->table('t_jadwaltemu')->insert(['idjadwal' => 7001, 'hari' => 3, 'mulai' => '10:00:00', 'selesai' => '11:40:00']);
|
||||
$db->table('t_jadwaltemu')->insert(['idjadwal' => 7003, 'hari' => 2, 'mulai' => '08:00:00', 'selesai' => '09:40:00']);
|
||||
$db->table('t_ruang')->insert([['idruang' => 701, 'namaruang' => 'R1'], ['idruang' => 702, 'namaruang' => 'Ruang Ujian 1']]);
|
||||
$db->table('t_jadwalruangkuliah')->insert(['idjadwaltemu' => $senin, 'idruang' => 701]);
|
||||
$db->table('t_jadwalujian')->insert([
|
||||
['idjadwalujian' => 701, 'idjadwal' => 7001, 'jenis' => 1, 'tanggalujian' => '2020-10-20', 'mulai' => '08:00:00', 'selesai' => '09:40:00'],
|
||||
['idjadwalujian' => 702, 'idjadwal' => 7001, 'jenis' => 2, 'tanggalujian' => '2021-01-10', 'mulai' => '13:00:00', 'selesai' => '14:40:00'],
|
||||
['idjadwalujian' => 703, 'idjadwal' => 7003, 'jenis' => 1, 'tanggalujian' => '2020-10-21', 'mulai' => '08:00:00', 'selesai' => '09:40:00'],
|
||||
]);
|
||||
$db->table('t_jadwalruangujian')->insert([['idjadwalujian' => 701, 'idruang' => 702], ['idjadwalujian' => 703, 'idruang' => 702]]);
|
||||
$db->table('t_periodenilai')->insert(['idperiode' => 900, 'idprogdi' => 21, 'mulai' => '2020-12-01', 'akhir' => '2021-01-15']);
|
||||
$db->table('t_histori_mahasiswa')->insert(['idmahasiswa' => 710, 'idperiode' => 900, 'stat_akd_akhir' => 1, 'ips' => 3.5]);
|
||||
}
|
||||
|
||||
/** @param list<int>|null $prodi */
|
||||
private function context(?array $prodi = null): ReportContext
|
||||
{
|
||||
$prodi ??= [21];
|
||||
$names = [21 => 'Teknik Informatika', 22 => 'Teknik Sipil'];
|
||||
|
||||
return new ReportContext(1, 'staf', $prodi, array_intersect_key($names, array_flip($prodi)));
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $params */
|
||||
private function report(string $slug, array $params = [], ?array $prodi = null, int $limit = 100): ReportResult
|
||||
{
|
||||
return $this->reports->run($slug, $params + ['periode' => 900], $this->context($prodi), $limit);
|
||||
}
|
||||
|
||||
/** @return list<string> */
|
||||
private function keys(ReportResult $result): array
|
||||
{
|
||||
return array_column($result->columns, 'key');
|
||||
}
|
||||
|
||||
/** @return list<mixed> */
|
||||
private function column(ReportResult $result, string $key): array
|
||||
{
|
||||
return array_column($result->rows, $key);
|
||||
}
|
||||
|
||||
public function test_slugs_hanya_laporan_yang_punya_sumber(): void
|
||||
{
|
||||
$slugs = $this->reports->slugs();
|
||||
|
||||
$this->assertCount(16, $slugs);
|
||||
$this->assertSame(array_unique($slugs), $slugs);
|
||||
// Jurnal perkuliahan per pertemuan dan penanda cekal ujian tidak punya sumber di DB lama.
|
||||
$this->assertNotContains('repp_perkuliahan', $slugs);
|
||||
$this->assertNotContains('repp_cekalujian', $slugs);
|
||||
}
|
||||
|
||||
public function test_definisi_parameter_valid_untuk_setiap_slug(): void
|
||||
{
|
||||
foreach ($this->reports->slugs() as $slug) {
|
||||
$definition = $this->reports->definition($slug, $this->context());
|
||||
$names = array_column($definition['params'], 'name');
|
||||
|
||||
$this->assertNotEmpty($names, $slug);
|
||||
$this->assertSame(array_unique($names), $names, "{$slug}: nama parameter harus unik");
|
||||
$this->assertEmpty(array_intersect($names, ['tampil', 'kop']), $slug);
|
||||
foreach ($definition['params'] as $param) {
|
||||
$this->assertContains($param['type'], ['select', 'text', 'number', 'date', 'check'], $slug);
|
||||
if ($param['type'] === 'select') {
|
||||
$this->assertIsArray($param['options'], "{$slug}.{$param['name']}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function test_parameter_wajib_dan_opsi_dari_db(): void
|
||||
{
|
||||
$params = collect($this->reports->definition('repp_jadwalkuliah', $this->context())['params'])->keyBy('name');
|
||||
|
||||
$this->assertTrue($params['periode']['required']);
|
||||
$this->assertSame('2020/2021 Ganjil', $params['periode']['options'][900]);
|
||||
$this->assertSame(900, $params['periode']['default']);
|
||||
$this->assertSame([21 => 'Teknik Informatika'], $params['prodi']['options']);
|
||||
$this->assertSame([2020 => '2020', 2019 => '2019'], $params['angkatan']['options']);
|
||||
$this->assertSame([1 => 'Reguler A'], $params['program']['options']);
|
||||
|
||||
$monitoring = collect($this->reports->definition('repp_monitoringkelas', $this->context())['params'])->keyBy('name');
|
||||
$this->assertSame('2020', $monitoring['kurikulum']['options']['2020']);
|
||||
|
||||
$mk = collect($this->reports->definition('repp_nilaimk', $this->context())['params'])->keyBy('name');
|
||||
$this->assertTrue($mk['mk']['required']);
|
||||
$this->assertFalse($mk['periode']['required']);
|
||||
}
|
||||
|
||||
public function test_daftar_hadir_hanya_peserta_disetujui_prodi_akun(): void
|
||||
{
|
||||
$result = $this->report('repp_absensi');
|
||||
|
||||
$this->assertSame(['kode', 'mk', 'kelas', 'dosen', 'nim', 'nama', 'angkatan'], $this->keys($result));
|
||||
$this->assertSame(['N710', 'N711', 'N710'], $this->column($result, 'nim'));
|
||||
$this->assertSame(['IF101', 'IF101', 'IF102'], $this->column($result, 'kode'));
|
||||
$this->assertSame('Siti Aminah, M.Pd.', $result->rows[0]['dosen']);
|
||||
$this->assertSame([2019, 2020, 2019], $this->column($result, 'angkatan'));
|
||||
$this->assertContains('Periode: 2020/2021 Ganjil', $result->summary);
|
||||
$this->assertContains('Jumlah: 3 peserta', $result->summary);
|
||||
|
||||
$this->assertSame(['N712'], $this->column($this->report('repp_absensi', [], [22]), 'nim'));
|
||||
$this->assertSame(['IF101', 'IF101'], $this->column($this->report('repp_absensi', ['kelas' => 'algoritma']), 'kode'));
|
||||
$this->assertSame(['IF102'], $this->column($this->report('repp_absensi', ['dosen' => 'budi']), 'kode'));
|
||||
}
|
||||
|
||||
public function test_rekap_presensi_per_mahasiswa(): void
|
||||
{
|
||||
$result = $this->report('repp_rekapabsenmhs');
|
||||
|
||||
$this->assertSame(['N710', 'N711'], $this->column($result, 'nim'));
|
||||
$this->assertEquals(['mk' => 2, 'mk_terisi' => 1, 'pertemuan' => 16, 'hadir' => 16, 'persen' => 100.0], array_intersect_key($result->rows[0], array_flip(['mk', 'mk_terisi', 'pertemuan', 'hadir', 'persen'])));
|
||||
$this->assertEquals(['mk' => 1, 'mk_terisi' => 1, 'pertemuan' => 16, 'hadir' => 8, 'persen' => 50.0], array_intersect_key($result->rows[1], array_flip(['mk', 'mk_terisi', 'pertemuan', 'hadir', 'persen'])));
|
||||
$this->assertSame(['N712'], $this->column($this->report('repp_rekapabsenmhs', [], [22]), 'nim'));
|
||||
$this->assertSame(['N711'], $this->column($this->report('repp_rekapabsenmhs', ['mahasiswa' => 'citra']), 'nim'));
|
||||
}
|
||||
|
||||
public function test_monitoring_presensi_dan_filter_tidak_masuk(): void
|
||||
{
|
||||
$all = $this->report('repp_absensimhs');
|
||||
$this->assertSame(['kode', 'mk', 'kelas', 'dosen', 'nim', 'nama', 'pertemuan', 'hadir', 'tidak_masuk'], $this->keys($all));
|
||||
$this->assertCount(3, $all->rows);
|
||||
|
||||
$absent = $this->report('repp_absensimhs', ['tidakmasuk_min' => 8]);
|
||||
$this->assertCount(1, $absent->rows);
|
||||
$this->assertEquals(['nim' => 'N711', 'pertemuan' => 16, 'hadir' => 8, 'tidak_masuk' => 8], array_intersect_key($absent->rows[0], array_flip(['nim', 'pertemuan', 'hadir', 'tidak_masuk'])));
|
||||
|
||||
$empty = $this->rowFor($all, 'N710', 'IF102');
|
||||
$this->assertNull($empty['hadir']);
|
||||
$this->assertNull($empty['tidak_masuk']);
|
||||
$this->assertSame(14, $empty['pertemuan']);
|
||||
}
|
||||
|
||||
public function test_persentase_presensi_urut_terendah_dan_kontak(): void
|
||||
{
|
||||
$result = $this->report('repp_prosentaseabs', ['kontak' => true]);
|
||||
|
||||
$this->assertContains('persen', $this->keys($result));
|
||||
$this->assertContains('hp', $this->keys($result));
|
||||
$this->assertSame(['N711', 'N710', 'N710'], $this->column($result, 'nim'));
|
||||
$this->assertEquals([50.0, 100.0, null], $this->column($result, 'persen'));
|
||||
$this->assertSame('0812000', $result->rows[1]['hp']);
|
||||
|
||||
$this->assertNotContains('hp', $this->keys($this->report('repp_prosentaseabs')));
|
||||
$range = $this->report('repp_prosentaseabs', ['tidakmasuk_min' => 1, 'tidakmasuk_max' => 8]);
|
||||
$this->assertSame(['N711'], $this->column($range, 'nim'));
|
||||
}
|
||||
|
||||
public function test_status_pengisian_presensi(): void
|
||||
{
|
||||
$result = $this->report('repp_isiabsensi');
|
||||
|
||||
$this->assertSame(['IF101', 'IF102'], $this->column($result, 'kode'));
|
||||
$this->assertEquals([2, 2, 0], [$result->rows[0]['peserta'], $result->rows[0]['terisi'], $result->rows[0]['belum']]);
|
||||
$this->assertSame('Lengkap', $result->rows[0]['status']);
|
||||
$this->assertEquals([1, 0, 1, 14], [$result->rows[1]['peserta'], $result->rows[1]['terisi'], $result->rows[1]['belum'], $result->rows[1]['pertemuan']]);
|
||||
$this->assertSame('Belum diisi', $result->rows[1]['status']);
|
||||
$this->assertSame(['TS101'], $this->column($this->report('repp_isiabsensi', [], [22]), 'kode'));
|
||||
}
|
||||
|
||||
public function test_jadwal_kuliah_mahasiswa(): void
|
||||
{
|
||||
$result = $this->report('repp_jadwalkuliah');
|
||||
|
||||
$this->assertCount(5, $result->rows);
|
||||
$this->assertEqualsCanonicalizing(['N710', 'N710', 'N710', 'N711', 'N711'], $this->column($result, 'nim'));
|
||||
$monday = collect($result->rows)->firstWhere('hari', 'Senin');
|
||||
$this->assertSame('07.30 – 09.10', $monday['jam']);
|
||||
$this->assertSame('R1', $monday['ruang']);
|
||||
$this->assertSame('Siti Aminah, M.Pd.', $monday['dosen']);
|
||||
$wednesday = collect($result->rows)->firstWhere('hari', 'Rabu');
|
||||
$this->assertNull($wednesday['ruang']);
|
||||
$noSchedule = collect($result->rows)->firstWhere('kode', 'IF102');
|
||||
$this->assertNull($noSchedule['hari']);
|
||||
|
||||
$this->assertCount(2, $this->report('repp_jadwalkuliah', ['angkatan' => 2020, 'mahasiswa' => 'N711'])->rows);
|
||||
$this->assertCount(0, $this->report('repp_jadwalkuliah', ['angkatan' => 2020, 'mahasiswa' => 'N710'])->rows);
|
||||
$this->assertCount(5, $this->report('repp_jadwalkuliah', ['program' => 1])->rows);
|
||||
$this->assertSame(['N712'], array_unique($this->column($this->report('repp_jadwalkuliah', [], [22]), 'nim')));
|
||||
}
|
||||
|
||||
public function test_jadwal_mingguan_prodi(): void
|
||||
{
|
||||
$result = $this->report('repp_jadwalmingguanprodi');
|
||||
|
||||
$this->assertSame(['Senin', 'Rabu'], $this->column($result, 'hari'));
|
||||
$this->assertSame(['R1', null], $this->column($result, 'ruang'));
|
||||
$this->assertSame('Siti Aminah, M.Pd.', $result->rows[0]['dosen']);
|
||||
$this->assertSame('Teknik Informatika', $result->rows[0]['prodi']);
|
||||
$this->assertSame(['Selasa'], $this->column($this->report('repp_jadwalmingguanprodi', [], [22]), 'hari'));
|
||||
$this->assertCount(2, $this->report('repp_jadwalmingguanprodi', ['semester' => 1, 'kurikulum' => '2020'])->rows);
|
||||
$this->assertCount(0, $this->report('repp_jadwalmingguanprodi', ['semester' => 2])->rows);
|
||||
$this->assertCount(0, $this->report('repp_jadwalmingguanprodi', ['dosen' => 'tidak ada'])->rows);
|
||||
}
|
||||
|
||||
public function test_berita_acara_ujian_dengan_ruang_dan_peserta(): void
|
||||
{
|
||||
$result = $this->report('repp_absensiujian');
|
||||
|
||||
$this->assertSame(['UTS', 'UAS'], $this->column($result, 'jenis'));
|
||||
$this->assertSame(['20-10-2020', '10-01-2021'], $this->column($result, 'tanggal'));
|
||||
$this->assertSame('08.00 – 09.40', $result->rows[0]['jam']);
|
||||
$this->assertSame('Ruang Ujian 1', $result->rows[0]['ruang']);
|
||||
$this->assertNull($result->rows[1]['ruang']);
|
||||
$this->assertSame([2, 2], $this->column($result, 'peserta'));
|
||||
$this->assertSame(['UAS'], $this->column($this->report('repp_absensiujian', ['jenis' => 2]), 'jenis'));
|
||||
$this->assertSame(['10-01-2021'], $this->column($this->report('repp_absensiujian', ['tanggal' => '2021-01-10']), 'tanggal'));
|
||||
$this->assertSame(['21-10-2020'], $this->column($this->report('repp_absensiujian', [], [22]), 'tanggal'));
|
||||
}
|
||||
|
||||
public function test_kartu_ujian_per_mahasiswa(): void
|
||||
{
|
||||
$result = $this->report('repp_kartuujian');
|
||||
|
||||
$this->assertCount(4, $result->rows);
|
||||
$this->assertSame(['N710', 'N710', 'N711', 'N711'], $this->column($result, 'nim'));
|
||||
$this->assertSame(['UTS', 'UAS', 'UTS', 'UAS'], $this->column($result, 'jenis'));
|
||||
$this->assertSame('Ruang Ujian 1', $result->rows[0]['ruang']);
|
||||
$this->assertSame(['N711', 'N711'], $this->column($this->report('repp_kartuujian', ['angkatan' => 2020]), 'nim'));
|
||||
$this->assertSame(['UAS', 'UAS'], $this->column($this->report('repp_kartuujian', ['jenis' => 2]), 'jenis'));
|
||||
$this->assertSame(['N712'], $this->column($this->report('repp_kartuujian', [], [22]), 'nim'));
|
||||
}
|
||||
|
||||
public function test_nilai_perkuliahan_dan_filter_status(): void
|
||||
{
|
||||
$result = $this->report('repp_nilaikuliah');
|
||||
|
||||
$this->assertCount(3, $result->rows);
|
||||
$first = $this->rowFor($result, 'N710', 'IF101');
|
||||
$this->assertEquals(['huruf' => 'A', 'total' => 80.0, 'bobot' => 4.0, 'lulus' => 'Lulus', 'kunci' => 'Dikunci', 'uts' => 70.0], array_intersect_key($first, array_flip(['huruf', 'total', 'bobot', 'lulus', 'kunci', 'uts'])));
|
||||
$this->assertSame('Tidak lulus', $this->rowFor($result, 'N711', 'IF101')['lulus']);
|
||||
$blank = $this->rowFor($result, 'N710', 'IF102');
|
||||
$this->assertNull($blank['huruf']);
|
||||
$this->assertNull($blank['lulus']);
|
||||
$this->assertSame('Belum dikunci', $blank['kunci']);
|
||||
|
||||
$this->assertSame(['IF102'], $this->column($this->report('repp_nilaikuliah', ['status_nilai' => 'belum']), 'kode'));
|
||||
$this->assertSame(['N711'], $this->column($this->report('repp_nilaikuliah', ['status_lulus' => 'tidak']), 'nim'));
|
||||
$this->assertSame(['N710'], $this->column($this->report('repp_nilaikuliah', ['status_lulus' => 'lulus']), 'nim'));
|
||||
$this->assertSame(['N712'], $this->column($this->report('repp_nilaikuliah', [], [22]), 'nim'));
|
||||
}
|
||||
|
||||
public function test_distribusi_nilai_per_kelas(): void
|
||||
{
|
||||
$result = $this->report('repp_distribusinilai');
|
||||
|
||||
$this->assertSame(['IF101', 'IF102'], $this->column($result, 'kode'));
|
||||
$this->assertEquals([2, 2, 1, 1, 0, 0], [$result->rows[0]['peserta'], $result->rows[0]['terisi'], $result->rows[0]['g_a'], $result->rows[0]['g_e'], $result->rows[0]['g_b'], $result->rows[0]['lain']]);
|
||||
$this->assertEquals([1, 0], [$result->rows[1]['peserta'], $result->rows[1]['terisi']]);
|
||||
|
||||
$this->assertSame(['IF101'], $this->column($this->report('repp_distribusinilai', ['nilai_terisi' => 'lengkap']), 'kode'));
|
||||
$this->assertSame(['IF102'], $this->column($this->report('repp_distribusinilai', ['nilai_terisi' => 'kosong']), 'kode'));
|
||||
$this->assertSame([], $this->column($this->report('repp_distribusinilai', ['nilai_terisi' => 'sebagian']), 'kode'));
|
||||
$this->assertSame(['IF101'], $this->column($this->report('repp_distribusinilai', ['kunci' => 'sudah']), 'kode'));
|
||||
$this->assertSame(['IF102'], $this->column($this->report('repp_distribusinilai', ['kunci' => 'belum']), 'kode'));
|
||||
$this->assertSame(['TS101'], $this->column($this->report('repp_distribusinilai', [], [22]), 'kode'));
|
||||
}
|
||||
|
||||
public function test_laporan_nilai_mahasiswa(): void
|
||||
{
|
||||
$result = $this->report('repp_nilaimhs');
|
||||
|
||||
$this->assertSame(['N710', 'N711'], $this->column($result, 'nim'));
|
||||
$this->assertEquals(['mk' => 2, 'sks' => 5, 'mk_nilai' => 1, 'ips' => 3.5, 'angkatan' => 2019], array_intersect_key($result->rows[0], array_flip(['mk', 'sks', 'mk_nilai', 'ips', 'angkatan'])));
|
||||
$this->assertEquals(['mk' => 1, 'sks' => 3, 'mk_nilai' => 1, 'ips' => null], array_intersect_key($result->rows[1], array_flip(['mk', 'sks', 'mk_nilai', 'ips'])));
|
||||
$this->assertSame(['N710'], $this->column($this->report('repp_nilaimhs', ['kelas' => 'basis']), 'nim'));
|
||||
$this->assertSame(['N710', 'N711'], $this->column($this->report('repp_nilaimhs', ['program' => 1]), 'nim'));
|
||||
$this->assertSame(['N712'], $this->column($this->report('repp_nilaimhs', [], [22]), 'nim'));
|
||||
}
|
||||
|
||||
public function test_nilai_mata_kuliah_per_periode(): void
|
||||
{
|
||||
$result = $this->report('repp_nilaimk', ['mk' => 'if101', 'periode' => null]);
|
||||
|
||||
$this->assertCount(1, $result->rows);
|
||||
$row = $result->rows[0];
|
||||
$this->assertSame('2020/2021 Ganjil', $row['periode']);
|
||||
$this->assertEquals(['peserta' => 2, 'terisi' => 2, 'rata' => 64.5, 'min' => 49.0, 'max' => 80.0, 'kunci' => 'Dikunci'], array_intersect_key($row, array_flip(['peserta', 'terisi', 'rata', 'min', 'max', 'kunci'])));
|
||||
|
||||
$noGrades = $this->report('repp_nilaimk', ['mk' => 'basis data']);
|
||||
$this->assertEquals([1, 0, null], [$noGrades->rows[0]['peserta'], $noGrades->rows[0]['terisi'], $noGrades->rows[0]['rata']]);
|
||||
$this->assertSame(['TS101'], $this->column($this->report('repp_nilaimk', ['mk' => 'statika'], [21, 22]), 'kode'));
|
||||
$this->assertSame([], $this->report('repp_nilaimk', ['mk' => 'statika'])->rows);
|
||||
$this->assertSame([], $this->report('repp_nilaimk', ['mk' => null])->rows);
|
||||
$this->assertSame([], $this->report('repp_nilaimk', ['mk' => 'if', 'dosen' => 'tidak ada'])->rows);
|
||||
}
|
||||
|
||||
public function test_kunci_nilai_dengan_masa_pengisian(): void
|
||||
{
|
||||
$result = $this->report('repp_kuncinilai');
|
||||
|
||||
$this->assertSame(['Dikunci', 'Belum dikunci'], $this->column($result, 'kunci'));
|
||||
$this->assertSame('20-01-2021', $result->rows[0]['terbit']);
|
||||
$this->assertSame('01-12-2020', $result->rows[0]['mulai']);
|
||||
$this->assertSame('15-01-2021', $result->rows[0]['akhir']);
|
||||
$this->assertNull($result->rows[1]['terbit']);
|
||||
$this->assertEquals([2, 2], [$result->rows[0]['peserta'], $result->rows[0]['terisi']]);
|
||||
$this->assertContains('Jumlah: 2 kelas (1 dikunci, 1 belum)', $result->summary);
|
||||
$this->assertSame(['IF102'], $this->column($this->report('repp_kuncinilai', ['kunci' => 'belum']), 'kode'));
|
||||
$this->assertSame(['IF101'], $this->column($this->report('repp_kuncinilai', ['kunci' => 'sudah']), 'kode'));
|
||||
}
|
||||
|
||||
public function test_monitoring_kelas(): void
|
||||
{
|
||||
$result = $this->report('repp_monitoringkelas');
|
||||
|
||||
$this->assertSame(['IF101', 'IF102'], $this->column($result, 'kode'));
|
||||
$this->assertEquals(['peserta' => 2, 'jadwal' => 2, 'ujian' => 2, 'presensi' => 2, 'nilai' => 2, 'kunci' => 'Dikunci'], array_intersect_key($result->rows[0], array_flip(['peserta', 'jadwal', 'ujian', 'presensi', 'nilai', 'kunci'])));
|
||||
$this->assertEquals(['peserta' => 1, 'jadwal' => 0, 'ujian' => 0, 'presensi' => 0, 'nilai' => 0, 'kunci' => 'Belum dikunci'], array_intersect_key($result->rows[1], array_flip(['peserta', 'jadwal', 'ujian', 'presensi', 'nilai', 'kunci'])));
|
||||
$this->assertSame(['IF101', 'IF102'], $this->column($this->report('repp_monitoringkelas', ['kurikulum' => '2020']), 'kode'));
|
||||
$this->assertSame([], $this->column($this->report('repp_monitoringkelas', ['kurikulum' => '2019']), 'kode'));
|
||||
$this->assertSame(['IF101'], $this->column($this->report('repp_monitoringkelas', ['dosen' => 'siti']), 'kode'));
|
||||
}
|
||||
|
||||
public function test_kapasitas_kelas(): void
|
||||
{
|
||||
$result = $this->report('repp_kapasitaskelas');
|
||||
|
||||
$this->assertEquals([30, 2, 28, 6.7], [$result->rows[0]['kapasitas'], $result->rows[0]['peserta'], $result->rows[0]['sisa'], $result->rows[0]['terisi']]);
|
||||
$this->assertEquals([2, 1, 1, 50.0], [$result->rows[1]['kapasitas'], $result->rows[1]['peserta'], $result->rows[1]['sisa'], $result->rows[1]['terisi']]);
|
||||
|
||||
$zero = $this->report('repp_kapasitaskelas', [], [22]);
|
||||
$this->assertSame(['TS101'], $this->column($zero, 'kode'));
|
||||
$this->assertNull($zero->rows[0]['sisa']);
|
||||
$this->assertNull($zero->rows[0]['terisi']);
|
||||
}
|
||||
|
||||
public function test_prodi_kosong_dan_prodi_di_luar_akun_tidak_menghasilkan_data(): void
|
||||
{
|
||||
foreach ($this->reports->slugs() as $slug) {
|
||||
$result = $this->reports->run($slug, ['periode' => 900, 'mk' => 'if'], $this->context([]), 100);
|
||||
$this->assertSame([], $result->rows, $slug);
|
||||
$this->assertSame(0, $result->count(), $slug);
|
||||
}
|
||||
|
||||
// Pilihan prodi yang bukan milik akun diabaikan: tetap prodi akun.
|
||||
$this->assertSame(['IF101', 'IF102'], $this->column($this->report('repp_kapasitaskelas', ['prodi' => 22]), 'kode'));
|
||||
$this->assertSame(['TS101'], $this->column($this->report('repp_kapasitaskelas', ['prodi' => 22], [21, 22]), 'kode'));
|
||||
}
|
||||
|
||||
public function test_batas_baris_dan_total(): void
|
||||
{
|
||||
$sheet = $this->report('repp_absensi', [], null, 2);
|
||||
$this->assertCount(2, $sheet->rows);
|
||||
$this->assertSame(3, $sheet->total);
|
||||
$this->assertTrue($sheet->truncated());
|
||||
|
||||
$recap = $this->report('repp_rekapabsenmhs', [], null, 1);
|
||||
$this->assertCount(1, $recap->rows);
|
||||
$this->assertSame(2, $recap->total);
|
||||
|
||||
$distribution = $this->report('repp_distribusinilai', [], null, 1);
|
||||
$this->assertCount(1, $distribution->rows);
|
||||
$this->assertSame(2, $distribution->total);
|
||||
|
||||
$grades = $this->report('repp_nilaimhs', [], null, 1);
|
||||
$this->assertSame(2, $grades->total);
|
||||
|
||||
$full = $this->report('repp_absensi', [], null, 100);
|
||||
$this->assertFalse($full->truncated());
|
||||
}
|
||||
|
||||
public function test_slug_tidak_dikenal_ditolak(): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
$this->reports->run('repp_perkuliahan', ['periode' => 900], $this->context(), 10);
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function rowFor(ReportResult $result, string $nim, string $kode): array
|
||||
{
|
||||
foreach ($result->rows as $row) {
|
||||
if ($row['nim'] === $nim && $row['kode'] === $kode) {
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
||||
$this->fail("Baris {$nim}/{$kode} tidak ada");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Operator\Reports;
|
||||
|
||||
use App\Support\Legacy\Reports\KurikulumReports;
|
||||
use App\Support\Legacy\Reports\ReportContext;
|
||||
use App\Support\Legacy\Reports\ReportResult;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\Concerns\FakesLegacyDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
/** Laporan kurikulum prodi dan daftar mata kuliah dari DB lama (tiruan). */
|
||||
class KurikulumReportsTest extends TestCase
|
||||
{
|
||||
use FakesLegacyDatabase;
|
||||
use RefreshDatabase;
|
||||
|
||||
private KurikulumReports $reports;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->useLegacyDatabase();
|
||||
$this->seedLegacyOverview();
|
||||
$this->seedLegacyEmployees();
|
||||
$this->seedLegacyCurriculum();
|
||||
$this->reports = app(KurikulumReports::class);
|
||||
}
|
||||
|
||||
private function context(array $prodi = [21, 22]): ReportContext
|
||||
{
|
||||
$names = DB::connection('untan')->table('t_bagian')->whereIn('idbagian', $prodi)->pluck('namabagian', 'idbagian')->all();
|
||||
|
||||
return new ReportContext(1, 'staf', $prodi, $names);
|
||||
}
|
||||
|
||||
private function keys(ReportResult $result): array
|
||||
{
|
||||
return array_column($result->columns, 'key');
|
||||
}
|
||||
|
||||
/** @return list<string> */
|
||||
private function codes(array $params, ?ReportContext $context = null): array
|
||||
{
|
||||
return array_column($this->reports->run('repp_matakuliah', $params, $context ?? $this->context(), 100)->rows, 'kode');
|
||||
}
|
||||
|
||||
public function test_slugs_hanya_yang_bersumber(): void
|
||||
{
|
||||
$this->assertSame(['repp_kurikulumprodi', 'repp_matakuliah'], $this->reports->slugs());
|
||||
}
|
||||
|
||||
public function test_definisi_valid(): void
|
||||
{
|
||||
foreach ($this->reports->slugs() as $slug) {
|
||||
$params = $this->reports->definition($slug, $this->context())['params'];
|
||||
$names = array_column($params, 'name');
|
||||
$this->assertSame($names, array_values(array_unique($names)));
|
||||
$this->assertEmpty(array_intersect($names, ['tampil', 'kop']));
|
||||
foreach ($params as $param) {
|
||||
$this->assertContains($param['type'], ['select', 'text', 'number', 'date', 'check']);
|
||||
if ($param['type'] === 'select') {
|
||||
$this->assertIsArray($param['options']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$kurikulum = collect($this->reports->definition('repp_kurikulumprodi', $this->context())['params'])->keyBy('name');
|
||||
$this->assertSame([21, 22], array_keys($kurikulum['prodi']['options']));
|
||||
$this->assertEqualsCanonicalizing([2020, 2021], array_keys($kurikulum['tahun']['options']));
|
||||
$matakuliah = collect($this->reports->definition('repp_matakuliah', $this->context([21]))['params'])->keyBy('name');
|
||||
$this->assertSame(['MKP', 'MKWU'], array_keys($matakuliah['kelompok']['options']));
|
||||
$this->assertSame([21], array_keys($matakuliah['prodi']['options']));
|
||||
}
|
||||
|
||||
public function test_kurikulum_prodi(): void
|
||||
{
|
||||
$result = $this->reports->run('repp_kurikulumprodi', [], $this->context(), 100);
|
||||
|
||||
$this->assertSame(['prodi', 'kode', 'kurikulum', 'tahun', 'berlaku', 'program', 'status', 'jumlah_mk', 'sks_wajib', 'sks_pilihan', 'sks_total'], $this->keys($result));
|
||||
$this->assertSame(2, $result->count());
|
||||
$byName = collect($result->rows)->keyBy('kurikulum');
|
||||
|
||||
// Kurikulum 900: 301 (3 SKS wajib), 302 + 303 (pilihan, 6 SKS), 304 (2 SKS wajib), 305 tanpa kelompok (4 SKS wajib).
|
||||
$keys = array_flip(['tahun', 'status', 'jumlah_mk', 'sks_wajib', 'sks_pilihan', 'sks_total']);
|
||||
$this->assertSame(
|
||||
['tahun' => '2020', 'status' => 'Aktif', 'jumlah_mk' => 5, 'sks_wajib' => 9, 'sks_pilihan' => 6, 'sks_total' => 15],
|
||||
array_intersect_key($byName['Kurikulum 2020'], $keys),
|
||||
);
|
||||
$this->assertSame('2020/2021 Ganjil', $byName['Kurikulum 2020']['berlaku']);
|
||||
$this->assertSame('55201', $byName['Kurikulum 2020']['kode']);
|
||||
$this->assertStringEndsWith('Teknik Sipil', $byName['Kurikulum 2021']['prodi']);
|
||||
$this->assertSame('Tidak aktif', $byName['Kurikulum 2021']['status']);
|
||||
$this->assertSame(1, $byName['Kurikulum 2021']['jumlah_mk']);
|
||||
$this->assertSame(2, $byName['Kurikulum 2021']['sks_total']);
|
||||
$this->assertContains('Jumlah: 2 kurikulum', $result->summary);
|
||||
}
|
||||
|
||||
public function test_kurikulum_prodi_filter(): void
|
||||
{
|
||||
$names = fn (array $params): array => array_column($this->reports->run('repp_kurikulumprodi', $params, $this->context(), 100)->rows, 'kurikulum');
|
||||
|
||||
$this->assertSame(['Kurikulum 2021'], $names(['tahun' => '2021']));
|
||||
$this->assertSame(['Kurikulum 2020'], $names(['status' => '1']));
|
||||
$this->assertSame(['Kurikulum 2021'], $names(['status' => '0']));
|
||||
$this->assertSame(['Kurikulum 2021'], $names(['prodi' => '22']));
|
||||
}
|
||||
|
||||
public function test_kurikulum_prodi_cakupan(): void
|
||||
{
|
||||
$names = fn (array $params, array $prodi): array => array_column($this->reports->run('repp_kurikulumprodi', $params, $this->context($prodi), 100)->rows, 'kurikulum');
|
||||
|
||||
$this->assertSame(['Kurikulum 2020'], $names([], [21]));
|
||||
// Prodi di luar akun diabaikan: kembali ke prodi akun, bukan prodi 99.
|
||||
$this->assertSame(['Kurikulum 2020'], $names(['prodi' => '99'], [21]));
|
||||
$this->assertNotContains('Kurikulum Luar', $names([], [21, 22]));
|
||||
|
||||
$empty = $this->reports->run('repp_kurikulumprodi', [], $this->context([]), 100);
|
||||
$this->assertSame([], $empty->rows);
|
||||
$this->assertSame(0, $empty->count());
|
||||
}
|
||||
|
||||
public function test_daftar_mata_kuliah(): void
|
||||
{
|
||||
$result = $this->reports->run('repp_matakuliah', [], $this->context([21]), 100);
|
||||
|
||||
$this->assertSame(['kode', 'nama', 'sks', 'semester', 'jenis', 'kelompok', 'sifat', 'grup', 'kurikulum', 'prodi'], $this->keys($result));
|
||||
$byCode = collect($result->rows)->keyBy('kode');
|
||||
$this->assertEqualsCanonicalizing(['IF311', 'IF312', 'IF313', 'IF314', 'IF315'], $byCode->keys()->all());
|
||||
|
||||
$pick = fn (string $code, array $keys): array => array_intersect_key($byCode[$code], array_flip($keys));
|
||||
$this->assertSame(
|
||||
['sks' => 3, 'semester' => 3, 'jenis' => 'Kuliah', 'kelompok' => 'MKWU', 'sifat' => 'Wajib', 'grup' => null],
|
||||
$pick('IF311', ['sks', 'semester', 'jenis', 'kelompok', 'sifat', 'grup']),
|
||||
);
|
||||
$this->assertSame(['kelompok' => 'MKP', 'sifat' => 'Pilihan', 'grup' => 'Sistem Informasi'], $pick('IF312', ['kelompok', 'sifat', 'grup']));
|
||||
$this->assertEquals(['jenis' => 'Praktik Lapangan', 'kelompok' => null, 'semester' => 7], $pick('IF315', ['jenis', 'kelompok', 'semester']));
|
||||
$this->assertSame('2020 – Kurikulum 2020', $byCode['IF311']['kurikulum']);
|
||||
$this->assertContains('Jumlah: 5 mata kuliah, 15 SKS', $result->summary);
|
||||
}
|
||||
|
||||
public function test_daftar_mata_kuliah_filter(): void
|
||||
{
|
||||
$this->assertEqualsCanonicalizing(['TS201'], $this->codes(['tahun' => '2021']));
|
||||
$this->assertEqualsCanonicalizing(['IF312', 'IF313'], $this->codes(['kelompok' => 'MKP']));
|
||||
$this->assertEqualsCanonicalizing(['IF315'], $this->codes(['tipe' => '1']));
|
||||
$this->assertEqualsCanonicalizing(['IF312'], $this->codes(['q' => 'web']));
|
||||
$this->assertEqualsCanonicalizing(['TS201'], $this->codes(['prodi' => '22', 'q' => 'ts2']));
|
||||
}
|
||||
|
||||
public function test_daftar_mata_kuliah_cakupan_dan_batas(): void
|
||||
{
|
||||
$this->assertSame([], $this->codes([], $this->context([])));
|
||||
$this->assertNotContains('LL101', $this->codes([]));
|
||||
$this->assertNotContains('LL101', $this->codes(['prodi' => '99'], $this->context([21])));
|
||||
|
||||
$limited = $this->reports->run('repp_matakuliah', [], $this->context(), 2);
|
||||
$this->assertCount(2, $limited->rows);
|
||||
$this->assertSame(6, $limited->total);
|
||||
$this->assertTrue($limited->truncated());
|
||||
$this->assertSame(6, $limited->count());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,454 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Operator\Reports;
|
||||
|
||||
use App\Support\Legacy\Reports\MahasiswaReports;
|
||||
use App\Support\Legacy\Reports\ReportContext;
|
||||
use App\Support\Legacy\Reports\ReportResult;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Tests\Concerns\FakesLegacyDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
/** Laporan kelompok Mahasiswa (menu Laporan operator) terhadap DB lama tiruan. */
|
||||
class MahasiswaReportsTest extends TestCase
|
||||
{
|
||||
use FakesLegacyDatabase;
|
||||
use RefreshDatabase;
|
||||
|
||||
private const array SLUGS = [
|
||||
'repp_daftarmhs', 'repp_daftarmhstransfer', 'repp_terancamdo', 'repp_cekalmhs', 'repp_ktm', 'repp_kurikulummhs',
|
||||
'repp_masastudi', 'repp_statussemester', 'repp_rekapbiodata', 'repp_rekapmhsprodi', 'repp_statusmhs', 'repp_statusmhs5thn',
|
||||
];
|
||||
|
||||
private MahasiswaReports $reports;
|
||||
|
||||
/** Prodi akun: 21 Teknik Informatika dan 22 Sistem Informasi. Prodi 99 di luar cakupan. */
|
||||
private ReportContext $context;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->useLegacyDatabase();
|
||||
$this->extendSchema();
|
||||
$this->seedStudents();
|
||||
$this->reports = new MahasiswaReports;
|
||||
$this->context = new ReportContext(1, 'operator', [21, 22], [21 => 'Teknik Informatika', 22 => 'Sistem Informasi']);
|
||||
}
|
||||
|
||||
private function extendSchema(): void
|
||||
{
|
||||
$schema = Schema::connection('untan');
|
||||
$columns = [
|
||||
't_mahasiswa' => [
|
||||
'kelamin' => fn (Blueprint $t) => $t->smallInteger('kelamin')->nullable(),
|
||||
'agama' => fn (Blueprint $t) => $t->smallInteger('agama')->nullable(),
|
||||
'tmplahir' => fn (Blueprint $t) => $t->string('tmplahir')->nullable(),
|
||||
'tgllahir' => fn (Blueprint $t) => $t->date('tgllahir')->nullable(),
|
||||
'alamat_mhs' => fn (Blueprint $t) => $t->string('alamat_mhs')->nullable(),
|
||||
'namaayah' => fn (Blueprint $t) => $t->string('namaayah')->nullable(),
|
||||
'namaibu' => fn (Blueprint $t) => $t->string('namaibu')->nullable(),
|
||||
'namaslta' => fn (Blueprint $t) => $t->string('namaslta')->nullable(),
|
||||
'thnlulusslta' => fn (Blueprint $t) => $t->string('thnlulusslta')->nullable(),
|
||||
],
|
||||
't_evaluasi' => [
|
||||
'aktif' => fn (Blueprint $t) => $t->integer('aktif')->default(0),
|
||||
'cuti' => fn (Blueprint $t) => $t->integer('cuti')->default(0),
|
||||
'nonaktif' => fn (Blueprint $t) => $t->integer('nonaktif')->default(0),
|
||||
],
|
||||
];
|
||||
foreach ($columns as $table => $definitions) {
|
||||
foreach ($definitions as $column => $define) {
|
||||
if (! $schema->hasColumn($table, $column)) {
|
||||
$schema->table($table, fn (Blueprint $t) => $define($t));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! $schema->hasTable('t_mahasiswa_masastudi')) {
|
||||
$schema->create('t_mahasiswa_masastudi', function (Blueprint $table) {
|
||||
$table->integer('idtoleransi')->primary();
|
||||
$table->integer('idmahasiswa');
|
||||
$table->string('nim')->nullable();
|
||||
});
|
||||
}
|
||||
if (! $schema->hasTable('t_perpanjangan_studi')) {
|
||||
$schema->create('t_perpanjangan_studi', function (Blueprint $table) {
|
||||
$table->integer('id_rec')->primary();
|
||||
$table->string('nim');
|
||||
$table->integer('idperiode')->nullable();
|
||||
$table->string('no_surat')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mahasiswa (prodi 21/22 dalam cakupan, 99 di luar):
|
||||
* 601 TI001 aktif L (2019 Ganjil), 602 TI002 aktif P pindahan PTN (2020 Genap), 603 TI003 lulus P cekal,
|
||||
* 604 SI001 aktif L pindah dari 606, 606 TI009 pindah (keluar) L, 607 XX001 prodi 99 (semua jenis data ada).
|
||||
*/
|
||||
private function seedStudents(): void
|
||||
{
|
||||
$db = DB::connection('untan');
|
||||
$db->table('t_mahasiswa')->delete();
|
||||
$db->table('t_bagian')->insert([
|
||||
['idbagian' => 22, 'idbagian_induk' => 20, 'idjenisbagian' => 3, 'namabagian' => 'Sistem Informasi'],
|
||||
['idbagian' => 99, 'idbagian_induk' => 20, 'idjenisbagian' => 3, 'namabagian' => 'Prodi Lain'],
|
||||
]);
|
||||
$db->table('t_jenjangprogdi')->insert(['idjenjang' => 2, 'kdjenjang' => 'S1', 'kode' => 'C', 'minsksbeban' => 144, 'mstudimax' => 7]);
|
||||
$db->table('t_progdi')->insert([['idbagian' => 21, 'idjenjang' => 2], ['idbagian' => 22, 'idjenjang' => 2], ['idbagian' => 99, 'idjenjang' => 2]]);
|
||||
$db->table('t_angkatanmhs')->insert(['idangkatan' => 151, 'tahun' => 2020, 'semester' => 2]);
|
||||
$db->table('t_jenisprogram')->insert(['idprogram' => 1, 'program' => 'Reguler A']);
|
||||
$db->table('t_jalurmasuk')->insert([['idjalur_siakad' => 1, 'nama_jalur_masuk' => 'SNMPTN'], ['idjalur_siakad' => 7, 'nama_jalur_masuk' => 'PINDAHAN PTN']]);
|
||||
$db->table('xs_agama')->insert(['idagama' => 1, 'agama' => 'Islam']);
|
||||
$db->table('t_stat_akademik')->insert([
|
||||
['idstat_akd' => 0, 'status_akademik' => 'Alpa Kuliah'], ['idstat_akd' => 1, 'status_akademik' => 'Aktif'],
|
||||
['idstat_akd' => 2, 'status_akademik' => 'Cuti'], ['idstat_akd' => 3, 'status_akademik' => 'Lulus'],
|
||||
]);
|
||||
$db->table('t_kurikulum')->insert(['idkurikulum' => 10, 'idprogdi' => 21, 'idprogram' => 1, 'namakurikulum' => 'Kur 2020', 'aktif' => true]);
|
||||
$db->table('t_periodekuliah')->insert([
|
||||
['idperiode' => 1, 'thakad' => '2020/2021', 'semester' => 1, 'perkuliahan' => 1],
|
||||
['idperiode' => 2, 'thakad' => '2020/2021', 'semester' => 2, 'perkuliahan' => 1],
|
||||
]);
|
||||
$db->table('t_periodekuliahaktif')->insert(['idprogdi' => 21, 'idperiode' => 2]);
|
||||
|
||||
$student = fn (int $id, string $nim, string $nama, int $prodi, int $angkatan, int $status, int $sex, int $jalur = 1, ?int $kurikulum = null): array => [
|
||||
'idmahasiswa' => $id, 'nim' => $nim, 'nama' => $nama, 'idprogdi' => $prodi, 'idangkatan' => $angkatan, 'stataktif' => $status,
|
||||
'kelamin' => $sex, 'jalur_masuk' => $jalur, 'idprogram' => 1, 'idkurikulum' => $kurikulum,
|
||||
'agama' => null, 'tmplahir' => null, 'tgllahir' => null, 'alamat_mhs' => null, 'hp' => null, 'email_mhs' => null,
|
||||
'namaayah' => null, 'namaibu' => null, 'namaslta' => null, 'thnlulusslta' => null,
|
||||
];
|
||||
$db->table('t_mahasiswa')->insert([
|
||||
array_merge($student(601, 'TI001', 'Andi Pratama', 21, 150, 1, 1, kurikulum: 10), [
|
||||
'agama' => 1, 'tmplahir' => 'Pontianak', 'tgllahir' => '2000-02-01', 'alamat_mhs' => 'Jl. Merdeka 1', 'hp' => '0812000',
|
||||
'email_mhs' => 'andi@example.test', 'namaayah' => 'Pak Andi', 'namaibu' => 'Bu Andi', 'namaslta' => 'SMAN 1', 'thnlulusslta' => '2019',
|
||||
]),
|
||||
$student(602, 'TI002', 'Bunga Lestari', 21, 151, 1, 2, 7),
|
||||
$student(603, 'TI003', 'Candra Dewi', 21, 150, 2, 2),
|
||||
$student(604, 'SI001', 'Dedi Kurnia', 22, 150, 1, 1),
|
||||
$student(606, 'TI009', 'Dedi Lama', 21, 150, 5, 1),
|
||||
$student(607, 'XX001', 'Luar Cakupan', 99, 150, 1, 1, 7),
|
||||
]);
|
||||
|
||||
$db->table('t_histori_mahasiswa')->insert([
|
||||
['idmahasiswa' => 601, 'idperiode' => 1, 'stat_akd_akhir' => 1], ['idmahasiswa' => 601, 'idperiode' => 2, 'stat_akd_akhir' => 1],
|
||||
['idmahasiswa' => 602, 'idperiode' => 2, 'stat_akd_akhir' => 2],
|
||||
['idmahasiswa' => 604, 'idperiode' => 1, 'stat_akd_akhir' => 1], ['idmahasiswa' => 604, 'idperiode' => 2, 'stat_akd_akhir' => 0],
|
||||
['idmahasiswa' => 607, 'idperiode' => 2, 'stat_akd_akhir' => 1],
|
||||
]);
|
||||
$kst = fn (int $mhs, int $stat): array => ['idmahasiswa' => $mhs, 'idjadwal' => 1, 'idmatakuliah' => 1, 'idperiode' => 2, 'stat' => $stat];
|
||||
$db->table('t_kst')->insert([$kst(601, 1), $kst(604, 0), $kst(607, 1)]);
|
||||
$db->table('t_evaluasi')->insert([
|
||||
['idmahasiswa' => 601, 'idperiode' => 2, 'semestertempuh' => 13, 'skslulus' => 100, 'ipkeval' => 3.2, 'aktif' => 12, 'cuti' => 0, 'nonaktif' => 1],
|
||||
['idmahasiswa' => 602, 'idperiode' => 2, 'semestertempuh' => 5, 'skslulus' => 50, 'ipkeval' => 3.0, 'aktif' => 3, 'cuti' => 2, 'nonaktif' => 0],
|
||||
['idmahasiswa' => 604, 'idperiode' => 2, 'semestertempuh' => 14, 'skslulus' => 90, 'ipkeval' => 2.4, 'aktif' => 6, 'cuti' => 1, 'nonaktif' => 7],
|
||||
['idmahasiswa' => 607, 'idperiode' => 2, 'semestertempuh' => 14, 'skslulus' => 90, 'ipkeval' => 2.4, 'aktif' => 7, 'cuti' => 0, 'nonaktif' => 7],
|
||||
]);
|
||||
$db->table('t_mahasiswa_cekal')->insert([['idcekal' => 1, 'idmahasiswa' => 603, 'nim' => 'TI003'], ['idcekal' => 2, 'idmahasiswa' => 607, 'nim' => 'XX001']]);
|
||||
$db->table('t_pindah')->insert([
|
||||
['idpindah' => 1, 'idmahasiswa' => 604, 'idmahasiswalama' => 606, 'idperiode' => 2],
|
||||
['idpindah' => 2, 'idmahasiswa' => 607, 'idmahasiswalama' => 606, 'idperiode' => 2],
|
||||
]);
|
||||
$db->table('t_mahasiswa_masastudi')->insert(['idtoleransi' => 1, 'idmahasiswa' => 601, 'nim' => 'TI001']);
|
||||
$db->table('t_perpanjangan_studi')->insert(['id_rec' => 1, 'nim' => 'TI001', 'idperiode' => 2, 'no_surat' => '123/UN22']);
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $params */
|
||||
private function report(string $slug, array $params = [], int $limit = 200, ?ReportContext $context = null): ReportResult
|
||||
{
|
||||
return $this->reports->run($slug, $params, $context ?? $this->context, $limit);
|
||||
}
|
||||
|
||||
/** @return list<mixed> */
|
||||
private function column(ReportResult $result, string $key): array
|
||||
{
|
||||
return array_column($result->rows, $key);
|
||||
}
|
||||
|
||||
public function test_slugs_cover_only_reports_with_a_source(): void
|
||||
{
|
||||
$this->assertSame(self::SLUGS, $this->reports->slugs());
|
||||
$this->assertNotContains('repp_kalender', $this->reports->slugs());
|
||||
$this->assertNotContains('repp_riwayatmeet', $this->reports->slugs());
|
||||
}
|
||||
|
||||
public function test_definitions_are_valid(): void
|
||||
{
|
||||
foreach (self::SLUGS as $slug) {
|
||||
$definition = $this->reports->definition($slug, $this->context);
|
||||
$names = array_column($definition['params'], 'name');
|
||||
|
||||
$this->assertNotEmpty($names, $slug);
|
||||
$this->assertSame($names, array_values(array_unique($names)), "{$slug}: nama parameter harus unik");
|
||||
$this->assertSame([], array_intersect($names, ['tampil', 'kop']), $slug);
|
||||
foreach ($definition['params'] as $param) {
|
||||
$this->assertContains($param['type'], ['select', 'text', 'number', 'date', 'check'], $slug);
|
||||
$this->assertNotSame('', $param['label']);
|
||||
if ($param['type'] === 'select') {
|
||||
$this->assertIsArray($param['options'], "{$slug}.{$param['name']}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function test_definition_options_come_from_account_scope(): void
|
||||
{
|
||||
$params = collect($this->reports->definition('repp_daftarmhs', $this->context)['params'])->keyBy('name');
|
||||
|
||||
$this->assertSame([21 => 'Teknik Informatika', 22 => 'Sistem Informasi'], $params['prodi']['options']);
|
||||
$this->assertTrue($params['prodi']['required']);
|
||||
$this->assertSame([151 => '2020 Genap', 150 => '2019 Ganjil'], $params['masuk']['options']);
|
||||
$this->assertSame([1 => 'Reguler A'], $params['program']['options']);
|
||||
$this->assertSame([7 => 'PINDAHAN PTN', 1 => 'SNMPTN'], $params['jalur']['options']);
|
||||
|
||||
$period = collect($this->reports->definition('repp_statussemester', $this->context)['params'])->firstWhere('name', 'periode');
|
||||
$this->assertSame([2 => '2020/2021 Genap', 1 => '2020/2021 Ganjil'], $period['options']);
|
||||
$this->assertSame(2, $period['default']);
|
||||
}
|
||||
|
||||
public function test_student_list(): void
|
||||
{
|
||||
$result = $this->report('repp_daftarmhs', ['prodi' => 21, 'masuk' => 150]);
|
||||
|
||||
$this->assertSame(['nim', 'nama', 'jk', 'prodi', 'masuk', 'program', 'jalur', 'status'], array_column($result->columns, 'key'));
|
||||
$this->assertSame(['TI001', 'TI003', 'TI009'], $this->column($result, 'nim'));
|
||||
$this->assertSame(['Masih Kuliah', 'Lulus', 'Pindah'], $this->column($result, 'status'));
|
||||
$this->assertSame(['L', 'P', 'L'], $this->column($result, 'jk'));
|
||||
$this->assertSame('2019 Ganjil', $result->rows[0]['masuk']);
|
||||
$this->assertSame('Reguler A', $result->rows[0]['program']);
|
||||
$this->assertSame('SNMPTN', $result->rows[0]['jalur']);
|
||||
$this->assertSame(3, $result->total);
|
||||
|
||||
$this->assertSame(['TI001'], $this->column($this->report('repp_daftarmhs', ['prodi' => 21, 'masuk' => 150, 'status' => 1]), 'nim'));
|
||||
$this->assertSame(['TI002'], $this->column($this->report('repp_daftarmhs', ['prodi' => 21, 'masuk' => 151, 'jalur' => 7]), 'nim'));
|
||||
}
|
||||
|
||||
public function test_student_list_respects_limit_and_total(): void
|
||||
{
|
||||
$result = $this->report('repp_daftarmhs', ['prodi' => 21, 'masuk' => 150], limit: 2);
|
||||
|
||||
$this->assertCount(2, $result->rows);
|
||||
$this->assertSame(3, $result->total);
|
||||
$this->assertTrue($result->truncated());
|
||||
}
|
||||
|
||||
public function test_transfers(): void
|
||||
{
|
||||
$all = $this->report('repp_daftarmhstransfer');
|
||||
|
||||
$this->assertSame(2, $all->total);
|
||||
$this->assertSame(['SI001', 'TI002'], $this->column($all, 'nim'));
|
||||
$this->assertSame('Pindah Program Studi', $all->rows[0]['jenis']);
|
||||
$this->assertSame('Teknik Informatika (TI009)', $all->rows[0]['asal']);
|
||||
$this->assertSame('2020/2021 Genap', $all->rows[0]['periode']);
|
||||
$this->assertSame('PINDAHAN PTN', $all->rows[1]['jalur']);
|
||||
$this->assertNull($all->rows[1]['asal']);
|
||||
|
||||
$this->assertSame(['SI001'], $this->column($this->report('repp_daftarmhstransfer', ['jenis' => 'prodi']), 'nim'));
|
||||
$this->assertSame(['TI002'], $this->column($this->report('repp_daftarmhstransfer', ['jenis' => 'ptn']), 'nim'));
|
||||
$this->assertSame(['TI002'], $this->column($this->report('repp_daftarmhstransfer', ['angkatan' => 2020]), 'nim'));
|
||||
}
|
||||
|
||||
public function test_dropout_risk(): void
|
||||
{
|
||||
$result = $this->report('repp_terancamdo', ['periode' => 2]);
|
||||
|
||||
// 601: 12 aktif + 1 non aktif = 13 dari batas 14; 604: 6 + 7 = 13. 602 masih jauh, 607 di luar cakupan.
|
||||
$this->assertSame(['SI001', 'TI001'], $this->column($result, 'nim'));
|
||||
$this->assertSame(14, $result->rows[0]['batas']);
|
||||
$this->assertSame(1, $result->rows[0]['sisa']);
|
||||
$this->assertSame(2.4, $result->rows[0]['ipk']);
|
||||
$this->assertSame(2, $result->total);
|
||||
|
||||
$this->assertSame([], $this->report('repp_terancamdo', ['periode' => 2, 'sisa' => 0])->rows);
|
||||
$this->assertSame(['SI001', 'TI001', 'TI002'], $this->column($this->report('repp_terancamdo', ['periode' => 2, 'sisa' => 12]), 'nim'));
|
||||
$this->assertSame(['SI001'], $this->column($this->report('repp_terancamdo', ['periode' => 2, 'maks_cuti' => 0]), 'nim'));
|
||||
$this->assertSame(['TI001'], $this->column($this->report('repp_terancamdo', ['periode' => 2, 'prodi' => 21]), 'nim'));
|
||||
}
|
||||
|
||||
public function test_blacklist(): void
|
||||
{
|
||||
$result = $this->report('repp_cekalmhs');
|
||||
|
||||
$this->assertSame(['TI003'], $this->column($result, 'nim'));
|
||||
$this->assertSame('Lulus', $result->rows[0]['status']);
|
||||
$this->assertSame(2019, $result->rows[0]['angkatan']);
|
||||
$this->assertSame(1, $result->total);
|
||||
$this->assertSame([], $this->report('repp_cekalmhs', ['mahasiswa' => 'zzz'])->rows);
|
||||
$this->assertSame(['TI003'], $this->column($this->report('repp_cekalmhs', ['mahasiswa' => 'candra']), 'nim'));
|
||||
}
|
||||
|
||||
public function test_student_card(): void
|
||||
{
|
||||
$this->assertSame(5, $this->report('repp_ktm')->total);
|
||||
|
||||
$result = $this->report('repp_ktm', ['mahasiswa' => 'andi']);
|
||||
|
||||
$this->assertSame(['TI001'], $this->column($result, 'nim'));
|
||||
$this->assertSame('Pontianak, 01-02-2000', $result->rows[0]['ttl']);
|
||||
$this->assertSame('S1 - Teknik Informatika', $result->rows[0]['prodi']);
|
||||
$this->assertSame('2019 Ganjil', $result->rows[0]['masuk']);
|
||||
$this->assertSame(['TI002'], $this->column($this->report('repp_ktm', ['masuk' => 151]), 'nim'));
|
||||
}
|
||||
|
||||
public function test_student_curriculum(): void
|
||||
{
|
||||
$all = $this->report('repp_kurikulummhs', ['angkatan' => 2019]);
|
||||
|
||||
$this->assertSame(['SI001', 'TI001', 'TI003', 'TI009'], $this->column($all, 'nim'));
|
||||
$this->assertSame('Kur 2020', $all->rows[1]['kurikulum']);
|
||||
$this->assertSame('Ya', $all->rows[1]['aktif']);
|
||||
$this->assertNull($all->rows[0]['kurikulum']);
|
||||
$this->assertSame(['SI001'], $this->column($this->report('repp_kurikulummhs', ['prodi' => 22]), 'nim'));
|
||||
$this->assertSame(['TI002'], $this->column($this->report('repp_kurikulummhs', ['mahasiswa' => 'bunga']), 'nim'));
|
||||
}
|
||||
|
||||
public function test_study_duration(): void
|
||||
{
|
||||
$result = $this->report('repp_masastudi', ['periode' => 2, 'status' => 1]);
|
||||
|
||||
$this->assertSame(['SI001', 'TI001', 'TI002'], $this->column($result, 'nim'));
|
||||
[$si, $ti, $bunga] = $result->rows;
|
||||
$this->assertSame(['smt' => 4, 'aktif' => 1, 'cuti' => 0, 'nonaktif' => 1, 'batas' => 14, 'sisa' => 12], array_intersect_key($si, array_flip(['aktif', 'nonaktif', 'cuti', 'batas', 'sisa', 'smt'])));
|
||||
$this->assertSame(2, $ti['aktif']);
|
||||
$this->assertSame('Ya', $ti['toleransi']);
|
||||
$this->assertSame('123/UN22', $ti['perpanjangan']);
|
||||
$this->assertSame(1, $bunga['cuti']);
|
||||
$this->assertSame(14, $bunga['sisa']);
|
||||
$this->assertSame(1, $bunga['smt']);
|
||||
|
||||
$this->assertSame(['SI001'], $this->column($this->report('repp_masastudi', ['periode' => 2, 'status_semester' => 0]), 'nim'));
|
||||
$this->assertSame(['TI002'], $this->column($this->report('repp_masastudi', ['periode' => 2, 'status_semester' => 2]), 'nim'));
|
||||
$this->assertSame(['TI002'], $this->column($this->report('repp_masastudi', ['periode' => 2, 'angkatan' => 2020]), 'nim'));
|
||||
}
|
||||
|
||||
public function test_semester_status(): void
|
||||
{
|
||||
$result = $this->report('repp_statussemester', ['periode' => 2, 'prodi' => 21]);
|
||||
|
||||
$this->assertSame(['nim', 'nama', 'prodi', 'angkatan', 'smt', 'status', 'krs', 'setuju'], array_column($result->columns, 'key'));
|
||||
$this->assertSame(['TI001', 'TI002'], $this->column($result, 'nim'));
|
||||
$this->assertSame(['Aktif', 'Cuti'], $this->column($result, 'status'));
|
||||
$this->assertSame(['Ya', 'Tidak'], $this->column($result, 'krs'));
|
||||
$this->assertSame(['Ya', 'Tidak'], $this->column($result, 'setuju'));
|
||||
|
||||
$this->assertSame(['TI001'], $this->column($this->report('repp_statussemester', ['periode' => 2, 'prodi' => 21, 'krs' => 'ya']), 'nim'));
|
||||
$this->assertSame(['TI002'], $this->column($this->report('repp_statussemester', ['periode' => 2, 'prodi' => 21, 'krs_setuju' => 'tidak']), 'nim'));
|
||||
$this->assertSame(['TI002'], $this->column($this->report('repp_statussemester', ['periode' => 2, 'prodi' => 21, 'status_semester' => 2]), 'nim'));
|
||||
|
||||
$other = $this->report('repp_statussemester', ['periode' => 2, 'prodi' => 22]);
|
||||
$this->assertSame(['Alpa Kuliah'], $this->column($other, 'status'));
|
||||
$this->assertSame(['Ya'], $this->column($other, 'krs'));
|
||||
$this->assertSame(['Tidak'], $this->column($other, 'setuju'));
|
||||
$this->assertSame(['SI001'], $this->column($this->report('repp_statussemester', ['periode' => 2, 'prodi' => 22, 'status_semester' => 0]), 'nim'));
|
||||
}
|
||||
|
||||
public function test_semester_status_contact_columns_are_optional(): void
|
||||
{
|
||||
$result = $this->report('repp_statussemester', ['periode' => 2, 'prodi' => 21, 'kontak' => true]);
|
||||
|
||||
$this->assertContains('hp', array_column($result->columns, 'key'));
|
||||
$this->assertSame('0812000', $result->rows[0]['hp']);
|
||||
$this->assertSame('andi@example.test', $result->rows[0]['email']);
|
||||
$this->assertNull($result->rows[1]['hp']);
|
||||
}
|
||||
|
||||
public function test_biodata(): void
|
||||
{
|
||||
$result = $this->report('repp_rekapbiodata', ['masuk' => 150]);
|
||||
|
||||
$this->assertSame(['SI001', 'TI001', 'TI003', 'TI009'], $this->column($result, 'nim'));
|
||||
$this->assertSame(4, $result->total);
|
||||
$row = $result->rows[1];
|
||||
$this->assertSame('Islam', $row['agama']);
|
||||
$this->assertSame('01-02-2000', $row['tgllahir']);
|
||||
$this->assertSame('Pak Andi', $row['ayah']);
|
||||
$this->assertSame('SMAN 1', $row['sekolah']);
|
||||
$this->assertNotContains('passwd_ortu', array_column($result->columns, 'key'));
|
||||
|
||||
$this->assertSame(['TI001'], $this->column($this->report('repp_rekapbiodata', ['masuk' => 150, 'prodi' => 21, 'status' => 1]), 'nim'));
|
||||
}
|
||||
|
||||
public function test_program_recap(): void
|
||||
{
|
||||
$result = $this->report('repp_rekapmhsprodi', ['prodi' => 'semua']);
|
||||
|
||||
$this->assertSame(3, $result->total);
|
||||
$this->assertSame(
|
||||
[['Sistem Informasi', 2019, 1, 0, 1, 1, 0, 0], ['Teknik Informatika', 2020, 0, 1, 1, 1, 0, 0], ['Teknik Informatika', 2019, 2, 1, 3, 1, 1, 1]],
|
||||
array_map(fn (array $r): array => [$r['prodi'], $r['angkatan'], $r['l'], $r['p'], $r['total'], $r['aktif'], $r['lulus'], $r['keluar']], $result->rows),
|
||||
);
|
||||
|
||||
$this->assertSame([2020], $this->column($this->report('repp_rekapmhsprodi', ['prodi' => 21, 'jalur' => 7]), 'angkatan'));
|
||||
$this->assertSame(['Sistem Informasi'], array_unique($this->column($this->report('repp_rekapmhsprodi', ['prodi' => 22]), 'prodi')));
|
||||
}
|
||||
|
||||
public function test_academic_status_recap(): void
|
||||
{
|
||||
$result = $this->report('repp_statusmhs', ['periode' => 2]);
|
||||
|
||||
$this->assertSame(['prodi', 's0', 's1', 's2', 'total'], array_column($result->columns, 'key'));
|
||||
$this->assertSame(['Alpa Kuliah', 'Aktif', 'Cuti'], array_slice(array_column($result->columns, 'label'), 1, 3));
|
||||
$this->assertSame(
|
||||
[['Sistem Informasi', 1, 0, 0, 1], ['Teknik Informatika', 0, 1, 1, 2], ['Jumlah', 1, 1, 1, 3]],
|
||||
array_map(fn (array $r): array => [$r['prodi'], $r['s0'], $r['s1'], $r['s2'], $r['total']], $result->rows),
|
||||
);
|
||||
|
||||
$aktif = $this->report('repp_statusmhs', ['periode' => 2, 'status' => 1]);
|
||||
$this->assertSame(['Teknik Informatika', 'Jumlah'], $this->column($aktif, 'prodi'));
|
||||
$this->assertSame(['Teknik Informatika', 'Jumlah'], $this->column($this->report('repp_statusmhs', ['periode' => 2, 'angkatan' => 2020]), 'prodi'));
|
||||
}
|
||||
|
||||
public function test_cohort_status_recap(): void
|
||||
{
|
||||
$result = $this->report('repp_statusmhs5thn');
|
||||
|
||||
$this->assertSame(['angkatan', 's1', 's2', 's5', 'total'], array_column($result->columns, 'key'));
|
||||
$this->assertSame(
|
||||
[['2020', 1, 0, 0, 1], ['2019', 2, 1, 1, 4], ['Jumlah', 3, 1, 1, 5]],
|
||||
array_map(fn (array $r): array => [$r['angkatan'], $r['s1'], $r['s2'], $r['s5'], $r['total']], $result->rows),
|
||||
);
|
||||
|
||||
$range = $this->report('repp_statusmhs5thn', ['mulai' => 2020, 'sampai' => 2020]);
|
||||
$this->assertSame(['2020', 'Jumlah'], $this->column($range, 'angkatan'));
|
||||
$this->assertSame(['2019', 'Jumlah'], $this->column($this->report('repp_statusmhs5thn', ['mulai' => 2019, 'sampai' => 2019, 'status' => 2]), 'angkatan'));
|
||||
}
|
||||
|
||||
public function test_requested_prodi_outside_account_scope_is_ignored(): void
|
||||
{
|
||||
$result = $this->report('repp_daftarmhs', ['prodi' => 99, 'masuk' => 150]);
|
||||
|
||||
$this->assertSame(['SI001', 'TI001', 'TI003', 'TI009'], $this->column($result, 'nim'));
|
||||
$this->assertNotContains('XX001', $this->column($this->report('repp_ktm'), 'nim'));
|
||||
}
|
||||
|
||||
public function test_every_report_is_empty_without_managed_prodi(): void
|
||||
{
|
||||
$none = new ReportContext(1, 'operator', [], []);
|
||||
|
||||
foreach (self::SLUGS as $slug) {
|
||||
$params = match ($slug) {
|
||||
'repp_daftarmhs' => ['masuk' => 150],
|
||||
'repp_rekapbiodata' => ['masuk' => 150],
|
||||
'repp_rekapmhsprodi' => ['prodi' => 'semua'],
|
||||
default => [],
|
||||
};
|
||||
$result = $this->report($slug, $params, context: $none);
|
||||
|
||||
$this->assertSame([], $result->rows, $slug);
|
||||
$this->assertSame(0, $result->count(), $slug);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_definitions_work_without_managed_prodi(): void
|
||||
{
|
||||
$none = new ReportContext(1, 'operator', [], []);
|
||||
|
||||
foreach (self::SLUGS as $slug) {
|
||||
$this->assertIsArray($this->reports->definition($slug, $none)['params'], $slug);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,419 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Operator\Reports;
|
||||
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Legacy\Reports\ReportContext;
|
||||
use App\Support\Legacy\Reports\ReportResult;
|
||||
use App\Support\Legacy\Reports\TugasAkhirReports;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Tests\Concerns\FakesLegacyDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Laporan tugas akhir dan kelulusan dari DB lama (tiruan). Data uji (id 7xxx): prodi 71 (dalam cakupan) dan 72 (luar);
|
||||
* mahasiswa 7201 (lulus, angkatan 2019), 7202 (aktif, 2020), 7203 (keluar, 2020, tanpa dosen), 7204 (prodi 72),
|
||||
* 7205 (lulus, 2019, tanggal mulai rusak, tanpa rekap evaluasi).
|
||||
*/
|
||||
class TugasAkhirReportsTest extends TestCase
|
||||
{
|
||||
use FakesLegacyDatabase;
|
||||
use RefreshDatabase;
|
||||
|
||||
private const array IMPLEMENTED = [
|
||||
'repp_skripsi', 'repp_mhsskripsi', 'repp_totalmhsskripsi', 'repp_bimbinganta', 'repp_nilaiujiskripsi',
|
||||
'repp_beritaacarata', 'repp_skpembimbingta', 'repp_skpengujita', 'repp_rekappembimbingta', 'repp_distgsakhir',
|
||||
'repp_daftarwisuda', 'repp_yudisium', 'repp_bukuwisuda',
|
||||
];
|
||||
|
||||
private TugasAkhirReports $reports;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->useLegacyDatabase();
|
||||
$this->seedThesisData();
|
||||
$this->reports = app(TugasAkhirReports::class);
|
||||
}
|
||||
|
||||
private function seedThesisData(): void
|
||||
{
|
||||
$db = DB::connection('untan');
|
||||
foreach (['tmplahir' => fn (Blueprint $t) => $t->string('tmplahir')->nullable(), 'tgllahir' => fn (Blueprint $t) => $t->date('tgllahir')->nullable()] as $column => $add) {
|
||||
if (! Schema::connection('untan')->hasColumn('t_mahasiswa', $column)) {
|
||||
Schema::connection('untan')->table('t_mahasiswa', fn (Blueprint $t) => $add($t));
|
||||
}
|
||||
}
|
||||
|
||||
$db->table('t_bagian')->insert([
|
||||
['idbagian' => 71, 'idbagian_induk' => 5, 'idjenisbagian' => 3, 'namabagian' => 'Prodi Uji A'],
|
||||
['idbagian' => 72, 'idbagian_induk' => 5, 'idjenisbagian' => 3, 'namabagian' => 'Prodi Uji B'],
|
||||
]);
|
||||
$db->table('t_angkatanmhs')->insert([['idangkatan' => 7001, 'tahun' => 2019, 'semester' => 1], ['idangkatan' => 7002, 'tahun' => 2020, 'semester' => 1]]);
|
||||
$db->table('t_pegawai')->insert([
|
||||
['idpegawai' => 7101, 'nip' => '1980', 'nama' => 'Andi Pembimbing', 'gelardepan' => 'Dr.', 'gelarbelakang' => 'M.T.'],
|
||||
['idpegawai' => 7102, 'nip' => '1981', 'nama' => 'Budi Penguji', 'gelardepan' => '', 'gelarbelakang' => ''],
|
||||
['idpegawai' => 7103, 'nip' => 'Admin', 'nama' => 'Admin', 'gelardepan' => '', 'gelarbelakang' => ''],
|
||||
]);
|
||||
$db->table('t_periodekuliah')->insert([
|
||||
['idperiode' => 7301, 'thakad' => '2022/2023', 'semester' => 1, 'perkuliahan' => 1],
|
||||
['idperiode' => 7302, 'thakad' => '2022/2023', 'semester' => 2, 'perkuliahan' => 1],
|
||||
]);
|
||||
$db->table('t_periodekuliahaktif')->insert(['idprogdi' => 71, 'idperiode' => 7302]);
|
||||
|
||||
$student = fn (int $id, string $nim, string $nama, int $prodi, int $angkatan, int $status, ?int $wisuda = null, array $extra = []): array => [
|
||||
'idmahasiswa' => $id, 'nim' => $nim, 'nama' => $nama, 'idprogdi' => $prodi, 'idangkatan' => $angkatan, 'stataktif' => $status, 'idperiodewisuda' => $wisuda,
|
||||
] + $extra;
|
||||
foreach ([
|
||||
$student(7201, 'T71001', 'Ani Satu', 71, 7001, 2, 7401, ['tmplahir' => 'Pontianak', 'tgllahir' => '2000-05-17', 'nmr_ijazah' => 'IJ-7201', 'nmr_skdekan' => 'SK/7201', 'tgl_skdekan' => '2023-03-30', 'tgl_lulus' => '2023-03-31']),
|
||||
$student(7202, 'T71002', 'Budi Dua', 71, 7002, 1),
|
||||
$student(7203, 'T71003', 'Cici Tiga', 71, 7002, 3),
|
||||
$student(7204, 'T72001', 'Dedi Luar', 72, 7001, 2, 7402),
|
||||
$student(7205, 'T71005', 'Eko Lima', 71, 7001, 2, 7401),
|
||||
] as $row) {
|
||||
$db->table('t_mahasiswa')->insert($row);
|
||||
}
|
||||
$db->table('t_skripsi')->insert([
|
||||
['idmahasiswa' => 7201, 'judul' => 'Judul Ani', 'pembimbing1' => 7101, 'pembimbing2' => 7103, 'penguji1' => 7102, 'penguji2' => null, 'tglmulai' => '2022-09-01', 'tgllulus' => '2023-03-15'],
|
||||
['idmahasiswa' => 7202, 'judul' => 'Judul Budi', 'pembimbing1' => 7101, 'pembimbing2' => null, 'penguji1' => null, 'penguji2' => null, 'tglmulai' => '2023-03-01', 'tgllulus' => null],
|
||||
['idmahasiswa' => 7203, 'judul' => null, 'pembimbing1' => null, 'pembimbing2' => null, 'penguji1' => null, 'penguji2' => null, 'tglmulai' => '2023-04-01', 'tgllulus' => null],
|
||||
['idmahasiswa' => 7204, 'judul' => 'Judul Dedi', 'pembimbing1' => 7101, 'pembimbing2' => null, 'penguji1' => 7102, 'penguji2' => null, 'tglmulai' => '2022-09-05', 'tgllulus' => '2023-03-20'],
|
||||
['idmahasiswa' => 7205, 'judul' => 'Judul Eko', 'pembimbing1' => 7102, 'pembimbing2' => null, 'penguji1' => 7101, 'penguji2' => null, 'tglmulai' => '0001-01-01', 'tgllulus' => '2023-03-16'],
|
||||
]);
|
||||
|
||||
$db->table('t_matakuliah')->insert([
|
||||
['idmatakuliah' => 7501, 'kodemk' => 'SK1', 'namamk' => 'Skripsi', 'sks' => 6, 'tipe' => 2],
|
||||
['idmatakuliah' => 7502, 'kodemk' => 'MK2', 'namamk' => 'Biasa', 'sks' => 3, 'tipe' => 0],
|
||||
]);
|
||||
$kst = fn (int $mhs, int $mk, int $periode, int $stat, ?string $huruf, ?float $total, ?float $mutu): array => [
|
||||
'idmahasiswa' => $mhs, 'idjadwal' => 1, 'idmatakuliah' => $mk, 'idperiode' => $periode, 'stat' => $stat, 'nilaihuruf' => $huruf, 'nilaitotal' => $total, 'nilaimutu' => $mutu,
|
||||
];
|
||||
$db->table('t_kst')->insert([
|
||||
$kst(7201, 7501, 7302, 1, 'A', 85, 4),
|
||||
$kst(7202, 7501, 7302, 3, null, null, null),
|
||||
$kst(7203, 7501, 7302, 0, null, null, null),
|
||||
$kst(7204, 7501, 7302, 1, 'B', 70, 3),
|
||||
$kst(7201, 7502, 7302, 1, 'A', 90, 4),
|
||||
$kst(7201, 7501, 7301, 1, 'B', 72, 3),
|
||||
]);
|
||||
|
||||
$db->table('t_periodewisuda')->insert([
|
||||
['idperiode' => 7401, 'kdperiode' => '20223', 'namaperiode' => '2022/2023 Periode III', 'tgl_wisuda' => '2023-04-01'],
|
||||
['idperiode' => 7402, 'kdperiode' => '20224', 'namaperiode' => '2022/2023 Periode IV', 'tgl_wisuda' => null],
|
||||
]);
|
||||
$db->table('t_evaluasi_rekap')->insert([
|
||||
['idmahasiswa' => 7201, 'jmlsks' => 144, 'jmlmutusks' => 500],
|
||||
['idmahasiswa' => 7204, 'jmlsks' => 100, 'jmlmutusks' => 390],
|
||||
]);
|
||||
$db->table('t_predikatkelulusan')->insert([
|
||||
['idpredikat' => 902, 'ipkmin' => 3.51, 'ipkmax' => 4, 'predikat' => 'Dengan Pujian'],
|
||||
['idpredikat' => 903, 'ipkmin' => 3.01, 'ipkmax' => 3.5, 'predikat' => 'Sangat Memuaskan'],
|
||||
]);
|
||||
}
|
||||
|
||||
private function context(array $prodi = [71]): ReportContext
|
||||
{
|
||||
$names = DB::connection('untan')->table('t_bagian')->whereIn('idbagian', $prodi)->pluck('namabagian', 'idbagian')->all();
|
||||
|
||||
return new ReportContext(1, 'staf', $prodi, $names);
|
||||
}
|
||||
|
||||
private function report(string $slug, array $params = [], ?ReportContext $context = null, int $limit = 100): ReportResult
|
||||
{
|
||||
return $this->reports->run($slug, $params, $context ?? $this->context(), $limit);
|
||||
}
|
||||
|
||||
/** @return list<string|null> */
|
||||
private function column(ReportResult $result, string $key): array
|
||||
{
|
||||
return array_column($result->rows, $key);
|
||||
}
|
||||
|
||||
private function keys(ReportResult $result): array
|
||||
{
|
||||
return array_column($result->columns, 'key');
|
||||
}
|
||||
|
||||
public function test_slugs_hanya_yang_bersumber(): void
|
||||
{
|
||||
$this->assertSame(self::IMPLEMENTED, $this->reports->slugs());
|
||||
foreach (['repp_proposalskripsi', 'repp_jadwalujita', 'repp_beritaacaraajuta', 'repp_nilaiproposalta', 'repp_monitoringsyaratta', 'repp_monitoringproporsalta'] as $slug) {
|
||||
$this->assertNotContains($slug, $this->reports->slugs());
|
||||
}
|
||||
}
|
||||
|
||||
public function test_definisi_valid(): void
|
||||
{
|
||||
foreach ($this->reports->slugs() as $slug) {
|
||||
$params = $this->reports->definition($slug, $this->context())['params'];
|
||||
$names = array_column($params, 'name');
|
||||
$this->assertSame($names, array_values(array_unique($names)), $slug);
|
||||
$this->assertEmpty(array_intersect($names, ['tampil', 'kop']), $slug);
|
||||
foreach ($params as $param) {
|
||||
$this->assertContains($param['type'], ['select', 'text', 'number', 'date', 'check'], $slug);
|
||||
if ($param['type'] === 'select') {
|
||||
$this->assertIsArray($param['options'], $slug);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function test_opsi_dan_parameter_wajib(): void
|
||||
{
|
||||
$skripsi = collect($this->reports->definition('repp_skripsi', $this->context())['params'])->keyBy('name');
|
||||
$this->assertSame([71 => 'Prodi Uji A'], $skripsi['prodi']['options']);
|
||||
$this->assertSame([2020 => '2020', 2019 => '2019'], $skripsi['angkatan']['options']);
|
||||
$this->assertSame([7302 => '2022/2023 Genap', 7301 => '2022/2023 Ganjil'], $skripsi['periode']['options']);
|
||||
|
||||
$total = collect($this->reports->definition('repp_totalmhsskripsi', $this->context())['params'])->keyBy('name');
|
||||
$this->assertTrue($total['periode']['required']);
|
||||
$this->assertSame(7302, $total['periode']['default']);
|
||||
|
||||
$buku = collect($this->reports->definition('repp_bukuwisuda', $this->context())['params'])->keyBy('name');
|
||||
$this->assertTrue($buku['prodi']['required'] && $buku['periode_wisuda']['required']);
|
||||
$this->assertSame([7401 => '20223 (2022/2023 Periode III)'], $buku['periode_wisuda']['options']);
|
||||
|
||||
$dist = collect($this->reports->definition('repp_distgsakhir', $this->context())['params'])->keyBy('name');
|
||||
$this->assertTrue($dist['tgl_awal']['required'] && $dist['tgl_akhir']['required']);
|
||||
}
|
||||
|
||||
public function test_skripsi_daftar_dan_cakupan_prodi(): void
|
||||
{
|
||||
$result = $this->report('repp_skripsi');
|
||||
|
||||
$this->assertSame(['nim', 'nama', 'prodi', 'angkatan', 'judul', 'pembimbing1', 'pembimbing2', 'penguji1', 'penguji2', 'mulai', 'lulus_ujian', 'tahap', 'status'], $this->keys($result));
|
||||
$this->assertEqualsCanonicalizing(['T71001', 'T71002', 'T71003', 'T71005'], $this->column($result, 'nim'));
|
||||
$this->assertNull($result->total);
|
||||
|
||||
$ani = collect($result->rows)->firstWhere('nim', 'T71001');
|
||||
$this->assertSame('Prodi Uji A', $ani['prodi']);
|
||||
$this->assertSame(2019, $ani['angkatan']);
|
||||
$this->assertSame('Judul Ani', $ani['judul']);
|
||||
$this->assertSame('Dr. Andi Pembimbing, M.T.', $ani['pembimbing1']);
|
||||
$this->assertNull($ani['pembimbing2'], 'akun Admin bukan dosen');
|
||||
$this->assertSame('Budi Penguji', $ani['penguji1']);
|
||||
$this->assertSame('01-09-2022', $ani['mulai']);
|
||||
$this->assertSame('15-03-2023', $ani['lulus_ujian']);
|
||||
$this->assertSame('Lulus Ujian', $ani['tahap']);
|
||||
$this->assertSame('Lulus', $ani['status']);
|
||||
|
||||
$eko = collect($result->rows)->firstWhere('nim', 'T71005');
|
||||
$this->assertNull($eko['mulai'], 'tanggal rusak dianggap tidak tercatat');
|
||||
$this->assertSame('Keluar', collect($result->rows)->firstWhere('nim', 'T71003')['status']);
|
||||
}
|
||||
|
||||
public function test_skripsi_filter(): void
|
||||
{
|
||||
$this->assertEqualsCanonicalizing(['T71002', 'T71003'], $this->column($this->report('repp_skripsi', ['angkatan' => 2020]), 'nim'));
|
||||
$this->assertEqualsCanonicalizing(['T71001', 'T71005'], $this->column($this->report('repp_skripsi', ['status' => 'lulus']), 'nim'));
|
||||
$this->assertSame(['T71002'], $this->column($this->report('repp_skripsi', ['status' => 'aktif']), 'nim'));
|
||||
$this->assertSame(['T71003'], $this->column($this->report('repp_skripsi', ['status' => 'keluar']), 'nim'));
|
||||
$this->assertEqualsCanonicalizing(['T71001', 'T71005'], $this->column($this->report('repp_skripsi', ['tahap' => 'ujian']), 'nim'));
|
||||
$this->assertEqualsCanonicalizing(['T71002', 'T71003'], $this->column($this->report('repp_skripsi', ['periode' => 7302]), 'nim'));
|
||||
$this->assertSame(['T71001'], $this->column($this->report('repp_skripsi', ['periode' => 7301]), 'nim'));
|
||||
$this->assertSame(['T71002'], $this->column($this->report('repp_skripsi', ['mahasiswa' => 'budi']), 'nim'));
|
||||
$this->assertSame([], $this->report('repp_skripsi', ['prodi' => 72])->rows, 'prodi di luar cakupan tidak muncul');
|
||||
}
|
||||
|
||||
public function test_skripsi_limit_dan_total(): void
|
||||
{
|
||||
$result = $this->report('repp_skripsi', [], null, 2);
|
||||
|
||||
$this->assertCount(2, $result->rows);
|
||||
$this->assertSame(4, $result->total);
|
||||
$this->assertTrue($result->truncated());
|
||||
$this->assertContains('Jumlah: 4 tugas akhir', $result->summary);
|
||||
}
|
||||
|
||||
public function test_rekap_mahasiswa_tugas_akhir(): void
|
||||
{
|
||||
$result = $this->report('repp_mhsskripsi');
|
||||
|
||||
$this->assertSame(['prodi', 'angkatan', 'jumlah', 'bimbingan', 'ujian'], $this->keys($result));
|
||||
$this->assertSame([
|
||||
['prodi' => 'Prodi Uji A', 'angkatan' => 2020, 'jumlah' => 2, 'bimbingan' => 2, 'ujian' => 0],
|
||||
['prodi' => 'Prodi Uji A', 'angkatan' => 2019, 'jumlah' => 2, 'bimbingan' => 0, 'ujian' => 2],
|
||||
], $result->rows);
|
||||
|
||||
$genap = $this->report('repp_mhsskripsi', ['periode' => 7302]);
|
||||
$this->assertSame([2020], $this->column($genap, 'angkatan'));
|
||||
$this->assertSame([2], $this->column($genap, 'jumlah'));
|
||||
|
||||
$both = $this->report('repp_mhsskripsi', [], $this->context([71, 72]));
|
||||
$this->assertContains('Prodi Uji B', $this->column($both, 'prodi'));
|
||||
}
|
||||
|
||||
public function test_jumlah_mahasiswa_tugas_akhir_dari_krs(): void
|
||||
{
|
||||
$result = $this->report('repp_totalmhsskripsi', ['periode' => 7302]);
|
||||
|
||||
$this->assertSame(['prodi', 'peserta', 'bernilai', 'belum'], $this->keys($result));
|
||||
$this->assertSame([['prodi' => 'Prodi Uji A', 'peserta' => 2, 'bernilai' => 1, 'belum' => 1]], $result->rows);
|
||||
$this->assertContains('Periode: 2022/2023 Genap', $result->summary);
|
||||
|
||||
$both = $this->report('repp_totalmhsskripsi', ['periode' => 7302], $this->context([71, 72]));
|
||||
$this->assertSame(['Prodi Uji A', 'Prodi Uji B'], $this->column($both, 'prodi'));
|
||||
$this->assertSame([], $this->report('repp_totalmhsskripsi')->rows, 'periode wajib');
|
||||
}
|
||||
|
||||
public function test_bimbingan_tugas_akhir(): void
|
||||
{
|
||||
$result = $this->report('repp_bimbinganta', ['prodi' => 71]);
|
||||
|
||||
$this->assertCount(4, $result->rows);
|
||||
$ani = collect($result->rows)->firstWhere('nim', 'T71001');
|
||||
$this->assertSame('Dr. Andi Pembimbing, M.T. (1980)', $ani['pembimbing1']);
|
||||
$this->assertNull($ani['pembimbing2']);
|
||||
$this->assertSame(['T71002'], $this->column($this->report('repp_bimbinganta', ['prodi' => 71, 'status' => 'aktif']), 'nim'));
|
||||
$this->assertSame([], $this->report('repp_bimbinganta', ['prodi' => 72])->rows);
|
||||
}
|
||||
|
||||
public function test_nilai_tugas_akhir_dari_krs(): void
|
||||
{
|
||||
$result = $this->report('repp_nilaiujiskripsi', ['periode' => 7302]);
|
||||
|
||||
$this->assertEqualsCanonicalizing(['T71001', 'T71002'], $this->column($result, 'nim'));
|
||||
$ani = collect($result->rows)->firstWhere('nim', 'T71001');
|
||||
$this->assertSame('SK1 Skripsi', $ani['matakuliah']);
|
||||
$this->assertSame('A', $ani['nilai_huruf']);
|
||||
$this->assertSame(85.0, (float) $ani['nilai_angka']);
|
||||
$this->assertSame(4.0, (float) $ani['mutu']);
|
||||
$this->assertSame('Budi Penguji', $ani['penguji1']);
|
||||
$this->assertNull(collect($result->rows)->firstWhere('nim', 'T71002')['nilai_huruf']);
|
||||
|
||||
$this->assertSame(['T71001'], $this->column($this->report('repp_nilaiujiskripsi', ['periode' => 7301]), 'nim'));
|
||||
$this->assertSame(['T71002'], $this->column($this->report('repp_nilaiujiskripsi', ['periode' => 7302, 'angkatan' => 2020]), 'nim'));
|
||||
}
|
||||
|
||||
public function test_berita_acara_ujian(): void
|
||||
{
|
||||
$result = $this->report('repp_beritaacarata');
|
||||
|
||||
$this->assertSame(['T71005', 'T71001'], $this->column($result, 'nim'), 'terbaru dulu; prodi lain tidak muncul');
|
||||
$ani = collect($result->rows)->firstWhere('nim', 'T71001');
|
||||
$this->assertSame('15-03-2023', $ani['tgl_ujian']);
|
||||
$this->assertSame('Dr. Andi Pembimbing, M.T.', $ani['pembimbing']);
|
||||
$this->assertSame('Budi Penguji', $ani['penguji']);
|
||||
$this->assertSame('A', $ani['nilai'], 'nilai terbaik dari KRS tugas akhir');
|
||||
|
||||
$this->assertSame(['T71005'], $this->column($this->report('repp_beritaacarata', ['tgl_awal' => '2023-03-16']), 'nim'));
|
||||
$this->assertSame(['T71001'], $this->column($this->report('repp_beritaacarata', ['tgl_akhir' => '2023-03-15']), 'nim'));
|
||||
|
||||
$this->expectException(PortalException::class);
|
||||
$this->report('repp_beritaacarata', ['tgl_awal' => '2023-04-01', 'tgl_akhir' => '2023-03-01']);
|
||||
}
|
||||
|
||||
public function test_sk_pembimbing_dan_penguji(): void
|
||||
{
|
||||
$pembimbing = $this->report('repp_skpembimbingta');
|
||||
$this->assertEqualsCanonicalizing(['T71001', 'T71002', 'T71005'], $this->column($pembimbing, 'nim'));
|
||||
$this->assertSame(['nim', 'nama', 'prodi', 'angkatan', 'judul', 'tanggal', 'dosen1', 'dosen2'], $this->keys($pembimbing));
|
||||
$this->assertSame(['T71002'], $this->column($this->report('repp_skpembimbingta', ['periode' => 7302]), 'nim'));
|
||||
$this->assertSame(['T71001'], $this->column($this->report('repp_skpembimbingta', ['mahasiswa' => 'ani']), 'nim'));
|
||||
|
||||
$penguji = $this->report('repp_skpengujita');
|
||||
$this->assertEqualsCanonicalizing(['T71001', 'T71005'], $this->column($penguji, 'nim'));
|
||||
$ani = collect($penguji->rows)->firstWhere('nim', 'T71001');
|
||||
$this->assertSame('15-03-2023', $ani['tanggal']);
|
||||
$this->assertSame('Budi Penguji (1981)', $ani['dosen1']);
|
||||
$this->assertEqualsCanonicalizing(['T71001', 'T71005'], $this->column($this->report('repp_skpengujita', ['periode' => 7302]), 'nim'));
|
||||
$this->assertSame([], $this->report('repp_skpengujita', ['periode' => 7301])->rows);
|
||||
}
|
||||
|
||||
public function test_rekap_pembimbing(): void
|
||||
{
|
||||
$result = $this->report('repp_rekappembimbingta');
|
||||
|
||||
$this->assertSame(['nip', 'dosen', 'pb1', 'pb2', 'total', 'aktif', 'lulus'], $this->keys($result));
|
||||
$this->assertSame([
|
||||
['nip' => '1980', 'dosen' => 'Dr. Andi Pembimbing, M.T.', 'pb1' => 2, 'pb2' => 0, 'total' => 2, 'aktif' => 1, 'lulus' => 1],
|
||||
['nip' => '1981', 'dosen' => 'Budi Penguji', 'pb1' => 1, 'pb2' => 0, 'total' => 1, 'aktif' => 0, 'lulus' => 1],
|
||||
], $result->rows, 'mahasiswa prodi lain dan akun Admin tidak dihitung');
|
||||
|
||||
$this->assertSame(['1980'], $this->column($this->report('repp_rekappembimbingta', ['mahasiswa' => 'budi']), 'nip'));
|
||||
$this->assertSame([], $this->report('repp_rekappembimbingta', [], $this->context([]))->rows);
|
||||
}
|
||||
|
||||
public function test_distribusi_dosen(): void
|
||||
{
|
||||
$result = $this->report('repp_distgsakhir', ['tgl_awal' => '2022-08-01', 'tgl_akhir' => '2023-12-31']);
|
||||
|
||||
$this->assertSame(['nip', 'dosen', 'pb1', 'pb2', 'pj1', 'pj2', 'total'], $this->keys($result));
|
||||
$this->assertSame([
|
||||
['nip' => '1980', 'dosen' => 'Dr. Andi Pembimbing, M.T.', 'pb1' => 2, 'pb2' => 0, 'pj1' => 0, 'pj2' => 0, 'total' => 2],
|
||||
['nip' => '1981', 'dosen' => 'Budi Penguji', 'pb1' => 0, 'pb2' => 0, 'pj1' => 1, 'pj2' => 0, 'total' => 1],
|
||||
], $result->rows);
|
||||
|
||||
$this->assertSame(['1980'], $this->column($this->report('repp_distgsakhir', ['tgl_awal' => '2023-03-01', 'tgl_akhir' => '2023-12-31']), 'nip'));
|
||||
$this->assertSame(['1981'], $this->column($this->report('repp_distgsakhir', ['tgl_awal' => '2022-08-01', 'tgl_akhir' => '2023-12-31', 'dosen' => 'budi']), 'nip'));
|
||||
$this->assertSame([], $this->report('repp_distgsakhir', ['tgl_awal' => '2022-08-01', 'tgl_akhir' => '2023-12-31', 'status' => 'keluar'])->rows);
|
||||
}
|
||||
|
||||
public function test_daftar_wisuda(): void
|
||||
{
|
||||
$result = $this->report('repp_daftarwisuda', ['periode_wisuda' => 7401]);
|
||||
|
||||
$this->assertSame(['T71001', 'T71005'], $this->column($result, 'nim'), 'lulusan prodi lain tidak muncul');
|
||||
$ani = $result->rows[0];
|
||||
$this->assertSame('20223 (2022/2023 Periode III)', $ani['periode']);
|
||||
$this->assertSame('01-04-2023', $ani['tgl_wisuda']);
|
||||
$this->assertSame(3.47, $ani['ipk']);
|
||||
$this->assertSame('Sangat Memuaskan', $ani['predikat']);
|
||||
$this->assertSame('IJ-7201', $ani['ijazah']);
|
||||
$this->assertNull($result->rows[1]['ipk'], 'tanpa rekap evaluasi');
|
||||
$this->assertNull($result->rows[1]['predikat']);
|
||||
|
||||
$this->assertSame([], $this->report('repp_daftarwisuda', ['periode_wisuda' => 7402])->rows);
|
||||
$this->assertSame([], $this->report('repp_daftarwisuda')->rows, 'periode wajib');
|
||||
$this->assertContains('Jumlah: 2 lulusan', $result->summary);
|
||||
}
|
||||
|
||||
public function test_yudisium(): void
|
||||
{
|
||||
$result = $this->report('repp_yudisium', ['periode_wisuda' => 7401]);
|
||||
|
||||
$this->assertSame(['nim', 'nama', 'prodi', 'angkatan', 'periode', 'tgl_lulus', 'sk', 'tgl_sk', 'sks', 'ipk', 'predikat'], $this->keys($result));
|
||||
$ani = $result->rows[0];
|
||||
$this->assertSame('31-03-2023', $ani['tgl_lulus']);
|
||||
$this->assertSame('SK/7201', $ani['sk']);
|
||||
$this->assertSame('30-03-2023', $ani['tgl_sk']);
|
||||
$this->assertSame(144, $ani['sks']);
|
||||
$this->assertSame(3.47, $ani['ipk']);
|
||||
$this->assertNull($result->rows[1]['sks']);
|
||||
|
||||
$this->assertSame([], $this->report('repp_yudisium', ['periode_wisuda' => 7401, 'angkatan' => 2020])->rows);
|
||||
$this->assertSame(['T71005'], $this->column($this->report('repp_yudisium', ['periode_wisuda' => 7401, 'mahasiswa' => 'eko']), 'nim'));
|
||||
}
|
||||
|
||||
public function test_buku_wisuda(): void
|
||||
{
|
||||
$result = $this->report('repp_bukuwisuda', ['periode_wisuda' => 7401, 'prodi' => 71]);
|
||||
|
||||
$this->assertSame(['T71001', 'T71005'], $this->column($result, 'nim'));
|
||||
$ani = $result->rows[0];
|
||||
$this->assertSame('Pontianak, 17-05-2000', $ani['ttl']);
|
||||
$this->assertSame(3.47, $ani['ipk']);
|
||||
$this->assertSame('Judul Ani', $ani['judul']);
|
||||
$this->assertSame('15-03-2023', $ani['tgl_ujian']);
|
||||
$this->assertNull($result->rows[1]['ttl']);
|
||||
|
||||
$this->assertSame([], $this->report('repp_bukuwisuda', ['periode_wisuda' => 7401, 'prodi' => 72])->rows, 'prodi di luar cakupan');
|
||||
$this->assertContains('Program studi: Prodi Uji A', $result->summary);
|
||||
}
|
||||
|
||||
public function test_prodi_kosong_menghasilkan_hasil_kosong(): void
|
||||
{
|
||||
$empty = $this->context([]);
|
||||
$params = ['periode' => 7302, 'periode_wisuda' => 7401, 'prodi' => 71, 'tgl_awal' => '2022-01-01', 'tgl_akhir' => '2023-12-31'];
|
||||
|
||||
foreach ($this->reports->slugs() as $slug) {
|
||||
$result = $this->report($slug, $params, $empty);
|
||||
$this->assertSame([], $result->rows, $slug);
|
||||
$this->assertNotEmpty($result->columns, $slug);
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
-27
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Operator;
|
||||
namespace Tests\Feature\Superuser;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
@@ -10,8 +10,8 @@ use Tests\Concerns\FakesLegacyDatabase;
|
||||
use Tests\Concerns\InspectsHtml;
|
||||
use Tests\TestCase;
|
||||
|
||||
/** Setting > Periode Akademik dari DB lama: daftar t_periodekuliah (aktif hanya periode aktif prodi akun), tambah, ubah, hapus. */
|
||||
class LegacyPeriodeTest extends TestCase
|
||||
/** Periode Akademik (hanya Superuser) dari DB lama: daftar t_periodekuliah (aktif = aktif di setidaknya satu prodi), tambah, ubah, hapus. */
|
||||
class LegacyPeriodeAkademikTest extends TestCase
|
||||
{
|
||||
use FakesLegacyDatabase;
|
||||
use InspectsHtml;
|
||||
@@ -25,8 +25,8 @@ class LegacyPeriodeTest extends TestCase
|
||||
$this->seedLegacyOverview();
|
||||
DB::connection('untan')->table('t_periodekuliah')->where('idperiode', 371)->update(['mulai' => '2021-02-01', 'selesai' => '2021-07-31']);
|
||||
DB::connection('untan')->table('t_angkatanmhs')->insert(['idangkatan' => 990, 'tahun' => 2024, 'semester' => 1]);
|
||||
$this->post(route('login.store'), ['username' => '198001012005011001', 'password' => 'rahasia-staf'])
|
||||
->assertRedirect(route('operator.dashboard'));
|
||||
$this->post(route('login.store'), ['username' => '197001011995011001', 'password' => 'rahasia-super'])
|
||||
->assertRedirect(route('superuser.dashboard'));
|
||||
}
|
||||
|
||||
private function rows(array $json): array
|
||||
@@ -36,7 +36,7 @@ class LegacyPeriodeTest extends TestCase
|
||||
|
||||
public function test_daftar_periode_dan_status_aktif(): void
|
||||
{
|
||||
$page = $this->get(route('operator.halaman', 'list_periode'))->assertOk()->assertSee('Periode akademik asli')->assertSee('satuPeriode')
|
||||
$page = $this->get(route('superuser.periode'))->assertOk()->assertSee('Periode akademik asli')->assertSee('satuPeriode')
|
||||
->assertSee('Tambah periode akademik')->assertSee('Hapus periode akademik?');
|
||||
$this->assertSame(['Kode', 'Nama Periode', 'Tgl. Awal Kuliah', 'Tgl. Akhir Kuliah', 'Tgl. Awal UTS', 'Tgl. Awal UAS', 'Aktif?', 'Aksi'], array_map(fn ($th): string => $this->textOf($th), iterator_to_array($this->dom($page)->query("//*[@aria-label='Daftar Periode Akademik']//thead/tr/th"))));
|
||||
$this->assertSame(1, $this->dom($page)->query("//dialog[@class='dialog']//form//select[@name='semester']")->length, 'Formulir ada di modal.');
|
||||
@@ -46,66 +46,83 @@ class LegacyPeriodeTest extends TestCase
|
||||
['20201', '2020/2021 Ganjil', '–', '–', 'Ya'],
|
||||
['20193', '2019/2020 Genap (pendek)', '–', '–', 'Tidak'],
|
||||
['20192', '2019/2020 Genap', '–', '–', 'Tidak'],
|
||||
], $this->rows($this->getJson(route('operator.periode.data'))->assertOk()->json()), 'Hanya periode aktif prodi akun (368) yang Ya.');
|
||||
], $this->rows($this->getJson(route('superuser.periode.data'))->assertOk()->json()), 'Ya = periode aktif di setidaknya satu prodi.');
|
||||
}
|
||||
|
||||
public function test_tambah_ubah_hapus(): void
|
||||
{
|
||||
$db = DB::connection('untan');
|
||||
|
||||
$created = $this->postJson(route('operator.periode.store'), ['thakad' => '2024/2025', 'semester' => 1, 'perkuliahan' => 1, 'mulai' => '2024-08-01', 'selesai' => '2025-01-31'])
|
||||
$created = $this->postJson(route('superuser.periode.store'), ['thakad' => '2024/2025', 'semester' => 1, 'perkuliahan' => 1, 'mulai' => '2024-08-01', 'selesai' => '2025-01-31'])
|
||||
->assertCreated()->assertJsonPath('message', 'Periode akademik ditambahkan.');
|
||||
$id = $created->json('id');
|
||||
$this->assertSame(['20241', '2024/2025 Ganjil', '1 Agt 2024', '31 Jan 2025', 'Tidak'], $this->rows($created->json())[0]);
|
||||
$row = (array) $db->table('t_periodekuliah')->where('idperiode', $id)->first();
|
||||
$this->assertSame(['2024/2025', 1, 1, '2024-08-01', '2025-01-31', '20241', '2024', 990, 'SIAKAD', '198001012005011'], [
|
||||
$this->assertSame(['2024/2025', 1, 1, '2024-08-01', '2025-01-31', '20241', '2024', 990, 'SIAKAD', '197001011995011'], [
|
||||
trim($row['thakad']), (int) $row['semester'], (int) $row['perkuliahan'], $row['mulai'], $row['selesai'], $row['periode_dikti'], $row['periode_anggaran'], (int) $row['idangkatan'], $row['cname'], $row['uname'],
|
||||
], 'Kolom turunan dan audit diisi seperti aplikasi lama.');
|
||||
|
||||
$this->postJson(route('operator.periode.store'), ['thakad' => '2024/2025', 'semester' => 1, 'perkuliahan' => 1])
|
||||
$this->postJson(route('superuser.periode.store'), ['thakad' => '2024/2025', 'semester' => 1, 'perkuliahan' => 1])
|
||||
->assertStatus(422)->assertJsonPath('message', 'Periode 2024/2025 Ganjil sudah ada.');
|
||||
$this->postJson(route('operator.periode.store'), ['thakad' => '2024/2026', 'semester' => 1, 'perkuliahan' => 1])
|
||||
$this->postJson(route('superuser.periode.store'), ['thakad' => '2024/2026', 'semester' => 1, 'perkuliahan' => 1])
|
||||
->assertStatus(422)->assertJsonPath('message', 'Tahun akademik harus berformat TTTT/TTTT dengan tahun berurutan, misalnya 2025/2026.');
|
||||
$this->postJson(route('operator.periode.store'), ['thakad' => '2024/2025', 'semester' => 2, 'perkuliahan' => 2, 'mulai' => '2025-03-01', 'selesai' => '2025-02-01'])
|
||||
$this->postJson(route('superuser.periode.store'), ['thakad' => '2024/2025', 'semester' => 2, 'perkuliahan' => 2, 'mulai' => '2025-03-01', 'selesai' => '2025-02-01'])
|
||||
->assertStatus(422)->assertJsonValidationErrors(['selesai']);
|
||||
$this->postJson(route('operator.periode.store'), ['thakad' => 'abc', 'semester' => 3, 'perkuliahan' => 1])
|
||||
$this->postJson(route('superuser.periode.store'), ['thakad' => 'abc', 'semester' => 3, 'perkuliahan' => 1])
|
||||
->assertStatus(422)->assertJsonValidationErrors(['thakad', 'semester']);
|
||||
|
||||
$pendek = $this->postJson(route('operator.periode.store'), ['thakad' => '2024/2025', 'semester' => 1, 'perkuliahan' => 2])->assertCreated()->json('id');
|
||||
$pendek = $this->postJson(route('superuser.periode.store'), ['thakad' => '2024/2025', 'semester' => 1, 'perkuliahan' => 2])->assertCreated()->json('id');
|
||||
$this->assertSame(['20243', null, null], array_values((array) $db->table('t_periodekuliah')->where('idperiode', $pendek)->first(['periode_dikti', 'periode_anggaran', 'idangkatan'])));
|
||||
|
||||
$this->putJson(route('operator.periode.update', $id), ['thakad' => '2024/2025', 'semester' => 1, 'perkuliahan' => 1, 'mulai' => '2024-08-05', 'selesai' => null])
|
||||
$this->putJson(route('superuser.periode.update', $id), ['thakad' => '2024/2025', 'semester' => 1, 'perkuliahan' => 1, 'mulai' => '2024-08-05', 'selesai' => null])
|
||||
->assertOk()->assertJsonPath('message', 'Periode akademik diperbarui.');
|
||||
$this->assertSame(['2024-08-05', null], array_values((array) $db->table('t_periodekuliah')->where('idperiode', $id)->first(['mulai', 'selesai'])));
|
||||
$this->putJson(route('operator.periode.update', $id), ['thakad' => '2025/2026', 'semester' => 2, 'perkuliahan' => 1])->assertOk();
|
||||
$this->putJson(route('superuser.periode.update', $id), ['thakad' => '2025/2026', 'semester' => 2, 'perkuliahan' => 1])->assertOk();
|
||||
$this->assertSame(['2025/2026', '20252', '2026'], array_map(fn ($v) => is_string($v) ? trim($v) : $v, array_values((array) $db->table('t_periodekuliah')->where('idperiode', $id)->first(['thakad', 'periode_dikti', 'periode_anggaran']))), 'Identitas boleh diubah selama belum dipakai; kolom turunan ikut.');
|
||||
|
||||
// 368 dipakai t_periodekuliahaktif dan jadwal: tahun tetap boleh diubah (rujukan memakai idperiode), hapus ditolak.
|
||||
$this->putJson(route('operator.periode.update', 368), ['thakad' => '2030/2031', 'semester' => 1, 'perkuliahan' => 1])->assertOk();
|
||||
$this->putJson(route('superuser.periode.update', 368), ['thakad' => '2030/2031', 'semester' => 1, 'perkuliahan' => 1])->assertOk();
|
||||
$this->assertSame('2030/2031', trim($db->table('t_periodekuliah')->where('idperiode', 368)->value('thakad')));
|
||||
$this->assertTrue($db->table('t_periodekuliahaktif')->where('idperiode', 368)->exists(), 'Rujukan tetap utuh setelah tahun diubah.');
|
||||
$this->putJson(route('operator.periode.update', 368), ['thakad' => '2020/2021', 'semester' => 1, 'perkuliahan' => 1, 'mulai' => '2020-08-03'])->assertOk();
|
||||
$this->deleteJson(route('operator.periode.destroy', 368))->assertStatus(422)->assertJsonPath('message', 'Periode 2020/2021 Ganjil sudah dipakai (t_periodekuliahaktif), sehingga tidak boleh dihapus.');
|
||||
$this->deleteJson(route('operator.periode.destroy', 999))->assertStatus(422)->assertJsonPath('message', 'Periode tidak ditemukan.');
|
||||
$this->putJson(route('superuser.periode.update', 368), ['thakad' => '2020/2021', 'semester' => 1, 'perkuliahan' => 1, 'mulai' => '2020-08-03'])->assertOk();
|
||||
$this->deleteJson(route('superuser.periode.destroy', 368))->assertStatus(422)->assertJsonPath('message', 'Periode 2020/2021 Ganjil sudah dipakai (t_periodekuliahaktif), sehingga tidak boleh dihapus.');
|
||||
$this->deleteJson(route('superuser.periode.destroy', 999))->assertStatus(422)->assertJsonPath('message', 'Periode tidak ditemukan.');
|
||||
|
||||
$deleted = $this->deleteJson(route('operator.periode.destroy', $pendek))->assertOk()->assertJsonPath('message', 'Periode akademik dihapus.');
|
||||
$deleted = $this->deleteJson(route('superuser.periode.destroy', $pendek))->assertOk()->assertJsonPath('message', 'Periode akademik dihapus.');
|
||||
$this->assertNull($db->table('t_periodekuliah')->where('idperiode', $pendek)->first());
|
||||
$this->assertCount(5, $deleted->json('rows'));
|
||||
}
|
||||
|
||||
public function test_menu_hanya_untuk_superuser_akun_lama(): void
|
||||
{
|
||||
$this->get(route('superuser.dashboard'))->assertOk()->assertSee(route('superuser.periode'))->assertSee('Periode akademik');
|
||||
|
||||
Auth::logout();
|
||||
$this->post(route('login.store'), ['username' => '198001012005011001', 'password' => 'rahasia-staf'])->assertRedirect(route('operator.dashboard'));
|
||||
$this->get(route('operator.dashboard'))->assertOk()->assertDontSee('Periode Akademik')->assertDontSee('list_periode');
|
||||
$this->get(route('operator.halaman', 'list_periode'))->assertNotFound();
|
||||
$this->get(route('superuser.periode'))->assertForbidden();
|
||||
$this->getJson(route('superuser.periode.data'))->assertForbidden();
|
||||
$this->postJson(route('superuser.periode.store'), ['thakad' => '2024/2025', 'semester' => 1, 'perkuliahan' => 1])->assertForbidden();
|
||||
$this->deleteJson(route('superuser.periode.destroy', 371))->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_akses(): void
|
||||
{
|
||||
Auth::logout();
|
||||
$this->post(route('login.store'), ['username' => 'D1041191001', 'password' => 'rahasia-mhs']);
|
||||
$this->getJson(route('operator.periode.data'))->assertForbidden();
|
||||
$this->postJson(route('operator.periode.store'), ['thakad' => '2024/2025', 'semester' => 1, 'perkuliahan' => 1])->assertForbidden();
|
||||
$this->getJson(route('superuser.periode.data'))->assertForbidden();
|
||||
$this->postJson(route('superuser.periode.store'), ['thakad' => '2024/2025', 'semester' => 1, 'perkuliahan' => 1])->assertForbidden();
|
||||
|
||||
// Superuser akun demo tidak memegang data asli: halaman, data, dan simpan 404, menu tidak menampilkannya
|
||||
Auth::logout();
|
||||
config(['auth.guards.web.provider' => 'users']);
|
||||
Auth::forgetGuards();
|
||||
$this->actingAs(User::factory()->operator()->create())->get(route('operator.halaman', 'list_periode'))->assertOk()->assertDontSee('satuPeriode');
|
||||
$this->getJson(route('operator.periode.data'))->assertNotFound();
|
||||
$this->postJson(route('operator.periode.store'), ['thakad' => '2024/2025', 'semester' => 1, 'perkuliahan' => 1])->assertNotFound();
|
||||
$this->deleteJson(route('operator.periode.destroy', 371))->assertNotFound();
|
||||
$this->actingAs(User::factory()->superuser()->create());
|
||||
$this->get(route('superuser.dashboard'))->assertOk()->assertDontSee(route('superuser.periode'));
|
||||
$this->get(route('superuser.periode'))->assertNotFound();
|
||||
$this->getJson(route('superuser.periode.data'))->assertNotFound();
|
||||
$this->postJson(route('superuser.periode.store'), ['thakad' => '2024/2025', 'semester' => 1, 'perkuliahan' => 1])->assertNotFound();
|
||||
$this->deleteJson(route('superuser.periode.destroy', 371))->assertNotFound();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user