feat: Phase 2 - page CRUD, subscriber management, user management
This commit is contained in:
53
tests/Feature/StorePreregistrationPageTest.php
Normal file
53
tests/Feature/StorePreregistrationPageTest.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
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',
|
||||
'heading' => 'Register',
|
||||
'intro_text' => null,
|
||||
'thank_you_message' => null,
|
||||
'expired_message' => null,
|
||||
'ticketshop_url' => null,
|
||||
'start_date' => '2026-06-01T10:00',
|
||||
'end_date' => '2026-06-30T18:00',
|
||||
'phone_enabled' => false,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$response->assertRedirect(route('admin.pages.index'));
|
||||
$this->assertDatabaseCount('preregistration_pages', 1);
|
||||
$this->assertSame('Summer Fest', PreregistrationPage::query()->first()?->title);
|
||||
}
|
||||
|
||||
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' => '',
|
||||
'heading' => 'H',
|
||||
'start_date' => '2026-06-30T10:00',
|
||||
'end_date' => '2026-06-01T10:00',
|
||||
]);
|
||||
|
||||
$response->assertRedirect(route('admin.pages.create'));
|
||||
$response->assertSessionHasErrors('title');
|
||||
$response->assertSessionHasInput('heading', 'H');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user