/** * test for method getValue with type Fixed and selectionPriceType is empty or zero */ public function testGetValueTypeFixedWithoutSelectionPriceType() { $this->bundleMock->expects($this->once())->method('getPriceType')->will($this->returnValue(\Magento\Bundle\Model\Product\Price::PRICE_TYPE_FIXED)); $this->productMock->expects($this->once())->method('getSelectionPriceType')->will($this->returnValue(false)); $this->productMock->expects($this->any())->method('getSelectionPriceValue')->will($this->returnValue(100)); $this->discountCalculatorMock->expects($this->once())->method('calculateDiscount')->with($this->equalTo($this->bundleMock), $this->equalTo(100))->will($this->returnValue(70)); $this->assertEquals(70, $this->selectionPrice->getValue()); }
public function testGetAmount() { $this->setupSelectionPrice(); $price = 10.0; $amount = 20.0; $this->priceInfoMock->expects($this->once())->method('getPrice')->with(\Magento\Bundle\Pricing\Price\FinalPrice::PRICE_CODE)->willReturn($this->finalPriceMock); $this->finalPriceMock->expects($this->once())->method('getValue')->willReturn($price); $this->discountCalculatorMock->expects($this->once())->method('calculateDiscount')->with($this->bundleMock, $price)->willReturn($price); $this->priceCurrencyMock->expects($this->once())->method('round')->with($price)->willReturn($price); $this->bundleMock->expects($this->any())->method('getPriceType')->willReturn(\Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC); $this->calculatorMock->expects($this->once())->method('getAmount')->with($price, $this->productMock, null)->willReturn($amount); $this->assertEquals($amount, $this->selectionPrice->getAmount()); }
public function testGetProductDynamicBundle() { $this->bundleMock->expects($this->any())->method('getPriceType')->will($this->returnValue(\Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC)); $product = $this->selectionPrice->getProduct(); $this->assertEquals($this->productMock, $product); }