Esempio n. 1
0
 public function testSuggestItemsQty()
 {
     $data = [[], ['qty' => -2], ['qty' => 3], ['qty' => 3.5], ['qty' => 5], ['qty' => 4]];
     $this->quoteMock->expects($this->any())->method('getItemById')->will($this->returnValueMap([[2, $this->prepareQuoteItemMock(2)], [3, $this->prepareQuoteItemMock(3)], [4, $this->prepareQuoteItemMock(4)], [5, $this->prepareQuoteItemMock(5)]]));
     $this->stockState->expects($this->at(0))->method('suggestQty')->will($this->returnValue(3.0));
     $this->stockState->expects($this->at(1))->method('suggestQty')->will($this->returnValue(3.5));
     $this->checkoutSessionMock->expects($this->any())->method('getQuote')->will($this->returnValue($this->quoteMock));
     $this->assertSame([[], ['qty' => -2], ['qty' => 3.0, 'before_suggest_qty' => 3.0], ['qty' => 3.5, 'before_suggest_qty' => 3.5], ['qty' => 5], ['qty' => 4]], $this->cart->suggestItemsQty($data));
 }
Esempio n. 2
0
 public function testSuggestItemsQty()
 {
     $data = [[], ['qty' => -2], ['qty' => 3], ['qty' => 3.5], ['qty' => 5], ['qty' => 4]];
     $quote = $this->getMock('Magento\\Sales\\Model\\Quote', [], [], '', false);
     $quote->expects($this->any())->method('getItemById')->will($this->returnValueMap([[2, $this->prepareQuoteItemMock(2)], [3, $this->prepareQuoteItemMock(3)], [4, $this->prepareQuoteItemMock(4)], [5, $this->prepareQuoteItemMock(5)]]));
     $this->stockItemMock->expects($this->any())->method('suggestQty')->will($this->returnValueMap([[4, 3.0, 3.0], [5, 3.5, 3.5]]));
     $this->checkoutSessionMock->expects($this->once())->method('getQuote')->will($this->returnValue($quote));
     $this->assertSame([[], ['qty' => -2], ['qty' => 3.0, 'before_suggest_qty' => 3.0], ['qty' => 3.5, 'before_suggest_qty' => 3.5], ['qty' => 5], ['qty' => 4]], $this->cart->suggestItemsQty($data));
 }