Files
preregister/tests/Feature/StorePreregistrationPageTest.php
bert.hausmans 5a67827c23 feat: optional fixed viewport background on public pages
Adds background_fixed column, admin checkbox, fixed-position layers on the public layout, Dutch strings, and store tests.

Made-with: Cursor
2026-04-04 13:36:26 +02:00

74 lines
2.5 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature;
use App\Models\PageBlock;
use App\Models\PreregistrationPage;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class StorePreregistrationPageTest extends TestCase
{
use RefreshDatabase;
public function test_authenticated_user_can_store_page_without_files(): void
{
$user = User::factory()->create(['role' => 'user']);
$response = $this->actingAs($user)->post(route('admin.pages.store'), [
'title' => 'Summer Fest',
'thank_you_message' => null,
'expired_message' => null,
'ticketshop_url' => null,
'start_date' => '2026-06-01T10:00',
'end_date' => '2026-06-30T18:00',
'is_active' => true,
]);
$this->assertDatabaseCount('preregistration_pages', 1);
$page = PreregistrationPage::query()->first();
$response->assertRedirect(route('admin.pages.edit', $page));
$this->assertSame('Summer Fest', $page?->title);
$this->assertFalse($page?->background_fixed);
$this->assertGreaterThanOrEqual(4, PageBlock::query()->where('preregistration_page_id', $page?->id)->count());
}
public function test_store_can_enable_fixed_background(): void
{
$user = User::factory()->create(['role' => 'user']);
$response = $this->actingAs($user)->post(route('admin.pages.store'), [
'title' => 'Winter Fest',
'thank_you_message' => null,
'expired_message' => null,
'ticketshop_url' => null,
'start_date' => '2026-06-01T10:00',
'end_date' => '2026-06-30T18:00',
'is_active' => true,
'background_fixed' => true,
]);
$page = PreregistrationPage::query()->where('title', 'Winter Fest')->first();
$response->assertRedirect(route('admin.pages.edit', $page));
$this->assertNotNull($page);
$this->assertTrue($page->background_fixed);
}
public function test_validation_failure_redirects_back_with_input(): void
{
$user = User::factory()->create(['role' => 'user']);
$response = $this->actingAs($user)->from(route('admin.pages.create'))->post(route('admin.pages.store'), [
'title' => '',
'start_date' => '2026-06-30T10:00',
'end_date' => '2026-06-01T10:00',
]);
$response->assertRedirect(route('admin.pages.create'));
$response->assertSessionHasErrors('title');
}
}