public function testGetTotalAmount() { $rowTotal = 100; $taxAmount = 10; $hiddenTaxAmount = 2; $discountAmount = 20; $expectedValue = $rowTotal + $taxAmount + $hiddenTaxAmount - $discountAmount; $itemMock = $this->getMockBuilder('\\Magento\\Sales\\Model\\Order\\Item')->disableOriginalConstructor()->setMethods(['getRowTotal', 'getTaxAmount', 'getHiddenTaxAmount', 'getDiscountAmount', '__wakeup'])->getMock(); $itemMock->expects($this->once())->method('getRowTotal')->will($this->returnValue($rowTotal)); $itemMock->expects($this->once())->method('getTaxAmount')->will($this->returnValue($taxAmount)); $itemMock->expects($this->once())->method('getHiddenTaxAmount')->will($this->returnValue($hiddenTaxAmount)); $itemMock->expects($this->once())->method('getDiscountAmount')->will($this->returnValue($discountAmount)); $this->assertEquals($expectedValue, $this->renderer->getTotalAmount($itemMock)); }
/** * Calculate total amount for the item * * @param Item|QuoteItem|InvoiceItem|CreditmemoItem $item * @return mixed */ public function getTotalAmount($item) { return $this->itemPriceRenderer->getTotalAmount($item); }