feat: E.164 phone validation and storage with libphonenumber
- Add giggsey/libphonenumber-for-php, PhoneNumberNormalizer, ValidPhoneNumber rule - Store subscribers as E.164; mutator normalizes on save; optional phone required from form block - Migration to normalize legacy subscriber phones; Mailwizz/search/UI/tests updated - Add run-deploy-from-local.sh and PREREGISTER_DEFAULT_PHONE_REGION in .env.example Made-with: Cursor
This commit is contained in:
29
tests/Unit/SubscriberPhoneDisplayTest.php
Normal file
29
tests/Unit/SubscriberPhoneDisplayTest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Subscriber;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SubscriberPhoneDisplayTest extends TestCase
|
||||
{
|
||||
public function test_phone_display_keeps_e164_with_plus(): void
|
||||
{
|
||||
$subscriber = new Subscriber(['phone' => '+31613210095']);
|
||||
$this->assertSame('+31613210095', $subscriber->phoneDisplay());
|
||||
}
|
||||
|
||||
public function test_phone_display_prefixes_plus_for_legacy_digit_only_storage(): void
|
||||
{
|
||||
$subscriber = new Subscriber(['phone' => '31613210095']);
|
||||
$this->assertSame('+31613210095', $subscriber->phoneDisplay());
|
||||
}
|
||||
|
||||
public function test_phone_display_returns_null_when_empty(): void
|
||||
{
|
||||
$subscriber = new Subscriber(['phone' => null]);
|
||||
$this->assertNull($subscriber->phoneDisplay());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user