37 lines
1,018 B
PHP
37 lines
1,018 B
PHP
<?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,
|
|
]);
|
|
});
|
|
});
|