Ejemplo n.º 1
0
 public function testGetTotalAmount()
 {
     $totalAmount = 10;
     $itemMock = $this->getMockBuilder('\\Magento\\Sales\\Model\\Order\\Item')->disableOriginalConstructor()->getMock();
     $this->itemPriceRenderer->expects($this->once())->method('getTotalAmount')->with($itemMock)->will($this->returnValue($totalAmount));
     $this->assertEquals($totalAmount, $this->renderer->getTotalAmount($itemMock));
 }
Ejemplo n.º 2
0
 /**
  * Add tax data to result
  *
  * @param \Magento\Checkout\CustomerData\Cart $subject
  * @param array $result
  * @return array
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterGetSectionData(\Magento\Checkout\CustomerData\Cart $subject, $result)
 {
     $result['subtotal_incl_tax'] = $this->checkoutHelper->formatPrice($this->getSubtotalInclTax());
     $result['subtotal_excl_tax'] = $this->checkoutHelper->formatPrice($this->getSubtotalExclTax());
     $items = $this->getQuote()->getAllVisibleItems();
     if (is_array($result['items'])) {
         foreach ($result['items'] as $key => $itemAsArray) {
             if ($item = $this->findItemById($itemAsArray['item_id'], $items)) {
                 $this->itemPriceRenderer->setItem($item);
                 $this->itemPriceRenderer->setTemplate('checkout/cart/item/price/sidebar.phtml');
                 $result['items'][$key]['product_price'] = $this->itemPriceRenderer->toHtml();
             }
         }
     }
     return $result;
 }
Ejemplo n.º 3
0
 public function testGetBaseTotalAmount()
 {
     $baseRowTotal = 100;
     $baseTaxAmount = 10;
     $baseHiddenTaxAmount = 2;
     $baseDiscountAmount = 20;
     $expectedValue = 92;
     $itemMock = $this->getMockBuilder('\\Magento\\Sales\\Model\\Order\\Item')->disableOriginalConstructor()->setMethods(['getBaseRowTotal', 'getBaseTaxAmount', 'getBaseHiddenTaxAmount', 'getBaseDiscountAmount', '__wakeup'])->getMock();
     $itemMock->expects($this->once())->method('getBaseRowTotal')->will($this->returnValue($baseRowTotal));
     $itemMock->expects($this->once())->method('getBaseTaxAmount')->will($this->returnValue($baseTaxAmount));
     $itemMock->expects($this->once())->method('getBaseHiddenTaxAmount')->will($this->returnValue($baseHiddenTaxAmount));
     $itemMock->expects($this->once())->method('getBaseDiscountAmount')->will($this->returnValue($baseDiscountAmount));
     $this->assertEquals($expectedValue, $this->renderer->getBaseTotalAmount($itemMock));
 }
Ejemplo n.º 4
0
 /**
  * @param \Magento\Framework\View\Element\Template\Context $context
  * @param \Magento\Tax\Helper\Data $taxHelper
  * @param PriceCurrencyInterface $priceCurrency
  * @param \Magento\Weee\Helper\Data $weeeHelper
  * @param array $data
  */
 public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Tax\Helper\Data $taxHelper, PriceCurrencyInterface $priceCurrency, \Magento\Weee\Helper\Data $weeeHelper, array $data = array())
 {
     $this->weeeHelper = $weeeHelper;
     parent::__construct($context, $taxHelper, $priceCurrency, $data);
     $this->_isScopePrivate = true;
 }
Ejemplo n.º 5
0
 /**
  * Retrieve formated price, use different formatter depending on type of item
  *
  * @param float $price
  * @return string
  */
 public function formatPrice($price)
 {
     return $this->itemPriceRenderer->formatPrice($price);
 }