auditionadmin/tests/Feature/app/Http/Controllers/Admin/LogViewerTest.php

25 lines
762 B
PHP

<?php
use App\Models\AuditLogEntry;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('denies access to a non-admin user', function () {
$this->get(route('admin.view_logs'))->assertRedirect(route('home'));
actAsNormal();
$this->get(route('admin.view_logs'))->assertRedirect(route('dashboard'));
actAsTab();
$this->get(route('admin.view_logs'))->assertRedirect(route('dashboard'));
});
it('lists log entries', function () {
actAsAdmin();
$logEntries = AuditLogEntry::all()->pluck('message');
$response = $this->get(route('admin.view_logs'))->assertOk()
->assertViewIs('admin.logview');
foreach ($logEntries as $logEntry) {
$response->assertSee($logEntry, false);
}
});