ldc-cocotte/tests/Unit/App/Dto/ShopDtoTest.php

43 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\App\Dto;
use App\Dto\ShopDto;
use Domain\Models\Entities\Shop;
use Domain\Models\ValueObjects\Entities\ShopId;
use Shared\Helpers\UuidHelper;
describe('ShopDto', function (): void {
it('creates a DTO from domain Shop entity', function (): void {
// GIVEN
$uuid = UuidHelper::v7();
$shopId = new ShopId($uuid);
$domainShop = new Shop(
id: $shopId,
name: 'Boutique Domain',
address: '10 avenue de la Gare',
postcode: '69001',
city: 'Lyon',
phone: '0478000000',
latitude: '45.75',
longitude: '4.85',
isDefault: true,
);
// WHEN
$dto = ShopDto::fromDomain($domainShop);
// THEN
expect($dto->id)->toBe($uuid->toString())
->and($dto->name)->toBe('Boutique Domain')
->and($dto->address)->toBe('10 avenue de la Gare')
->and($dto->postcode)->toBe('69001')
->and($dto->city)->toBe('Lyon')
->and($dto->phone)->toBe('0478000000')
->and($dto->latitude)->toBe('45.75')
->and($dto->longitude)->toBe('4.85')
->and($dto->default)->toBeTrue();
});
});