public function testRemoveQuoteItem() { $itemId = 1; $this->cartMock->expects($this->once())->method('removeItem')->with($itemId)->willReturnSelf(); $this->cartMock->expects($this->once())->method('save')->willReturnSelf(); $this->assertEquals($this->sidebar, $this->sidebar->removeQuoteItem($itemId)); }
/** * @return $this */ public function executeInternal() { $itemId = (int) $this->getRequest()->getParam('item_id'); try { $this->sidebar->checkQuoteItem($itemId); $this->sidebar->removeQuoteItem($itemId); return $this->jsonResponse(); } catch (LocalizedException $e) { return $this->jsonResponse($e->getMessage()); } catch (\Exception $e) { $this->logger->critical($e); return $this->jsonResponse($e->getMessage()); } }
/** * @return $this */ public function execute() { if (!$this->getFormKeyValidator()->validate($this->getRequest())) { return $this->resultRedirectFactory->create()->setPath('*/cart/'); } $itemId = (int) $this->getRequest()->getParam('item_id'); try { $this->sidebar->checkQuoteItem($itemId); $this->sidebar->removeQuoteItem($itemId); return $this->jsonResponse(); } catch (\Magento\Framework\Exception\LocalizedException $e) { return $this->jsonResponse($e->getMessage()); } catch (\Exception $e) { $this->logger->critical($e); return $this->jsonResponse($e->getMessage()); } }