feat(forms): add desfile entry reservation form
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Forms;
|
||||
|
||||
use App\Domains\Core\Auth\Models\User;
|
||||
use App\Domains\Core\Authorization\Enums\RoleCode;
|
||||
use App\Domains\Core\Menu\Models\Menu;
|
||||
use App\Domains\Core\Tenant\Models\Tenant;
|
||||
use Database\Seeders\AuthorizationSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminAppDesfileEntryReservationFormControllerTest 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/desfile/entry-reservation')
|
||||
->assertUnauthorized();
|
||||
}
|
||||
|
||||
public function test_the_tenant_must_have_the_reservations_menu(): void
|
||||
{
|
||||
$tenant = $this->createTenant('without_reservations');
|
||||
Sanctum::actingAs($this->createAdminAppUser($tenant));
|
||||
|
||||
$this->getJson('/api/v1/adminapp/forms/desfile/entry-reservation')
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_it_only_returns_the_available_payment_types(): void
|
||||
{
|
||||
$tenant = $this->createTenant('desfile_pura_tendencia');
|
||||
$this->grantReservationsMenu($tenant);
|
||||
Sanctum::actingAs($this->createAdminAppUser($tenant));
|
||||
|
||||
$this->getJson('/api/v1/adminapp/forms/desfile/entry-reservation')
|
||||
->assertOk()
|
||||
->assertExactJson([
|
||||
'data' => [
|
||||
'payment_types' => [
|
||||
['value' => 'sin_cargo', 'label' => 'Sin cargo'],
|
||||
['value' => 'otro_metodo', 'label' => 'Otro método'],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
private function createTenant(string $code): Tenant
|
||||
{
|
||||
return Tenant::query()->create([
|
||||
'codigo' => $code,
|
||||
'nombre' => str($code)->headline(),
|
||||
'dominio' => "{$code}.test",
|
||||
]);
|
||||
}
|
||||
|
||||
private function createAdminAppUser(Tenant $tenant): User
|
||||
{
|
||||
return User::factory()->create([
|
||||
'rol_codigo' => RoleCode::AdminApp->value,
|
||||
'tenant_codigo' => $tenant->codigo,
|
||||
]);
|
||||
}
|
||||
|
||||
private function grantReservationsMenu(Tenant $tenant): void
|
||||
{
|
||||
$menu = Menu::query()->create([
|
||||
'code' => 'adminapp.desfile.reservas',
|
||||
'label' => 'Reserva de Tickets',
|
||||
'route' => '/admin/desfile/reservas',
|
||||
]);
|
||||
|
||||
$tenant->menues()->attach($menu->code);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user