/** * test for convert method */ public function testConvert() { $this->quoteItemMock->expects($this->exactly(2))->method('getProduct')->willReturn($this->productMock); $this->productMock->expects($this->once())->method('getTypeInstance')->willReturn($this->productTypeMock); $this->productTypeMock->expects($this->once())->method('getOrderOptions')->with($this->productMock)->willReturn(['option']); $this->objectCopyServiceMock->expects($this->at(0))->method('getDataFromFieldset')->with('quote_convert_item', 'to_order_item', $this->quoteItemMock)->willReturn([]); $this->objectCopyServiceMock->expects($this->at(1))->method('getDataFromFieldset')->with('quote_convert_item', 'to_order_item_discount', $this->quoteItemMock)->willReturn([]); $this->orderItemFactoryMock->expects($this->once())->method('create')->willReturn($this->orderItemMock); $this->assertInstanceOf('Magento\\Sales\\Model\\Order\\Item', $this->converter->convert($this->quoteItemMock, [])); }
public function testInitTotalsNoItems() { $address = $this->getMock('\\Magento\\Quote\\Model\\Quote\\Address', [], [], '', false); $this->item->expects($this->never())->method('getParentItemId'); $this->model->init($this->model->getWebsiteId(), $this->model->getCustomerGroupId(), $this->model->getCouponCode()); $this->model->initTotals([], $address); }
/** * @param $baseRowTotalInclTax * @param $baseRowWeeeTaxInclTax * @param $weeeEnabled * @param $expectedValue * @dataProvider testGetFinalDisplayPriceDataProvider */ public function testGetBaseFinalRowDisplayPriceInclTax($baseRowTotalInclTax, $baseRowWeeeTaxInclTax, $weeeEnabled, $expectedValue) { $this->weeeHelper->expects($this->once())->method('isEnabled')->will($this->returnValue($weeeEnabled)); $this->weeeHelper->expects($this->any())->method('getBaseRowWeeeTaxInclTax')->with($this->item)->will($this->returnValue($baseRowWeeeTaxInclTax)); $this->item->expects($this->once())->method('getBaseRowTotalInclTax')->will($this->returnValue($baseRowTotalInclTax)); $this->assertEquals($expectedValue, $this->renderer->getBaseFinalRowDisplayPriceInclTax()); }
/** * test compare two items first without options and second with options */ public function testCompareItemWithoutOptionWithCompared() { $this->itemMock->expects($this->any())->method('getProductId')->will($this->returnValue(1)); $this->comparedMock->expects($this->any())->method('getProductId')->will($this->returnValue(1)); $this->comparedMock->expects($this->any())->method('getOptions')->will($this->returnValue([$this->getOptionMock('option-1', 1), $this->getOptionMock('option-2', 'option-value'), $this->getOptionMock('option-3', serialize(['value' => 'value-1', 'qty' => 2]))])); $this->itemMock->expects($this->any())->method('getOptions')->will($this->returnValue([])); $this->assertFalse($this->helper->compare($this->itemMock, $this->comparedMock)); }
public function testSaveModifiedItem() { $this->entitySnapshotMock->expects($this->exactly(2))->method('isModified')->with($this->quoteItemMock)->willReturn(true); $this->quoteItemMock->expects($this->once())->method('isOptionsSaved')->willReturn(false); $this->quoteItemMock->expects($this->once())->method('saveItemOptions'); $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock); $this->assertEquals($this->model, $this->model->save($this->quoteItemMock)); }
/** * Verify that compare ignores empty options. */ public function testCompareWithEmptyValues() { $this->itemMock->expects($this->any())->method('getProductId')->will($this->returnValue(1)); $this->comparedMock->expects($this->any())->method('getProductId')->will($this->returnValue(1)); $this->itemMock->expects($this->once())->method('getOptions')->willReturn([$this->getOptionMock('option-1', serialize(['non-empty-option' => 'test', 'empty_option' => '']))]); $this->comparedMock->expects($this->once())->method('getOptions')->willReturn([$this->getOptionMock('option-1', serialize(['non-empty-option' => 'test']))]); $this->assertTrue($this->helper->compare($this->itemMock, $this->comparedMock)); }
public function testGetTotalAmount() { $rowTotal = 100; $taxAmount = 10; $hiddenTaxAmount = 2; $discountAmount = 20; $weeeTaxAppliedRowAmount = 10; $expectedResult = $rowTotal + $taxAmount + $hiddenTaxAmount - $discountAmount + $weeeTaxAppliedRowAmount; $this->itemMock->expects($this->once())->method('getRowTotal')->will($this->returnValue($rowTotal)); $this->itemMock->expects($this->once())->method('getTaxAmount')->will($this->returnValue($taxAmount)); $this->itemMock->expects($this->once())->method('getHiddenTaxAmount')->will($this->returnValue($hiddenTaxAmount)); $this->itemMock->expects($this->once())->method('getDiscountAmount')->will($this->returnValue($discountAmount)); $this->itemMock->expects($this->once())->method('getWeeeTaxAppliedRowAmount')->will($this->returnValue($weeeTaxAppliedRowAmount)); $this->assertEquals($expectedResult, $this->block->getTotalAmount($this->itemMock)); }