refactor(catalog): handle null validity time in CatalogItemDetailResource and update related tests
This commit is contained in:
@@ -36,7 +36,9 @@ class CatalogItemDetailResource extends JsonResource
|
|||||||
'max_units_per_user' => $this->max_units_per_user,
|
'max_units_per_user' => $this->max_units_per_user,
|
||||||
'has_tickets' => $this->has_tickets,
|
'has_tickets' => $this->has_tickets,
|
||||||
'validity_time_id' => $this->validity_time_id,
|
'validity_time_id' => $this->validity_time_id,
|
||||||
'validity_time' => ValidityTimeResource::make($this->validityTime),
|
'validity_time' => $this->validityTime === null
|
||||||
|
? null
|
||||||
|
: ValidityTimeResource::make($this->validityTime),
|
||||||
'attributes' => $this->attributesData(),
|
'attributes' => $this->attributesData(),
|
||||||
'stock_tecnico' => $this->when(
|
'stock_tecnico' => $this->when(
|
||||||
$selectedVariant === null,
|
$selectedVariant === null,
|
||||||
@@ -101,7 +103,9 @@ class CatalogItemDetailResource extends JsonResource
|
|||||||
'label' => $option->label,
|
'label' => $option->label,
|
||||||
'sort_order' => $option->sort_order,
|
'sort_order' => $option->sort_order,
|
||||||
'validity_time_id' => $option->validity_time_id,
|
'validity_time_id' => $option->validity_time_id,
|
||||||
'validity_time' => ValidityTimeResource::make($option->validityTime),
|
'validity_time' => $option->validityTime === null
|
||||||
|
? null
|
||||||
|
: ValidityTimeResource::make($option->validityTime),
|
||||||
'metadata' => $option->metadata,
|
'metadata' => $option->metadata,
|
||||||
])
|
])
|
||||||
->values(),
|
->values(),
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Event;
|
namespace Tests\Feature\Event;
|
||||||
|
|
||||||
|
use App\Domains\Attachable\Enums\AttachmentType;
|
||||||
|
use App\Domains\Attachable\Models\Attachment;
|
||||||
use App\Domains\Auth\Models\User;
|
use App\Domains\Auth\Models\User;
|
||||||
use App\Domains\Authorization\Enums\RoleCode;
|
use App\Domains\Authorization\Enums\RoleCode;
|
||||||
use App\Domains\Tenant\Models\Tenant;
|
use App\Domains\Tenant\Models\Tenant;
|
||||||
@@ -240,11 +242,32 @@ class AdminAppEventControllerTest extends TestCase
|
|||||||
|
|
||||||
private function createTenant(string $code): Tenant
|
private function createTenant(string $code): Tenant
|
||||||
{
|
{
|
||||||
|
$headerLogo = $this->createAttachment("{$code}-header");
|
||||||
|
$footerLogo = $this->createAttachment("{$code}-footer");
|
||||||
|
|
||||||
return Tenant::query()->create([
|
return Tenant::query()->create([
|
||||||
'codigo' => $code,
|
'codigo' => $code,
|
||||||
'nombre' => ucfirst($code),
|
'nombre' => ucfirst($code),
|
||||||
'dominio' => "{$code}.test",
|
'dominio' => "{$code}.test",
|
||||||
'website_type_code' => 'onticket',
|
'website_type_code' => 'onticket',
|
||||||
|
'primary_color' => '#000000',
|
||||||
|
'secondary_color' => '#000000',
|
||||||
|
'danger_color' => '#000000',
|
||||||
|
'success_color' => '#000000',
|
||||||
|
'header_bg_color' => '#000000',
|
||||||
|
'footer_bg_color' => '#000000',
|
||||||
|
'header_logo_id' => $headerLogo->id,
|
||||||
|
'footer_logo_id' => $footerLogo->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createAttachment(string $name): Attachment
|
||||||
|
{
|
||||||
|
return Attachment::query()->create([
|
||||||
|
'path' => "test/{$name}.png",
|
||||||
|
'filename' => "{$name}.png",
|
||||||
|
'type' => AttachmentType::Image,
|
||||||
|
'mime_type' => 'image/png',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user