ldc-arcadia-api/tests/Unit/Application/Arcadia/Exceptions/EmployeeNotFoundExceptionTest.php

38 lines
1.1 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace Tests\Unit\Application\Arcadia\Exceptions;
use Application\Arcadia\Exceptions\EmployeeNotFoundException;
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
use Shared\DDD\Exception\NotFoundException;
covers(EmployeeNotFoundException::class);
describe('EmployeeNotFoundException Unit Tests', function (): void {
it('creates exception from value object', function (): void {
// GIVEN
$id = new ArcadiaEmployeeId('01155902');
// WHEN
$exception = EmployeeNotFoundException::forEmployee($id);
// THEN
expect($exception)->toBeInstanceOf(NotFoundException::class)
->and($exception->getMessage())->toBe("Employee '01155902' not found.");
});
it('creates exception from string', function (): void {
// GIVEN
$id = '01155902';
// WHEN
$exception = EmployeeNotFoundException::forEmployee($id);
// THEN
expect($exception)->toBeInstanceOf(NotFoundException::class)
->and($exception->getMessage())->toBe("Employee '01155902' not found.");
});
});