chore: checkpoint before block builder refactor
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user