name = 'Boutique Centre'; $shop->address = '10 rue Centrale'; $shop->postcode = '69002'; $shop->city = 'Lyon'; $shop->phone = '+33472000000'; $shop->default = true; $shop->save(); // WHEN $dto = ShopDto::fromModel($shop); // THEN expect($dto->id)->toBe($shop->id) ->and($dto->name)->toBe('Boutique Centre') ->and($dto->address)->toBe('10 rue Centrale') ->and($dto->postcode)->toBe('69002') ->and($dto->city)->toBe('Lyon') ->and($dto->phone)->toBe('+33472000000') ->and($dto->default)->toBeTrue() ->and($dto->getRouteKey())->toBe($shop->id); }); test('it maps loaded pickupExceptions relation correctly', function () { // GIVEN $shop = Shop::factory()->create(); $exception = PickupException::factory()->create(); $shop->pickupExceptions()->attach($exception->id, [ 'replacement_date' => '2026-06-01', 'order_deadline_at' => '2026-05-31 12:00:00', ]); $shop->load('pickupExceptions'); // WHEN $dto = ShopDto::fromModel($shop); // THEN expect($dto->pickupExceptions)->not->toBeNull() ->and($dto->pickupExceptions)->toHaveCount(1) ->and($dto->pickupExceptions->first()->id)->toBe($exception->id) ->and($dto->pickupExceptions->first()->pivot)->not->toBeNull() ->and($dto->pickupExceptions->first()->pivot->replacement_date?->format('Y-m-d'))->toBe('2026-06-01'); }); });