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)); }
/** * Prepare item html * * This method uses renderer for real product type * * @return string */ protected function _toHtml() { if ($this->getItem()->getOrderItem()) { $item = $this->getItem()->getOrderItem(); } else { $item = $this->getItem(); } if ($productType = $item->getRealProductType()) { $renderer = $this->getRenderedBlock()->getItemRenderer($productType); $renderer->setItem($this->getItem()); return $renderer->toHtml(); } return parent::_toHtml(); }
/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\Stdlib\String $string * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory * @param \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory * @param \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory * @param array $data */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Stdlib\String $string, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory, \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory, array $data = array()) { $this->_purchasedFactory = $purchasedFactory; $this->_itemsFactory = $itemsFactory; parent::__construct($context, $string, $productOptionFactory, $data); }