public function testSave() { $itemId = 1; $quoteItem = $this->getMock('\\Magento\\Sales\\Model\\Quote\\Item', ['getIsVirtual', '__wakeup'], [], '', false); $this->quoteMock->expects($this->once())->method('getItemById')->with($itemId)->will($this->returnValue($quoteItem)); $quoteItem->expects($this->once())->method('getIsVirtual')->will($this->returnValue(0)); $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock)); $this->helperMock->expects($this->once())->method('isMessagesAllowed')->with('items', $this->quoteMock, $this->storeMock)->will($this->returnValue(true)); $this->giftMessageManagerMock->expects($this->once())->method('setMessage')->with($this->quoteMock, 'quote_item', $this->messageMock, $itemId)->will($this->returnValue($this->giftMessageManagerMock)); $this->assertTrue($this->itemRepository->save($this->cartId, $this->messageMock, $itemId)); }
/** * {@inheritDoc} */ public function save($cartId, MessageInterface $giftMessage, $itemId) { /** @var $quoteIdMask QuoteIdMask */ $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id'); return $this->repository->save($quoteIdMask->getQuoteId(), $giftMessage, $itemId); }