27 lines
698 B
PHP
27 lines
698 B
PHP
<?php
|
|
|
|
namespace Tests\Unit\Shared\ValueObject;
|
|
|
|
use App\Shared\ValueObject\EmailAddress;
|
|
use InvalidArgumentException;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class EmailAddressTest extends TestCase
|
|
{
|
|
public function test_it_rejects_an_invalid_email_address(): void
|
|
{
|
|
$this->expectException(InvalidArgumentException::class);
|
|
$this->expectExceptionMessage(
|
|
'Invalid email address: invalid-email',
|
|
);
|
|
|
|
new EmailAddress('invalid-email');
|
|
}
|
|
|
|
public function test_it_trims_and_normalizes_the_domain(): void
|
|
{
|
|
$email = new EmailAddress(' Founder@EXAMPLE.COM ');
|
|
|
|
$this->assertSame('Founder@example.com', $email->value());
|
|
}
|
|
}
|