test user persistence
This commit is contained in:
parent
a8a6177a1d
commit
b5697e1e1f
3 changed files with 94 additions and 0 deletions
27
backend/tests/Unit/Shared/ValueObject/EmailAddressTest.php
Normal file
27
backend/tests/Unit/Shared/ValueObject/EmailAddressTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?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());
|
||||
}
|
||||
}
|
||||
19
backend/tests/Unit/User/UserTest.php
Normal file
19
backend/tests/Unit/User/UserTest.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit\User;
|
||||
|
||||
use App\Shared\ValueObject\EmailAddress;
|
||||
use App\User\User;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class UserTest extends TestCase
|
||||
{
|
||||
public function test_it_exposes_its_identity_and_email(): void
|
||||
{
|
||||
$email = new EmailAddress('user@example.com');
|
||||
$user = new User(id: 42, email: $email);
|
||||
|
||||
$this->assertSame(42, $user->getId());
|
||||
$this->assertSame($email, $user->getEmail());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue