Create tests for app/Models/AuditLogEntry
This commit is contained in:
parent
c309c23ca6
commit
8d76c9e66d
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\AuditLogEntry;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
|
it('formats created_at timestamp in Chicago timezone', function () {
|
||||||
|
Carbon::setTestNow('2024-01-01 12:00:00');
|
||||||
|
|
||||||
|
$entry = AuditLogEntry::create([
|
||||||
|
'user' => 'test@example.com',
|
||||||
|
'ip_address' => '127.0.0.1',
|
||||||
|
'message' => 'Test Message',
|
||||||
|
'affected' => ['users' => [1]],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Force reload to trigger the attribute accessor
|
||||||
|
$entry->refresh();
|
||||||
|
|
||||||
|
// The timestamp should be formatted as "M j, Y H:i:s" in America/Chicago timezone
|
||||||
|
expect($entry->created_at)->toBe('Jan 1, 2024 06:00:00');
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue