/** * {@inheritdoc} */ public function handle(OrderInterface $order) { try { $this->onHandQuantityUpdater->decrease($order); $this->onHoldQuantityUpdater->decrease($order); } catch (\InvalidArgumentException $exception) { throw new HandleException(self::class, 'Cannot decrease inventory on hold and on hand quantity', $exception); } }
function it_throws_handle_exception_if_decreasing_quantity_updater_fails(OrderQuantityUpdaterInterface $onHandQuantityUpdater, OrderInterface $order) { $onHandQuantityUpdater->decrease($order)->willThrow(\InvalidArgumentException::class); $this->shouldThrow(HandleException::class)->during('handle', [$order]); }