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
78 lines
2.2 KiB
PHP
78 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Casts\ShopperEstablishmentCodeCast;
|
|
use Domain\Models\ValueObjects\ShopperEstablishmentCode;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
it('gets a ShopperEstablishmentCode', function () {
|
|
// GIVEN
|
|
$cast = new ShopperEstablishmentCodeCast();
|
|
$model = \Mockery::mock(Model::class);
|
|
|
|
// WHEN
|
|
$code = $cast->get($model, 'etablissement', 'ETAB01', []);
|
|
|
|
// THEN
|
|
expect($code)->toBeInstanceOf(ShopperEstablishmentCode::class)
|
|
->and($code->value)->toBe('ETAB01');
|
|
});
|
|
|
|
it('throws exception when getting invalid ShopperEstablishmentCode type', function () {
|
|
// GIVEN
|
|
$cast = new ShopperEstablishmentCodeCast();
|
|
$model = \Mockery::mock(Model::class);
|
|
|
|
// WHEN
|
|
$cast->get($model, 'etablissement', 123, []);
|
|
|
|
// THEN
|
|
})->throws(\UnexpectedValueException::class, 'ShopperEstablishmentCode must be a string.');
|
|
|
|
it('throws exception when getting null ShopperEstablishmentCode', function () {
|
|
// GIVEN
|
|
$cast = new ShopperEstablishmentCodeCast();
|
|
$model = \Mockery::mock(Model::class);
|
|
|
|
// WHEN
|
|
$cast->get($model, 'etablissement', null, []);
|
|
|
|
// THEN
|
|
})->throws(\UnexpectedValueException::class, 'ShopperEstablishmentCode must be a string.');
|
|
|
|
it('sets a ShopperEstablishmentCode from instance', function () {
|
|
// GIVEN
|
|
$cast = new ShopperEstablishmentCodeCast();
|
|
$model = \Mockery::mock(Model::class);
|
|
$vo = new ShopperEstablishmentCode('ETAB01');
|
|
|
|
// WHEN
|
|
$value = $cast->set($model, 'etablissement', $vo, []);
|
|
|
|
// THEN
|
|
expect($value)->toBe('ETAB01');
|
|
});
|
|
|
|
it('sets a ShopperEstablishmentCode from valid string', function () {
|
|
// GIVEN
|
|
$cast = new ShopperEstablishmentCodeCast();
|
|
$model = \Mockery::mock(Model::class);
|
|
|
|
// WHEN
|
|
$value = $cast->set($model, 'etablissement', 'ETAB01', []);
|
|
|
|
// THEN
|
|
expect($value)->toBe('ETAB01');
|
|
});
|
|
|
|
it('throws exception when setting invalid ShopperEstablishmentCode type', function () {
|
|
// GIVEN
|
|
$cast = new ShopperEstablishmentCodeCast();
|
|
$model = \Mockery::mock(Model::class);
|
|
|
|
// WHEN
|
|
$cast->set($model, 'etablissement', 123, []);
|
|
|
|
// THEN
|
|
})->throws(\UnexpectedValueException::class, 'The given value is not an instance of ShopperEstablishmentCode.');
|