public function testGetMinimalPriceFixedBundleWithOption()
 {
     $optionMaxPrice = 2;
     $this->baseAmount = 5;
     $result = 7;
     $this->prepareMock();
     $this->saleableInterfaceMock->expects($this->once())->method('getPriceType')->willReturn(Price::PRICE_TYPE_FIXED);
     $this->customOptionPriceMock->expects($this->once())->method('getCustomOptionRange')->with(true)->willReturn($optionMaxPrice);
     $this->bundleCalculatorMock->expects($this->once())->method('getAmount')->with($this->equalTo($this->baseAmount + $optionMaxPrice), $this->equalTo($this->saleableInterfaceMock))->will($this->returnValue($result));
     $this->assertSame($result, $this->finalPrice->getMinimalPrice());
     //The second call should use cached value
     $this->assertSame($result, $this->finalPrice->getMinimalPrice());
 }
Example #2
0
 public function testGetMinimalPriceFixedBundleWithOption()
 {
     $optionMaxPrice = 2;
     $this->baseAmount = 5;
     $result = 7;
     $this->prepareMock();
     $customOptions = [$this->getMockBuilder(\Magento\Catalog\Api\Data\ProductCustomOptionInterface::class)->setMethods(['setProduct'])->getMockForAbstractClass()];
     $this->productOptionRepositoryMock->expects(static::once())->method('getProductOptions')->with($this->saleableInterfaceMock)->willReturn($customOptions);
     $this->saleableInterfaceMock->expects($this->once())->method('getPriceType')->willReturn(Price::PRICE_TYPE_FIXED);
     $this->customOptionPriceMock->expects($this->once())->method('getCustomOptionRange')->with(true)->willReturn($optionMaxPrice);
     $this->bundleCalculatorMock->expects($this->once())->method('getAmount')->with($this->equalTo($this->baseAmount + $optionMaxPrice), $this->equalTo($this->saleableInterfaceMock))->will($this->returnValue($result));
     $this->assertSame($result, $this->finalPrice->getMinimalPrice());
     //The second call should use cached value
     $this->assertSame($result, $this->finalPrice->getMinimalPrice());
 }
 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');
 }
Example #4
0
 /**
  * Test getOptions()
  */
 public function testGetOptions()
 {
     $price = 100;
     $displayValue = 120;
     $id = 1;
     $expected = [$id => [$price => ['base_amount' => $price, 'adjustment' => $displayValue]]];
     $this->amount->expects($this->once())->method('getValue')->will($this->returnValue(120));
     $this->calculator->expects($this->once())->method('getAmount')->will($this->returnValue($this->amount));
     $optionValueMock = $this->getOptionValueMock($price);
     $optionValueMock->expects($this->once())->method('getId')->will($this->returnValue($id));
     $optionItemMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Option')->disableOriginalConstructor()->setMethods(['getValues', '__wakeup'])->getMock();
     $optionItemMock->expects($this->any())->method('getValues')->will($this->returnValue(array($optionValueMock)));
     $options = [$optionItemMock];
     $this->product->expects($this->once())->method('getOptions')->will($this->returnValue($options));
     $result = $this->object->getOptions();
     $this->assertEquals($expected, $result);
     $result = $this->object->getOptions();
     $this->assertEquals($expected, $result);
 }