feat: Add event association to purchases; implement event relationship in models, update migration, and enhance tests
This commit is contained in:
@@ -11,6 +11,7 @@ use App\Domains\Catalog\Models\CatalogItem;
|
||||
use App\Domains\Catalog\Models\Category;
|
||||
use App\Domains\Catalog\Models\Inventory;
|
||||
use App\Domains\Catalog\Models\Variant;
|
||||
use App\Domains\Event\Models\Event;
|
||||
use App\Domains\Purchase\Models\Purchase;
|
||||
use App\Domains\Purchase\Services\CheckoutService;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
@@ -33,6 +34,12 @@ class StorePurchaseTest extends TestCase
|
||||
public function test_it_creates_an_independent_purchase_snapshot_from_cart(): void
|
||||
{
|
||||
$tenant = $this->createTenant('sonder', 'Sonder', 'sonder.com.ar');
|
||||
$event = Event::query()->create([
|
||||
'tenant_code' => $tenant->codigo,
|
||||
'name' => 'Sonder Fest',
|
||||
'address' => 'Test address',
|
||||
]);
|
||||
$tenant->update(['active_event_id' => $event->id]);
|
||||
$user = User::factory()->create([
|
||||
'email' => 'buyer@example.com',
|
||||
]);
|
||||
@@ -85,6 +92,7 @@ class StorePurchaseTest extends TestCase
|
||||
$response->assertJsonPath('data.nombre_apellido', null);
|
||||
$response->assertJsonPath('data.email', null);
|
||||
$response->assertJsonPath('data.tenant_codigo', 'sonder');
|
||||
$response->assertJsonPath('data.event_id', $event->id);
|
||||
$response->assertJsonPath('data.status', Purchase::STATUS_CREATED);
|
||||
$response->assertJsonPath('data.items_source', 'purchase');
|
||||
$response->assertJsonCount(1, 'data.items');
|
||||
@@ -97,6 +105,7 @@ class StorePurchaseTest extends TestCase
|
||||
'id' => $purchaseId,
|
||||
'cart_id' => $cartId,
|
||||
'tenant_codigo' => 'sonder',
|
||||
'event_id' => $event->id,
|
||||
'user_id' => $user->id,
|
||||
'dni' => null,
|
||||
'telefono' => null,
|
||||
|
||||
25
tests/Unit/Forms/SaleFormServiceTest.php
Normal file
25
tests/Unit/Forms/SaleFormServiceTest.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Forms;
|
||||
|
||||
use App\Domains\Forms\Services\SaleFormService;
|
||||
use App\Domains\Purchase\Models\Purchase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SaleFormServiceTest extends TestCase
|
||||
{
|
||||
public function test_it_returns_every_purchase_status_as_a_form_option(): void
|
||||
{
|
||||
$form = (new SaleFormService)->get();
|
||||
|
||||
$this->assertSame(Purchase::statuses(), array_column($form['statuses'], 'code'));
|
||||
$this->assertSame([
|
||||
'Creada',
|
||||
'Esperando pago',
|
||||
'Confirmada',
|
||||
'Cancelada',
|
||||
'Rechazada',
|
||||
'Vencida',
|
||||
], array_column($form['statuses'], 'name'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user