Refactor ticket validity handling and improve tests
- Updated tests for Accommodation, Entry, Food, Merchandise, and Sale controllers to use soft deletes for variants and ensure proper inventory counts. - Enhanced ticket generation logic to resolve validity from soft-deleted catalog sources. - Introduced a new TicketValidityResolver service to manage ticket validity based on event dates and variant definitions. - Removed unnecessary database assertions and improved the clarity of validity checks in tests. - Added comprehensive tests for the new TicketValidityResolver service, ensuring correct handling of event dates and multi-select options. - Cleaned up unused code and assertions in existing tests for better maintainability.
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Domains\Authorization\Enums\RoleCode;
|
||||
use App\Domains\Catalog\Models\Attribute;
|
||||
use App\Domains\Catalog\Models\CatalogItem;
|
||||
use App\Domains\Catalog\Models\Category;
|
||||
use App\Domains\Catalog\Models\Variant;
|
||||
use App\Domains\Menu\Models\Menu;
|
||||
use App\Domains\Shared\Enums\FieldType;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
@@ -97,7 +98,7 @@ class EntryControllerTest extends TestCase
|
||||
->where('nombre', 'Entradas')
|
||||
->sole();
|
||||
|
||||
CatalogItem::query()->each(function (CatalogItem $entry) use ($tenant, $entryCategory): void {
|
||||
CatalogItem::query()->orderBy('id')->each(function (CatalogItem $entry) use ($tenant, $entryCategory): void {
|
||||
$this->assertSame($tenant->codigo, $entry->tenant_code);
|
||||
$this->assertSame($entryCategory->id, $entry->category_id);
|
||||
$this->assertSame('tracked', $entry->inventory_policy->value);
|
||||
@@ -191,9 +192,10 @@ class EntryControllerTest extends TestCase
|
||||
$this->deleteJson("/api/v1/adminapp/tenant/entries/{$entryId}")
|
||||
->assertNoContent();
|
||||
|
||||
$this->assertDatabaseCount('catalog_items', 0);
|
||||
$this->assertDatabaseCount('variantes', 0);
|
||||
$this->assertDatabaseCount('inventories', 0);
|
||||
$this->assertSoftDeleted('catalog_items', ['id' => $entryId]);
|
||||
$this->assertSame(0, CatalogItem::query()->count());
|
||||
$this->assertSame(0, Variant::query()->count());
|
||||
$this->assertDatabaseCount('inventories', 1);
|
||||
}
|
||||
|
||||
public function test_dates_must_belong_to_the_authenticated_tenant(): void
|
||||
|
||||
Reference in New Issue
Block a user