72 lines
2.5 KiB
PHP
72 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects;
|
|
|
|
use Domain\Models\ValueObjects\Matricule;
|
|
use Domain\Models\ValueObjects\OrderEmployee;
|
|
|
|
describe('OrderEmployee', function (): void {
|
|
it('can instantiate correctly', function (): void {
|
|
// GIVEN
|
|
$matricule = new Matricule('1234567');
|
|
$employee = new OrderEmployee(
|
|
$matricule,
|
|
'John',
|
|
'Doe',
|
|
'Facility',
|
|
'Site',
|
|
'Service'
|
|
// WHEN
|
|
);
|
|
// THEN
|
|
|
|
expect($employee->matricule)->toBe($matricule)
|
|
->and($employee->firstname)->toBe('John')
|
|
->and($employee->lastname)->toBe('Doe')
|
|
->and($employee->facility)->toBe('Facility')
|
|
->and($employee->site)->toBe('Site')
|
|
->and($employee->service)->toBe('Service');
|
|
});
|
|
|
|
it('throws exception if firstname is empty', function (): void {
|
|
// GIVEN
|
|
// WHEN
|
|
$action = fn () => new OrderEmployee(new Matricule('1234567'), '', 'Doe', 'Facility', 'Site', 'Service');
|
|
// THEN
|
|
expect($action)->toThrow(\DomainException::class, 'firstname cannot be empty');
|
|
});
|
|
|
|
it('throws exception if lastname is empty', function (): void {
|
|
// GIVEN
|
|
// WHEN
|
|
$action = fn () => new OrderEmployee(new Matricule('1234567'), 'John', '', 'Facility', 'Site', 'Service');
|
|
// THEN
|
|
expect($action)->toThrow(\DomainException::class, 'lastname cannot be empty');
|
|
});
|
|
|
|
it('throws exception if facility is empty', function (): void {
|
|
// GIVEN
|
|
// WHEN
|
|
$action = fn () => new OrderEmployee(new Matricule('1234567'), 'John', 'Doe', '', 'Site', 'Service');
|
|
// THEN
|
|
expect($action)->toThrow(\DomainException::class, 'facility cannot be empty');
|
|
});
|
|
|
|
it('throws exception if site is empty', function (): void {
|
|
// GIVEN
|
|
// WHEN
|
|
$action = fn () => new OrderEmployee(new Matricule('1234567'), 'John', 'Doe', 'Facility', '', 'Service');
|
|
// THEN
|
|
expect($action)->toThrow(\DomainException::class, 'site cannot be empty');
|
|
});
|
|
|
|
it('throws exception if service is empty', function (): void {
|
|
// GIVEN
|
|
// WHEN
|
|
$action = fn () => new OrderEmployee(new Matricule('1234567'), 'John', 'Doe', 'Facility', 'Site', '');
|
|
// THEN
|
|
expect($action)->toThrow(\DomainException::class, 'service cannot be empty');
|
|
});
|
|
});
|