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); } }