38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Domain\Exceptions;
|
|
|
|
use Domain\Exceptions\BrandNotFoundException;
|
|
use Domain\Models\ValueObjects\Brand\BrandCode;
|
|
use Domain\Models\ValueObjects\Brand\BrandId;
|
|
use DomainException;
|
|
|
|
covers(BrandNotFoundException::class);
|
|
|
|
describe('brand not found exception', function (): void {
|
|
it('get the correct message from id', function (): void {
|
|
// GIVEN
|
|
$id = BrandId::generate();
|
|
|
|
// WHEN
|
|
$exception = BrandNotFoundException::fromId($id);
|
|
|
|
// THEN
|
|
expect($exception->getMessage())->toBe('Brand with id "' . $id . '" was not found.')
|
|
->and($exception)->toBeInstanceOf(DomainException::class);
|
|
});
|
|
|
|
it('get the correct message from code', function (): void {
|
|
// GIVEN
|
|
$code = new BrandCode('AAA01');
|
|
|
|
// WHEN
|
|
$exception = BrandNotFoundException::fromCode($code);
|
|
|
|
// THEN
|
|
expect($exception->getMessage())->toBe('Brand with code "AAA01" was not found.')
|
|
->and($exception)->toBeInstanceOf(DomainException::class);
|
|
});
|
|
});
|