156 lines
6.5 KiB
PHP
156 lines
6.5 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Forms;
|
|
|
|
use App\Domains\Attachable\Enums\AttachmentType;
|
|
use App\Domains\Attachable\Models\Attachment;
|
|
use App\Domains\Auth\Models\User;
|
|
use App\Domains\Authorization\Enums\RoleCode;
|
|
use App\Domains\Tenant\Models\Tenant;
|
|
use Database\Seeders\AttributeSeeder;
|
|
use Database\Seeders\AuthorizationSeeder;
|
|
use Database\Seeders\FiestaFutbolInfantilProductSeeder;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Laravel\Sanctum\Sanctum;
|
|
use Tests\TestCase;
|
|
|
|
class AdminAppTicketFormControllerTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->seed(AuthorizationSeeder::class);
|
|
}
|
|
|
|
public function test_authentication_is_required(): void
|
|
{
|
|
$this->getJson('/api/v1/adminapp/forms/fiesta-futbol-infantil/ticket')
|
|
->assertUnauthorized();
|
|
}
|
|
|
|
public function test_it_returns_nested_ticket_options_using_the_frontend_presentation_mapping(): void
|
|
{
|
|
$headerLogo = $this->createAttachment('header.png');
|
|
$footerLogo = $this->createAttachment('footer.png');
|
|
$tenant = Tenant::query()->create([
|
|
'codigo' => 'fiesta_futbol_infantil',
|
|
'nombre' => 'Fiesta Fútbol Infantil',
|
|
'dominio' => 'fiesta-futbol-infantil.test',
|
|
'primary_color' => '#00973F',
|
|
'secondary_color' => '#A0A0A0',
|
|
'danger_color' => '#FF8888',
|
|
'success_color' => '#198754',
|
|
'header_bg_color' => '#ffffff',
|
|
'footer_bg_color' => '#015327',
|
|
'header_logo_id' => $headerLogo->id,
|
|
'footer_logo_id' => $footerLogo->id,
|
|
]);
|
|
$this->seed([AttributeSeeder::class, FiestaFutbolInfantilProductSeeder::class]);
|
|
|
|
Sanctum::actingAs(User::factory()->create([
|
|
'rol_codigo' => RoleCode::AdminApp->value,
|
|
'tenant_codigo' => $tenant->codigo,
|
|
]));
|
|
|
|
$response = $this->getJson('/api/v1/adminapp/forms/fiesta-futbol-infantil/ticket')
|
|
->assertOk()
|
|
->assertExactJson([
|
|
'data' => [
|
|
'statuses' => [
|
|
['value' => 'active', 'label' => 'Activo'],
|
|
['value' => 'used', 'label' => 'Usado'],
|
|
['value' => 'expired', 'label' => 'Vencido'],
|
|
],
|
|
'categories' => [
|
|
[
|
|
'value' => 'entradas',
|
|
'label' => 'Entradas',
|
|
'products' => [[
|
|
'value' => 'abono',
|
|
'label' => 'Abono',
|
|
'types' => [],
|
|
]],
|
|
],
|
|
[
|
|
'value' => 'alojamientos',
|
|
'label' => 'Camping',
|
|
'products' => [
|
|
['value' => 'Carpa', 'label' => 'Carpa', 'types' => []],
|
|
['value' => 'Motorhome', 'label' => 'Motorhome', 'types' => []],
|
|
],
|
|
],
|
|
[
|
|
'value' => 'comidas',
|
|
'label' => 'Comida',
|
|
'products' => [
|
|
[
|
|
'value' => (string) $tenant->eventDates[0]->id,
|
|
'label' => '09/10',
|
|
'types' => [
|
|
['value' => 'Desayuno', 'label' => 'Desayuno'],
|
|
['value' => 'Almuerzo', 'label' => 'Almuerzo'],
|
|
['value' => 'Cena', 'label' => 'Cena'],
|
|
],
|
|
],
|
|
[
|
|
'value' => (string) $tenant->eventDates[1]->id,
|
|
'label' => '10/10',
|
|
'types' => [
|
|
['value' => 'Desayuno', 'label' => 'Desayuno'],
|
|
['value' => 'Almuerzo', 'label' => 'Almuerzo'],
|
|
['value' => 'Cena', 'label' => 'Cena'],
|
|
],
|
|
],
|
|
[
|
|
'value' => (string) $tenant->eventDates[2]->id,
|
|
'label' => '11/10',
|
|
'types' => [
|
|
['value' => 'Desayuno', 'label' => 'Desayuno'],
|
|
['value' => 'Almuerzo', 'label' => 'Almuerzo'],
|
|
['value' => 'Cena', 'label' => 'Cena'],
|
|
],
|
|
],
|
|
[
|
|
'value' => (string) $tenant->eventDates[3]->id,
|
|
'label' => '12/10',
|
|
'types' => [
|
|
['value' => 'Desayuno', 'label' => 'Desayuno'],
|
|
['value' => 'Almuerzo', 'label' => 'Almuerzo'],
|
|
['value' => 'Cena', 'label' => 'Cena'],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
[
|
|
'value' => 'merchandising',
|
|
'label' => 'Merchandising',
|
|
'products' => [[
|
|
'value' => 'camiseta',
|
|
'label' => 'Camiseta',
|
|
'types' => [
|
|
['value' => 'Verde', 'label' => 'Verde'],
|
|
['value' => 'Blanco', 'label' => 'Blanco'],
|
|
],
|
|
]],
|
|
],
|
|
],
|
|
],
|
|
]);
|
|
|
|
$response->assertJsonMissingPath('data.categories.0.products.0.category');
|
|
}
|
|
|
|
private function createAttachment(string $filename): Attachment
|
|
{
|
|
return Attachment::query()->create([
|
|
'path' => "tests/{$filename}",
|
|
'filename' => $filename,
|
|
'type' => AttachmentType::Image,
|
|
'mime_type' => 'image/png',
|
|
]);
|
|
}
|
|
}
|