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