/** * @dataProvider showRangePriceDataProvider */ public function testShowRangePrice($value, $maxValue, $result) { $priceInfo = $this->getMock('Magento\\Framework\\Pricing\\PriceInfo\\Base', [], [], '', false); $optionPrice = $this->getMockBuilder('Magento\\Bundle\\Pricing\\Price\\BundleOptionPrice')->disableOriginalConstructor()->getMock(); $this->saleableItem->expects($this->atLeastOnce())->method('getPriceInfo')->will($this->returnValue($priceInfo)); $priceInfo->expects($this->atLeastOnce())->method('getPrice')->with(Price\BundleOptionPrice::PRICE_CODE)->will($this->returnValue($optionPrice)); $optionPrice->expects($this->once())->method('getValue')->will($this->returnValue($value)); $optionPrice->expects($this->once())->method('getMaxValue')->will($this->returnValue($maxValue)); $this->assertEquals($result, $this->model->showRangePrice()); }
/** * @dataProvider showRangePriceDataProvider */ public function testShowRangePrice($optMinValue, $optMaxValue, $custMinValue, $custMaxValue, $expectedShowRange) { $enableCustomOptionMocks = $optMinValue == $optMaxValue; $priceInfo = $this->getMock('Magento\\Framework\\Pricing\\PriceInfo\\Base', [], [], '', false); $bundleOptionPrice = $this->getMockBuilder('Magento\\Bundle\\Pricing\\Price\\BundleOptionPrice')->disableOriginalConstructor()->getMock(); $customOptionPrice = $this->getMockBuilder('Magento\\Catalog\\Pricing\\Price\\CustomOptionPrice')->disableOriginalConstructor()->getMock(); $this->saleableItem->expects($this->atLeastOnce())->method('getPriceInfo')->will($this->returnValue($priceInfo)); $priceInfo->expects($this->at(0))->method('getPrice')->with(Price\BundleOptionPrice::PRICE_CODE)->will($this->returnValue($bundleOptionPrice)); if ($enableCustomOptionMocks) { $priceInfo->expects($this->at(1))->method('getPrice')->with(CustomOptionPrice::PRICE_CODE)->will($this->returnValue($customOptionPrice)); } $bundleOptionPrice->expects($this->once())->method('getValue')->will($this->returnValue($optMinValue)); $bundleOptionPrice->expects($this->once())->method('getMaxValue')->will($this->returnValue($optMaxValue)); if ($enableCustomOptionMocks) { $customOptionPrice->expects($this->at(0))->method('getCustomOptionRange')->will($this->returnValue($custMinValue)); $customOptionPrice->expects($this->at(1))->method('getCustomOptionRange')->will($this->returnValue($custMaxValue)); } $this->assertEquals($expectedShowRange, $this->model->showRangePrice()); }