test(casts): add tests for ShopperEstablishmentCodeCast functionality test(casts): add tests for ShopperServiceCodeCast functionality test(casts): add tests for ShopperSiteCodeCast functionality test(dto): update ProductDtoTest to include additional fields test(dto): update SettingDtoTest to remove arcadiaSites assertions test(events): update AnOrderHasBeenPlacedTest to use value objects test(entities): update OrderTest to use value objects for employee details test(value-objects): update EmployeeUpsertDataTest to use value objects test(pagination): update PaginationTest to access value properties test(services): update AppCustomerAuthServiceTest to use CrmHashcode test(services): update CrmServiceTest to use CrmHashcode for customer retrieval
67 lines
2.2 KiB
PHP
67 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects;
|
|
|
|
use Domain\Models\ValueObjects\Matricule;
|
|
use Domain\Models\ValueObjects\OrderEmployee;
|
|
use Domain\Models\ValueObjects\ShopperEstablishmentCode;
|
|
use Domain\Models\ValueObjects\ShopperServiceCode;
|
|
use Domain\Models\ValueObjects\ShopperSiteCode;
|
|
|
|
describe('OrderEmployee', function (): void {
|
|
it('can instantiate correctly', function (): void {
|
|
// GIVEN
|
|
$matricule = new Matricule('1234567');
|
|
$facility = new ShopperEstablishmentCode('ETAB01');
|
|
$site = new ShopperSiteCode('SITEA');
|
|
$service = new ShopperServiceCode('101');
|
|
|
|
// WHEN
|
|
$employee = new OrderEmployee(
|
|
$matricule,
|
|
'John',
|
|
'Doe',
|
|
$facility,
|
|
$site,
|
|
$service
|
|
);
|
|
|
|
// 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
|
|
$matricule = new Matricule('1234567');
|
|
$facility = new ShopperEstablishmentCode('ETAB01');
|
|
$site = new ShopperSiteCode('SITEA');
|
|
$service = new ShopperServiceCode('101');
|
|
|
|
// WHEN
|
|
$action = fn () => new OrderEmployee($matricule, '', 'Doe', $facility, $site, $service);
|
|
|
|
// THEN
|
|
expect($action)->toThrow(\DomainException::class, 'firstname cannot be empty');
|
|
});
|
|
|
|
it('throws exception if lastname is empty', function (): void {
|
|
// GIVEN
|
|
$matricule = new Matricule('1234567');
|
|
$facility = new ShopperEstablishmentCode('ETAB01');
|
|
$site = new ShopperSiteCode('SITEA');
|
|
$service = new ShopperServiceCode('101');
|
|
|
|
// WHEN
|
|
$action = fn () => new OrderEmployee($matricule, 'John', '', $facility, $site, $service);
|
|
|
|
// THEN
|
|
expect($action)->toThrow(\DomainException::class, 'lastname cannot be empty');
|
|
});
|
|
});
|