feat: Remove 'in_review' status from purchase workflow; implement logging for status changes and update related tests
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Tests\Feature\Logging;
|
||||
use App\Domains\Logging\Enums\ValueChangeActorType;
|
||||
use App\Domains\Logging\Models\Concerns\LogsValueChanges;
|
||||
use App\Domains\Logging\Models\ValueChange;
|
||||
use App\Domains\Purchase\Models\Purchase;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
@@ -37,6 +38,12 @@ class LogsValueChangesTest extends TestCase
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('compras', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string('status')->default(Purchase::STATUS_CREATED);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
$migration = require database_path('migrations/2026_08_03_000200_create_value_changes_table.php');
|
||||
$migration->up();
|
||||
}
|
||||
@@ -103,6 +110,27 @@ class LogsValueChangesTest extends TestCase
|
||||
|
||||
$this->assertDatabaseCount('value_changes', 0);
|
||||
}
|
||||
|
||||
public function test_purchase_logs_its_status_changes(): void
|
||||
{
|
||||
$purchase = Purchase::query()->create([
|
||||
'status' => Purchase::STATUS_CREATED,
|
||||
]);
|
||||
|
||||
$purchase->update([
|
||||
'status' => Purchase::STATUS_PENDING_PAYMENT,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('value_changes', [
|
||||
'trackable_type' => $purchase->getMorphClass(),
|
||||
'trackable_id' => $purchase->id,
|
||||
'attribute' => 'status',
|
||||
'old_value' => Purchase::STATUS_CREATED,
|
||||
'new_value' => Purchase::STATUS_PENDING_PAYMENT,
|
||||
'actor_type' => ValueChangeActorType::System->value,
|
||||
'user_id' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
#[Fillable(['name', 'price', 'description'])]
|
||||
|
||||
Reference in New Issue
Block a user