Merge branch 'hotfix/change_history_time'
This commit is contained in:
@@ -23,6 +23,7 @@ class SaleModificationResource extends JsonResource
|
||||
'attribute' => $this->attribute,
|
||||
'old_value' => $this->old_value,
|
||||
'new_value' => $this->new_value,
|
||||
'changed_at' => $this->changed_at->utc()->toIso8601String(),
|
||||
'date' => $this->changed_at->format('Y-m-d'),
|
||||
'time' => $this->changed_at->format('H:i:s'),
|
||||
'actor_type' => $this->actor_type->value,
|
||||
|
||||
33
tests/Unit/Sale/SaleModificationResourceTest.php
Normal file
33
tests/Unit/Sale/SaleModificationResourceTest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Sale;
|
||||
|
||||
use App\Domains\Logging\Models\ValueChange;
|
||||
use App\Domains\Sale\Resources\AdminApp\SaleModificationResource;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Http\Request;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SaleModificationResourceTest extends TestCase
|
||||
{
|
||||
public function test_it_serializes_the_change_instant_as_utc_iso_8601(): void
|
||||
{
|
||||
$modification = (new ValueChange)->forceFill([
|
||||
'id' => 1,
|
||||
'trackable_id' => 33,
|
||||
'attribute' => 'status',
|
||||
'old_value' => 'pending_payment',
|
||||
'new_value' => 'cancelled',
|
||||
'changed_at' => CarbonImmutable::parse('2026-08-24 17:53:00', 'UTC'),
|
||||
'actor_type' => 'system',
|
||||
]);
|
||||
$modification->setRelation('trackable', null);
|
||||
$modification->setRelation('user', null);
|
||||
|
||||
$data = (new SaleModificationResource($modification))->resolve(Request::create('/'));
|
||||
|
||||
$this->assertSame('2026-08-24T17:53:00+00:00', $data['changed_at']);
|
||||
$this->assertSame('2026-08-24', $data['date']);
|
||||
$this->assertSame('17:53:00', $data['time']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user