35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use App\Dto\SettingDto;
|
||
|
|
use Domain\Models\ValueObjects\ShopperSiteCode;
|
||
|
|
|
||
|
|
describe('SettingDto', function (): void {
|
||
|
|
it('creates a DTO and provides helper methods', function (): void {
|
||
|
|
// GIVEN
|
||
|
|
$id = 1;
|
||
|
|
$sites = ['PA', 'LY'];
|
||
|
|
|
||
|
|
// WHEN
|
||
|
|
$dto = new SettingDto(id: $id, employeeSites: $sites);
|
||
|
|
|
||
|
|
// THEN
|
||
|
|
expect($dto->id)->toBe(1)
|
||
|
|
->and($dto->employeeSites)->toBe(['PA', 'LY'])
|
||
|
|
->and($dto->employeeSitesAsString())->toBe('PA, LY')
|
||
|
|
->and($dto->getShopperSiteCodes())->toHaveCount(2)
|
||
|
|
->and($dto->getShopperSiteCodes()[0])->toBeInstanceOf(ShopperSiteCode::class)
|
||
|
|
->and($dto->getShopperSiteCodes()[0]->value)->toBe('PA')
|
||
|
|
->and($dto->getShopperSiteCodes()[1]->value)->toBe('LY')
|
||
|
|
->and($dto->getRouteKey())->toBe(1)
|
||
|
|
->and($dto->getRouteKeyName())->toBe('setting')
|
||
|
|
->and($dto->resolveRouteBinding(1))->toBeNull()
|
||
|
|
->and($dto->resolveChildRouteBinding('child', 'val', 'field'))->toBeNull()
|
||
|
|
->and($dto->toArray())->toBe([
|
||
|
|
'id' => 1,
|
||
|
|
'employee_sites' => ['PA', 'LY'],
|
||
|
|
]);
|
||
|
|
});
|
||
|
|
});
|