示例#1
0
 /**
  * @return void
  */
 protected function prepareMock()
 {
     $this->saleableInterfaceMock = $this->getMock('Magento\\Catalog\\Model\\Product', [], [], '', false);
     $this->bundleCalculatorMock = $this->getMock('Magento\\Bundle\\Pricing\\Adjustment\\BundleCalculatorInterface');
     $this->basePriceMock = $this->getMock('Magento\\Catalog\\Pricing\\Price\\BasePrice', [], [], '', false);
     $this->basePriceMock->expects($this->any())->method('getValue')->will($this->returnValue($this->baseAmount));
     $this->bundleOptionMock = $this->getMockBuilder('Magento\\Bundle\\Pricing\\Price\\BundleOptionPrice')->disableOriginalConstructor()->getMock();
     $this->priceInfoMock = $this->getMock('Magento\\Framework\\Pricing\\PriceInfo\\Base', [], [], '', false);
     $this->priceInfoMock->expects($this->atLeastOnce())->method('getPrice')->will($this->returnValueMap([[\Magento\Catalog\Pricing\Price\BasePrice::PRICE_CODE, $this->basePriceMock], [BundleOptionPrice::PRICE_CODE, $this->bundleOptionMock]]));
     $this->saleableInterfaceMock->expects($this->once())->method('getPriceInfo')->will($this->returnValue($this->priceInfoMock));
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->finalPrice = new \Magento\Bundle\Pricing\Price\FinalPrice($this->saleableInterfaceMock, $this->quantity, $this->bundleCalculatorMock);
 }
示例#2
0
 /**
  * Test getMaximalPrice()
  */
 public function testGetMaximalPrice()
 {
     $basePrice = 10;
     $minimalPrice = 5;
     $this->basePriceMock->expects($this->once())->method('getValue')->will($this->returnValue($basePrice));
     $this->calculatorMock->expects($this->once())->method('getAmount')->with($this->equalTo($basePrice))->will($this->returnValue($minimalPrice));
     $result = $this->model->getMaximalPrice();
     $this->assertEquals($minimalPrice, $result);
 }
示例#3
0
 /**
  * @return void
  */
 protected function prepareMock()
 {
     $this->saleableInterfaceMock = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['getPriceType', 'getPriceInfo'])->getMock();
     $this->bundleCalculatorMock = $this->getMock('Magento\\Bundle\\Pricing\\Adjustment\\BundleCalculatorInterface');
     $this->basePriceMock = $this->getMock('Magento\\Catalog\\Pricing\\Price\\BasePrice', [], [], '', false);
     $this->basePriceMock->expects($this->any())->method('getValue')->will($this->returnValue($this->baseAmount));
     $this->bundleOptionMock = $this->getMockBuilder('Magento\\Bundle\\Pricing\\Price\\BundleOptionPrice')->disableOriginalConstructor()->getMock();
     $this->customOptionPriceMock = $this->getMockBuilder('\\Magento\\Catalog\\Pricing\\Price\\CustomOptionPrice')->disableOriginalConstructor()->getMock();
     $this->priceInfoMock = $this->getMock('Magento\\Framework\\Pricing\\PriceInfo\\Base', [], [], '', false);
     $this->priceInfoMock->expects($this->atLeastOnce())->method('getPrice')->will($this->returnValueMap([[\Magento\Catalog\Pricing\Price\BasePrice::PRICE_CODE, $this->basePriceMock], [BundleOptionPrice::PRICE_CODE, $this->bundleOptionMock], [CustomOptionPrice::PRICE_CODE, $this->customOptionPriceMock]]));
     $this->saleableInterfaceMock->expects($this->once())->method('getPriceInfo')->will($this->returnValue($this->priceInfoMock));
     $this->priceCurrencyMock = $this->getMock('\\Magento\\Framework\\Pricing\\PriceCurrencyInterface');
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->finalPrice = new \Magento\Bundle\Pricing\Price\FinalPrice($this->saleableInterfaceMock, $this->quantity, $this->bundleCalculatorMock, $this->priceCurrencyMock);
     $this->productOptionRepositoryMock = $this->getMockForAbstractClass(ProductCustomOptionRepositoryInterface::class);
     $reflection = new \ReflectionClass(get_class($this->finalPrice));
     $reflectionProperty = $reflection->getProperty('productOptionRepository');
     $reflectionProperty->setAccessible(true);
     $reflectionProperty->setValue($this->finalPrice, $this->productOptionRepositoryMock);
 }