From e18fe3deb270cfa7112238654849f76af2388a6d Mon Sep 17 00:00:00 2001 From: Sari Date: Mon, 3 Aug 2026 09:01:47 +0700 Subject: [PATCH] laporan: tampilkan deskripsi pelanggaran di kolom jenis (web+PDF); TEST GUARD: blokir test bila DB bukan *_test (cegah RefreshDatabase menghancurkan produksi saat config ter-cache) --- .../reports/violation-report-pdf.blade.php | 7 +++++- resources/views/reports/violations.blade.php | 7 +++++- tests/TestCase.php | 22 ++++++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/resources/views/reports/violation-report-pdf.blade.php b/resources/views/reports/violation-report-pdf.blade.php index 77cfa4f..78571da 100644 --- a/resources/views/reports/violation-report-pdf.blade.php +++ b/resources/views/reports/violation-report-pdf.blade.php @@ -146,7 +146,12 @@ {{ $v->student?->nisn }} {{ $v->student?->full_name }} {{ $v->student?->class?->name }} - {{ $v->violationType?->name }} ({{ $v->violationType?->category?->name ?? '-' }}) + +
{{ $v->violationType?->name }} ({{ $v->violationType?->category?->name ?? '-' }})
+ @if ($v->description) +
{{ $v->description }}
+ @endif + {{ $v->points }} {{ $status }} diff --git a/resources/views/reports/violations.blade.php b/resources/views/reports/violations.blade.php index 1b34eaa..5f01f93 100644 --- a/resources/views/reports/violations.blade.php +++ b/resources/views/reports/violations.blade.php @@ -277,7 +277,12 @@ {{ $v->student?->class?->name }} - {{ $v->violationType?->name }} + +
{{ $v->violationType?->name }}
+ @if ($v->description) +
{{ $v->description }}
+ @endif + {{ $v->points }} diff --git a/tests/TestCase.php b/tests/TestCase.php index fe1ffc2..bf3734c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -3,8 +3,28 @@ namespace Tests; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; +use Illuminate\Support\Facades\DB; abstract class TestCase extends BaseTestCase { - // + /** + * Pengaman: pastikan test HANYA boleh jalan di database test. + * + * Jika konfigurasi ter-cache (config:cache) membuat test menunjuk ke + * database produksi, RefreshDatabase akan menghancurkan data asli — + * guard ini menghentikan suite sebelum itu terjadi. + */ + protected function setUp(): void + { + parent::setUp(); + + $dbName = config('database.connections.'.config('database.default').'.database'); + + if (! str_ends_with((string) $dbName, '_test')) { + throw new \RuntimeException( + "TEST DIBLOKIR: database aktif '{$dbName}' bukan database test (harus berakhiran _test). ". + 'Jalankan `php artisan config:clear` lalu ulangi test.' + ); + } + } }