Add tests for ticket validity and event date formatting
- Create TicketValiditySchemaTest to verify database schema for ticket validity. - Update CatalogModelsTest to include tests for event date attributes and selection options. - Introduce EventDateTextFormatterTest for formatting event dates in Spanish. - Refactor EventModelsTest to include validity time relationships. - Add SaleDetailResourceTest to ensure correct serialization of purchase items. - Enhance TicketTest with validity time checks and status management. - Implement ValidityTimeResourceTest to validate resource output for different validity types. - Add ValidityTimeTest to verify casting and validity checks for validity time types.
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Domains\Tenant\Models\Tenant;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @mixin Tenant
|
||||
@@ -32,14 +33,13 @@ class TenantResource extends JsonResource
|
||||
'header_bg_color' => $this->header_bg_color,
|
||||
'footer_bg_color' => $this->footer_bg_color,
|
||||
'website_type_code' => $this->website_type_code,
|
||||
'active_event_id' => $this->active_event_id,
|
||||
'active_event' => $this->whenLoaded('activeEvent', fn () => $this->activeEvent === null
|
||||
'event_date_text' => $this->event_date_text,
|
||||
'event' => $this->whenLoaded('eventDates', fn () => $this->event_title === null
|
||||
? null
|
||||
: [
|
||||
'id' => $this->activeEvent->id,
|
||||
'name' => $this->activeEvent->name,
|
||||
'address' => $this->activeEvent->address,
|
||||
'dates' => $this->activeEvent->dates->map(fn ($eventDate): array => [
|
||||
'title' => $this->event_title,
|
||||
'location' => $this->event_location,
|
||||
'dates' => $this->eventDates->map(fn ($eventDate): array => [
|
||||
'id' => $eventDate->id,
|
||||
'date' => $eventDate->date->format('Y-m-d'),
|
||||
'time_start' => $eventDate->time_start,
|
||||
@@ -62,6 +62,8 @@ class TenantResource extends JsonResource
|
||||
'search_product_layout' => $this->search_product_layout->value,
|
||||
'search_group_layout' => $this->search_group_layout->value,
|
||||
'search_items_per_page' => $this->search_items_per_page,
|
||||
'display_categories' => $this->display_categories,
|
||||
'display_seach_bar' => $this->display_seach_bar,
|
||||
'social_media' => $this->whenLoaded(
|
||||
'socialMedia',
|
||||
fn () => $this->socialMedia
|
||||
@@ -158,6 +160,10 @@ class TenantResource extends JsonResource
|
||||
|
||||
$formatted['submenues'] = $childrenByParent
|
||||
->get($menu->code, collect())
|
||||
->sortBy(
|
||||
fn (Menu $submenu) => Str::lower(Str::ascii($submenu->label)),
|
||||
SORT_NATURAL
|
||||
)
|
||||
->map($formatMenu)
|
||||
->values();
|
||||
|
||||
@@ -167,6 +173,10 @@ class TenantResource extends JsonResource
|
||||
return $menus
|
||||
->filter(fn (Menu $menu) => $menu->parent_menu_code === null
|
||||
|| ! $menuCodes->has($menu->parent_menu_code))
|
||||
->sortBy(
|
||||
fn (Menu $menu) => Str::lower(Str::ascii($menu->label)),
|
||||
SORT_NATURAL
|
||||
)
|
||||
->map($formatMenu)
|
||||
->values();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user