shouldReceive('getBasket')->once()->andReturn($basket); $builder->shouldReceive('getShopId')->once()->andReturn($shopId); $shop = new Shop( id: $shopId, name: 'Shop 1', address: '1 rue Test', postcode: '75001', city: 'Paris', ); $orderTunnelService = \Mockery::mock(OrderTunnelService::class); $orderTunnelService->shouldReceive('getBuilderCompletedOrFail') ->once() ->andReturn($builder); $shopRepository = \Mockery::mock(ShopRepository::class); $shopRepository->shouldReceive('find') ->once() ->with($shopId) ->andReturn($shop); $query = new GetOrderConfirmationQuery($orderTunnelService, $shopRepository); $input = new GetOrderConfirmationQueryInput(); // WHEN $output = $query($input); // THEN expect($output)->toBeInstanceOf(GetOrderConfirmationQueryOutput::class) ->and($output->step)->toBe(OrderTunnelStep::CONFIRMATION) ->and($output->basket)->toBe($basket) ->and($output->builder)->toBe($builder) ->and($output->shop)->toBeInstanceOf(ShopDto::class) ->and($output->shop->name)->toBe('Shop 1'); }); it('throws NotFoundHttpException when shop is not found', function (): void { // GIVEN $shopId = new ShopId(Uuid::uuid7()); $basket = new Basket(new BasketId(Uuid::uuid7())); $builder = \Mockery::mock(OrderBuilderCompleted::class); $builder->shouldReceive('getBasket')->once()->andReturn($basket); $builder->shouldReceive('getShopId')->once()->andReturn($shopId); $orderTunnelService = \Mockery::mock(OrderTunnelService::class); $orderTunnelService->shouldReceive('getBuilderCompletedOrFail') ->once() ->andReturn($builder); $shopRepository = \Mockery::mock(ShopRepository::class); $shopRepository->shouldReceive('find') ->once() ->with($shopId) ->andReturn(null); $query = new GetOrderConfirmationQuery($orderTunnelService, $shopRepository); $input = new GetOrderConfirmationQueryInput(); // WHEN & THEN expect(fn () => $query($input))->toThrow(NotFoundHttpException::class, 'Shop not found'); }); });