Ejemplo n.º 1
0
 public function testGetAmount()
 {
     $amount = 20.0;
     $priceMock = $this->getMockBuilder('Magento\\Framework\\Pricing\\Price\\PriceInterface')->getMockForAbstractClass();
     $this->priceInfoMock->expects($this->once())->method('getPrices')->willReturn([$priceMock]);
     $this->calculatorMock->expects($this->once())->method('getAmount')->with(false, $this->saleableItemMock)->willReturn($amount);
     $this->assertEquals($amount, $this->basePrice->getAmount());
 }
Ejemplo n.º 2
0
 public function testGetLinkAmount()
 {
     $amount = 100;
     $this->linkMock->expects($this->once())->method('getPrice')->will($this->returnValue($amount));
     $this->linkMock->expects($this->once())->method('getProduct')->will($this->returnValue($this->saleableItemMock));
     $this->calculatorMock->expects($this->once())->method('getAmount')->with($amount, $this->equalTo($this->saleableItemMock))->will($this->returnValue($amount));
     $result = $this->linkPrice->getLinkAmount($this->linkMock);
     $this->assertEquals($amount, $result);
 }
Ejemplo n.º 3
0
 /**
  * Test method testGetDisplayValue
  */
 public function testGetAmount()
 {
     $priceValue = 77;
     $convertedPrice = 56.32;
     $amountValue = 88;
     $this->saleableItemMock->expects($this->once())->method('getPrice')->will($this->returnValue($priceValue));
     $this->priceCurrencyMock->expects($this->any())->method('convertAndRound')->with($priceValue)->will($this->returnValue($convertedPrice));
     $this->calculatorMock->expects($this->once())->method('getAmount')->with($this->equalTo($convertedPrice))->will($this->returnValue($amountValue));
     $this->assertEquals($amountValue, $this->regularPrice->getAmount());
 }
Ejemplo n.º 4
0
 /**
  * test method testGetOptionValueModified with option is_percent = false
  */
 public function testGetOptionValueModifiedIsNotPercent()
 {
     $this->saleableItemMock->expects($this->once())->method('setParentId')->with($this->equalTo(true))->will($this->returnValue($this->returnSelf()));
     $this->priceModifier->expects($this->once())->method('modifyPrice')->with($this->equalTo(77.33), $this->equalTo($this->saleableItemMock))->will($this->returnValue(77.67));
     $this->calculatorMock->expects($this->once())->method('getAmount')->with($this->equalTo(77.67), $this->equalTo($this->saleableItemMock), $this->equalTo(\Magento\Weee\Pricing\Adjustment::ADJUSTMENT_CODE))->will($this->returnValue(80.98999999999999));
     $this->assertEquals(80.98999999999999, $this->attribute->getOptionValueModified(['is_percent' => false, 'pricing_value' => 77.33]));
 }
Ejemplo n.º 5
0
 /**
  * test method testGetOptionValueModified with option is_percent = false
  */
 public function testGetOptionValueModifiedIsNotPercent()
 {
     $this->saleableItemMock->expects($this->once())->method('setParentId')->with($this->equalTo(true))->will($this->returnValue($this->returnSelf()));
     $this->priceModifier->expects($this->once())->method('modifyPrice')->with($this->equalTo(77.33), $this->equalTo($this->saleableItemMock))->will($this->returnValue(77.67));
     $this->calculatorMock->expects($this->once())->method('getAmount')->with($this->equalTo(77.67), $this->equalTo($this->saleableItemMock), null, [\Magento\Catalog\Pricing\Price\CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true])->will($this->returnValue(80.98999999999999));
     $this->assertEquals(80.98999999999999, $this->attribute->getOptionValueModified(['is_percent' => false, 'pricing_value' => 77.33]));
 }
Ejemplo n.º 6
0
 /**
  * Test method testGetDisplayValue
  */
 public function testGetAmount()
 {
     $priceValue = 77;
     $amountValue = 88;
     $this->calculatorMock->expects($this->once())->method('getAmount')->with($this->equalTo($priceValue))->will($this->returnValue($amountValue));
     $this->saleableItemMock->expects($this->once())->method('getPrice')->will($this->returnValue($priceValue));
     $this->assertEquals($amountValue, $this->regularPrice->getAmount());
 }
Ejemplo n.º 7
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);
 }
Ejemplo n.º 8
0
 /**
  * @dataProvider dataProviderForGetterAmount
  */
 public function testGetterAmount($amountForBundle, $optionList, $expectedResult)
 {
     $this->baseCalculator->expects($this->atLeastOnce())->method('getAmount')->with($this->baseAmount, $this->saleableItem)->will($this->returnValue($this->createAmountMock($amountForBundle)));
     $options = [];
     foreach ($optionList as $optionData) {
         $options[] = $this->createOptionMock($optionData);
     }
     $price = $this->getMock('Magento\\Bundle\\Pricing\\Price\\BundleOptionPrice', [], [], '', false);
     $price->expects($this->atLeastOnce())->method('getOptions')->will($this->returnValue($options));
     $this->priceMocks[Price\BundleOptionPrice::PRICE_CODE] = $price;
     // Price type of saleable items
     $this->saleableItem->expects($this->any())->method('getPriceType')->will($this->returnValue(ProductPrice::PRICE_TYPE_DYNAMIC));
     $this->amountFactory->expects($this->atLeastOnce())->method('create')->with($expectedResult['fullAmount'], $expectedResult['adjustments']);
     if ($expectedResult['isMinAmount']) {
         $this->model->getAmount($this->baseAmount, $this->saleableItem);
     } else {
         $this->model->getMaxAmount($this->baseAmount, $this->saleableItem);
     }
 }
Ejemplo n.º 9
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);
 }