public function testGetMinimalPrice() { $expectedResult = 5; $this->saleableInterfaceMock->expects($this->once())->method('getPrice')->will($this->returnValue($expectedResult)); $this->priceCurrencyMock->expects($this->once())->method('convertAndRound')->will($this->returnArgument(0)); $this->bundleCalculatorMock->expects($this->once())->method('getMinRegularAmount')->with($expectedResult, $this->saleableInterfaceMock)->will($this->returnValue($expectedResult)); $result = $this->regularPrice->getMinimalPrice(); $this->assertEquals($expectedResult, $result, 'Incorrect amount'); //Calling a second time, should use cached value $result = $this->regularPrice->getMinimalPrice(); $this->assertEquals($expectedResult, $result, 'Incorrect amount the second time'); }
public function testGetMinimalPriceForFixedPricedBundleWithOptions() { $price = 5; $minOptionPrice = 1; $expectedValue = $price + $minOptionPrice; $this->saleableInterfaceMock->expects($this->once())->method('getPrice')->will($this->returnValue($price)); $this->saleableInterfaceMock->expects($this->once())->method('getPriceType')->willReturn(Price::PRICE_TYPE_FIXED); $this->priceInfoMock->expects($this->atLeastOnce())->method('getPrice')->with(CustomOptionPrice::PRICE_CODE)->willReturn($this->customOptionPriceMock); $this->customOptionPriceMock->expects($this->once())->method('getCustomOptionRange')->with(true)->willReturn($minOptionPrice); $this->priceCurrencyMock->expects($this->once())->method('convertAndRound')->will($this->returnArgument(0)); $this->bundleCalculatorMock->expects($this->once())->method('getMinRegularAmount')->with($expectedValue, $this->saleableInterfaceMock)->will($this->returnValue($expectedValue)); $result = $this->regularPrice->getMinimalPrice(); $this->assertEquals($expectedValue, $result, 'Incorrect amount'); //Calling a second time, should use cached value $result = $this->regularPrice->getMinimalPrice(); $this->assertEquals($expectedValue, $result, 'Incorrect amount the second time'); }