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

56 lines
1.8 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
use App\Dto\ProductDto;
describe('ProductDto', function () {
test('it can be instantiated with all properties', function () {
// GIVEN
$id = '018f6c40-1234-7123-8123-123456789012';
$name = 'Poulet Fermier';
$slug = 'poulet-fermier';
// WHEN
$dto = new ProductDto(
id: $id,
name: $name,
slug: $slug,
);
// THEN
expect($dto->id)->toBe($id)
->and($dto->name)->toBe($name)
->and($dto->slug)->toBe($slug)
->and($dto->getRouteKey())->toBe($slug)
->and($dto->getRouteKeyName())->toBe('slug')
->and($dto->resolveRouteBinding('some-id'))->toBeNull()
->and($dto->resolveChildRouteBinding('child', 'some-id', 'field'))->toBeNull();
$array = $dto->toArray();
expect($array)->toBe([
'id' => $id,
'name' => $name,
'slug' => $slug,
'brand' => null,
'inco' => null,
'picture' => null,
'picture_alt' => null,
'picture_title' => null,
'picture_large' => null,
'picture_large_alt' => null,
'picture_large_title' => null,
'price' => null,
'discount' => null,
'stock' => 0,
'sell_unit' => null,
'range' => null,
'order' => 0,
'status' => false,
'star' => false,
'short_description' => null,
'description' => null,
]);
});
});