Example #1
0
 public function testFormatPriceInvoiceItem()
 {
     $price = 3.554;
     $formattedPrice = "\$3.55";
     $orderMock = $this->getMockBuilder('\\Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->setMethods(['formatPrice', '__wakeup'])->getMock();
     $orderMock->expects($this->once())->method('formatPrice')->with($price, false)->will($this->returnValue($formattedPrice));
     $orderItemMock = $this->getMockBuilder('\\Magento\\Sales\\Model\\Order\\Item')->disableOriginalConstructor()->setMethods(['getOrder', '__wakeup'])->getMock();
     $orderItemMock->expects($this->once())->method('getOrder')->will($this->returnValue($orderMock));
     $invoiceItemMock = $this->getMockBuilder('\\Magento\\Sales\\Model\\Invoice\\Item')->disableOriginalConstructor()->setMethods(['getOrderItem', '__wakeup', 'getStoreId'])->getMock();
     $invoiceItemMock->expects($this->once())->method('getOrderItem')->will($this->returnValue($orderItemMock));
     $this->renderer->setItem($invoiceItemMock);
     $this->assertEquals($formattedPrice, $this->renderer->formatPrice($price));
 }
Example #2
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);
 }