Ejemplo n.º 1
0
 /**
  * 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());
 }
 /**
  * test for method getValue with type Fixed and selectionPriceType is empty or zero
  *
  * @param bool $useRegularPrice
  * @dataProvider useRegularPriceDataProvider
  */
 public function testGetValueTypeFixedWithoutSelectionPriceType($useRegularPrice)
 {
     $this->setupSelectionPrice($useRegularPrice);
     $regularPrice = 100.125;
     $discountedPrice = 70.453;
     $convertedValue = 100.247;
     $actualPrice = $useRegularPrice ? $convertedValue : $discountedPrice;
     $expectedPrice = $useRegularPrice ? round($convertedValue, 2) : round($discountedPrice, 2);
     $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($regularPrice));
     $this->priceCurrencyMock->expects($this->once())->method('convert')->with($regularPrice)->will($this->returnValue($convertedValue));
     if (!$useRegularPrice) {
         $this->discountCalculatorMock->expects($this->once())->method('calculateDiscount')->with($this->equalTo($this->bundleMock), $this->equalTo($convertedValue))->will($this->returnValue($discountedPrice));
     }
     $this->priceCurrencyMock->expects($this->once())->method('round')->with($actualPrice)->will($this->returnValue($expectedPrice));
     $this->assertEquals($expectedPrice, $this->selectionPrice->getValue());
 }