/**
  * Returns max price
  *
  * @return \Magento\Framework\Pricing\Amount\AmountInterface
  */
 public function getMaximalPrice()
 {
     if (null === $this->maximalPrice) {
         $this->maximalPrice = $this->calculator->getMaxRegularAmount($this->getValue(), $this->product);
     }
     return $this->maximalPrice;
 }
 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');
 }
 /**
  * Returns max price
  *
  * @return \Magento\Framework\Pricing\Amount\AmountInterface
  */
 public function getMaximalPrice()
 {
     if (null === $this->maximalPrice) {
         $price = $this->getValue();
         if ($this->product->getPriceType() == Price::PRICE_TYPE_FIXED) {
             /** @var \Magento\Catalog\Pricing\Price\CustomOptionPrice $customOptionPrice */
             $customOptionPrice = $this->priceInfo->getPrice(CustomOptionPrice::PRICE_CODE);
             $price += $customOptionPrice->getCustomOptionRange(false);
         }
         $this->maximalPrice = $this->calculator->getMaxRegularAmount($price, $this->product);
     }
     return $this->maximalPrice;
 }
 /**
  * Option amount calculation for bundle product
  *
  * @param float $baseValue
  * @return \Magento\Framework\Pricing\Amount\AmountInterface
  */
 public function getConfiguredAmount($baseValue = 0.0)
 {
     $selectionPriceList = [];
     foreach ($this->getOptions() as $option) {
         $selectionPriceList = array_merge($selectionPriceList, $this->calculator->createSelectionPriceList($option, $this->product));
     }
     return $this->calculator->calculateBundleAmount($baseValue, $this->product, $selectionPriceList);
 }
Ejemplo n.º 5
0
 /**
  * @dataProvider getValueDataProvider
  */
 public function testGetMinimalPrice($baseAmount)
 {
     $result = rand(1, 10);
     $this->baseAmount = $baseAmount;
     $this->prepareMock();
     $this->bundleCalculatorMock->expects($this->once())->method('getAmount')->with($this->equalTo($this->baseAmount), $this->equalTo($this->saleableInterfaceMock))->will($this->returnValue($result));
     $this->assertSame($result, $this->finalPrice->getMinimalPrice());
 }
Ejemplo n.º 6
0
 public function testGetPriceWithoutOption()
 {
     $result = 5;
     $this->prepareMock();
     $this->bundleCalculatorMock->expects($this->once())->method('getAmountWithoutOption')->with($this->equalTo($this->baseAmount), $this->equalTo($this->saleableInterfaceMock))->will($this->returnValue($result));
     $this->assertSame($result, $this->finalPrice->getPriceWithoutOption());
     //The second call should use cached value
     $this->assertSame($result, $this->finalPrice->getPriceWithoutOption());
 }
 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');
 }
Ejemplo n.º 8
0
 public function testGetAmount()
 {
     $amountMock = $this->getMock('Magento\\Framework\\Pricing\\Amount\\AmountInterface');
     $this->bundleCalculatorMock->expects($this->once())->method('getOptionsAmount')->with($this->equalTo($this->saleableItemMock))->will($this->returnValue($amountMock));
     $this->assertSame($amountMock, $this->bundleOptionPrice->getAmount());
 }
Ejemplo n.º 9
0
 /**
  * Get minimal amount of bundle price with options
  *
  * @return \Magento\Framework\Pricing\Amount\AmountInterface
  */
 public function getAmount()
 {
     return $this->calculator->getOptionsAmount($this->product);
 }