name = 'Boutique Retrait'; $shop->address = '10 rue Principale'; $shop->postcode = '75001'; $shop->city = 'Paris'; $shop->default = true; $shop->save(); $reference = new OrderReference(Uuid::uuid7()); $order = new Order(); $order->reference = $reference; $order->total = Money::EUR(2500); $order->status = OrderStatus::WAITING; $order->pickup_day = now()->addDays(2); $order->shop_id = $shop->id; $order->delivery_address = new DeliveryAddress( name: $shop->name, address: $shop->address, postcode: $shop->postcode, city: $shop->city, ); $order->employee = new OrderEmployee( matricule: new Matricule('1234567'), firstname: 'Jean', lastname: 'Dupont', facility: new ShopperEstablishmentCode('FAC01'), site: new ShopperSiteCode('SITE'), service: new ShopperServiceCode('101'), ); $order->save(); /** @var GetTunnelOrderConfirmedQuery $query */ $query = app(GetTunnelOrderConfirmedQuery::class); $input = new GetTunnelOrderConfirmedQueryInput($order); // WHEN $output = $query($input); // THEN expect($output)->toBeInstanceOf(GetTunnelOrderConfirmedQueryOutput::class) ->and($output->step)->toBe(OrderTunnelStep::CONFIRMATION) ->and($output->order)->toBeInstanceOf(OrderDto::class) ->and((string) $output->order->reference)->toBe((string) $reference) ->and($output->shop)->toBeInstanceOf(ShopDto::class) ->and($output->shop->name)->toBe('Boutique Retrait') ->and($output->mapUrl)->toBeString(); }); it('throws UnexpectedValueException when order has no shop', function (): void { // GIVEN $reference = new OrderReference(Uuid::uuid7()); $order = new Order(); $order->reference = $reference; $order->total = Money::EUR(2500); $order->status = OrderStatus::WAITING; $order->pickup_day = now()->addDays(2); $order->shop_id = null; $order->employee = new OrderEmployee( matricule: new Matricule('1234567'), firstname: 'Jean', lastname: 'Dupont', facility: new ShopperEstablishmentCode('FAC01'), site: new ShopperSiteCode('SITE'), service: new ShopperServiceCode('101'), ); $order->delivery_address = new DeliveryAddress( name: 'Nom', address: '1 rue Test', postcode: '75001', city: 'Paris', ); $order->save(); /** @var GetTunnelOrderConfirmedQuery $query */ $query = app(GetTunnelOrderConfirmedQuery::class); $input = new GetTunnelOrderConfirmedQueryInput($order); // WHEN & THEN expect(fn () => $query($input))->toThrow(\UnexpectedValueException::class); }); });