예제 #1
0
 /**
  * Set up function
  */
 public function setUp()
 {
     $this->saleableMock = $this->getMock('Magento\\Catalog\\Model\\Product', [], [], '', false);
     $this->priceInfoMock = $this->basePriceMock = $this->getMock('Magento\\Framework\\Pricing\\PriceInfo\\Base', [], [], '', false);
     $this->basePriceMock = $this->getMock('Magento\\Catalog\\Pricing\\Price\\BasePrice', [], [], '', false);
     $this->calculatorMock = $this->getMock('Magento\\Framework\\Pricing\\Adjustment\\Calculator', [], [], '', false);
     $this->saleableMock->expects($this->once())->method('getPriceInfo')->will($this->returnValue($this->priceInfoMock));
     $this->priceInfoMock->expects($this->once())->method('getPrice')->with($this->equalTo(\Magento\Catalog\Pricing\Price\BasePrice::PRICE_CODE))->will($this->returnValue($this->basePriceMock));
     $this->model = new \Magento\Catalog\Pricing\Price\FinalPrice($this->saleableMock, 1, $this->calculatorMock);
 }
 public function testGetValue()
 {
     $priceValue = 10;
     $priceMock = $this->getMockBuilder('Magento\\Framework\\Pricing\\Price\\PriceInterface')->getMockForAbstractClass();
     $priceMock->expects($this->once())->method('getValue')->willReturn($priceValue);
     $this->priceInfoMock = $this->getMockBuilder('Magento\\Framework\\Pricing\\PriceInfo\\Base')->disableOriginalConstructor()->getMock();
     $this->priceInfoMock->expects($this->once())->method('getPrice')->with(ConfigurableProduct::PRICE_CODE)->willReturn($priceMock);
     $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $productMock->expects($this->once())->method('getPriceInfo')->willReturn($this->priceInfoMock);
     $wishlistItemOptionMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Item\\Option')->disableOriginalConstructor()->getMock();
     $wishlistItemOptionMock->expects($this->once())->method('getProduct')->willReturn($productMock);
     $this->saleableItem->expects($this->once())->method('getCustomOption')->with('simple_product')->willReturn($wishlistItemOptionMock);
     $this->assertEquals($priceValue, $this->model->getValue());
 }
 public function testGetAmount()
 {
     $resultPrice = rand(1, 9);
     $this->price->expects($this->once())->method('getValue')->willReturn($resultPrice);
     $this->priceInfo->expects($this->once())->method('getPrice')->with(BasePrice::PRICE_CODE)->willReturn($this->price);
     $this->calculator->expects($this->once())->method('getAmount')->with($resultPrice, $this->saleableItem)->willReturn($resultPrice);
     $this->assertEquals($resultPrice, $this->model->getAmount());
 }
예제 #4
0
 public function testGetValueWithNoCustomOption()
 {
     $priceMock = $this->getMockBuilder('Magento\\Framework\\Pricing\\Price\\PriceInterface')->getMockForAbstractClass();
     $priceMock->expects($this->once())->method('getValue')->willReturn(0);
     $this->priceInfoMock->expects($this->once())->method('getPrice')->with(BasePrice::PRICE_CODE)->willReturn($priceMock);
     $this->saleableItem->expects($this->once())->method('getLinksPurchasedSeparately')->willReturn(true);
     $this->saleableItem->expects($this->once())->method('getCustomOption')->with('downloadable_link_ids')->willReturn(null);
     $this->assertEquals(0, $this->model->getValue());
 }