Example #1
0
 public function testUpdateQuoteItemWithZeroQty()
 {
     $itemId = 1;
     $itemQty = 0;
     $this->resolverMock->expects($this->never())->method('getLocale');
     $this->cartMock->expects($this->once())->method('updateItems')->with([$itemId => ['qty' => $itemQty]])->willReturnSelf();
     $this->cartMock->expects($this->once())->method('save')->willReturnSelf();
     $this->assertEquals($this->sidebar, $this->sidebar->updateQuoteItem($itemId, $itemQty));
 }
 /**
  * @return $this
  */
 public function execute()
 {
     $itemId = (int) $this->getRequest()->getParam('item_id');
     $itemQty = (int) $this->getRequest()->getParam('item_qty');
     try {
         $this->sidebar->checkQuoteItem($itemId);
         $this->sidebar->updateQuoteItem($itemId, $itemQty);
         return $this->jsonResponse();
     } catch (LocalizedException $e) {
         return $this->jsonResponse($e->getMessage());
     } catch (\Exception $e) {
         $this->logger->critical($e);
         return $this->jsonResponse($e->getMessage());
     }
 }