chore: checkpoint before block builder refactor

This commit is contained in:
2026-04-03 23:03:09 +02:00
parent 330950cc6e
commit 4f3fefca5c
14 changed files with 315 additions and 99 deletions

View File

@@ -110,6 +110,88 @@ class PublicPageTest extends TestCase
$response->assertForbidden();
}
public function test_subscribe_rejects_invalid_email(): void
{
$page = $this->makePage([
'start_date' => now()->subHour(),
'end_date' => now()->addMonth(),
]);
$response = $this->postJson(route('public.subscribe', ['publicPage' => $page->slug]), [
'first_name' => 'A',
'last_name' => 'B',
'email' => 'not-a-valid-email',
]);
$response->assertUnprocessable();
$response->assertJsonValidationErrors(['email']);
}
public function test_subscribe_accepts_empty_phone_when_phone_field_enabled(): void
{
$page = $this->makePage([
'start_date' => now()->subHour(),
'end_date' => now()->addMonth(),
'phone_enabled' => true,
]);
$response = $this->postJson(route('public.subscribe', ['publicPage' => $page->slug]), [
'first_name' => 'A',
'last_name' => 'B',
'email' => 'nophone@example.com',
'phone' => '',
]);
$response->assertOk();
$this->assertDatabaseHas('subscribers', [
'preregistration_page_id' => $page->id,
'email' => 'nophone@example.com',
'phone' => null,
]);
}
public function test_subscribe_rejects_phone_with_too_few_digits(): void
{
$page = $this->makePage([
'start_date' => now()->subHour(),
'end_date' => now()->addMonth(),
'phone_enabled' => true,
]);
$response = $this->postJson(route('public.subscribe', ['publicPage' => $page->slug]), [
'first_name' => 'A',
'last_name' => 'B',
'email' => 'a@example.com',
'phone' => '+31 12 3',
]);
$response->assertUnprocessable();
$response->assertJsonValidationErrors(['phone']);
}
public function test_subscribe_normalizes_phone_to_digits(): void
{
$page = $this->makePage([
'start_date' => now()->subHour(),
'end_date' => now()->addMonth(),
'phone_enabled' => true,
]);
$response = $this->postJson(route('public.subscribe', ['publicPage' => $page->slug]), [
'first_name' => 'A',
'last_name' => 'B',
'email' => 'phoneuser@example.com',
'phone' => '+31 6 1234 5678',
]);
$response->assertOk();
$this->assertDatabaseHas('subscribers', [
'preregistration_page_id' => $page->id,
'email' => 'phoneuser@example.com',
'phone' => '31612345678',
]);
}
/**
* @param array<string, mixed> $overrides
*/