ldc-cocotte/tests/Unit/App/Dto/ProductDtoTest.php
Jérémy Munsch 93e4b202da
feat(products): enhance product form data with additional fields
Added support for new product attributes including tax rate, invoicing unit, order unit, and orderable dates. Updated related queries and views to accommodate these changes.
2026-11-15 16:45:00 +01:00

63 lines
2.1 KiB
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,
'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,
'tax_rate' => null,
'invoicing_unit' => null,
'stock' => 0,
'sell_unit' => null,
'order_unit' => null,
'range' => null,
'tags' => [],
'order' => 0,
'product_weight' => null,
'weight_variable' => false,
'status' => false,
'star' => false,
'orderable_start' => null,
'orderable_end' => null,
'short_description' => null,
'description' => null,
]);
});
});