32 lines
644 B
PHP
32 lines
644 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace Tests\Unit\Domain\Models\ValueObjects;
|
||
|
|
|
||
|
|
use Domain\Models\ValueObjects\Email;
|
||
|
|
|
||
|
|
describe('Email', function () {
|
||
|
|
it('can instantiate', function () {
|
||
|
|
// GIVEN
|
||
|
|
$email = 'test@example.com';
|
||
|
|
|
||
|
|
// WHEN
|
||
|
|
$vo = new Email($email);
|
||
|
|
|
||
|
|
// THEN
|
||
|
|
expect($vo)->toBeInstanceOf(Email::class);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('throws exception if email format is invalid', function () {
|
||
|
|
// GIVEN
|
||
|
|
$email = 'not-an-email';
|
||
|
|
|
||
|
|
// WHEN
|
||
|
|
$action = fn () => new Email($email);
|
||
|
|
|
||
|
|
// THEN
|
||
|
|
expect($action)->toThrow(\DomainException::class);
|
||
|
|
});
|
||
|
|
});
|