コード例 #1
0
ファイル: OptionTest.php プロジェクト: Doability/magento2dev
 public function testGetRegularPrice()
 {
     $priceInfoMock = $this->getMockForAbstractClass('Magento\\Framework\\Pricing\\PriceInfoInterface', [], '', false, false, true, ['getAmount', 'getPrice']);
     $priceInfoMock->expects($this->once())->method('getPrice')->willReturnSelf();
     $amountMock = $this->getMockForAbstractClass('Magento\\Framework\\Pricing\\Amount\\AmountInterface');
     $priceInfoMock->expects($this->once())->method('getAmount')->willReturn($amountMock);
     $this->productMock->expects($this->once())->method('getPriceInfo')->willReturn($priceInfoMock);
     $amountMock->expects($this->once())->method('getValue')->willReturn(50);
     $this->model->setPrice(50);
     $this->model->setPriceType(\Magento\Catalog\Model\Product\Option\Value::TYPE_PERCENT);
     $this->assertEquals(25, $this->model->getRegularPrice());
     $this->model->setPriceType(null);
     $this->assertEquals(50, $this->model->getRegularPrice());
 }
コード例 #2
0
 /**
  * Get price configuration
  *
  * @param \Magento\Catalog\Model\Product\Option\Value|\Magento\Catalog\Model\Product\Option $option
  * @return array
  */
 protected function _getPriceConfiguration($option)
 {
     $optionPrice = $this->pricingHelper->currency($option->getPrice(true), false, false);
     $data = ['prices' => ['oldPrice' => ['amount' => $this->pricingHelper->currency($option->getRegularPrice(), false, false), 'adjustments' => []], 'basePrice' => ['amount' => $this->_catalogData->getTaxPrice($option->getProduct(), $optionPrice, false, null, null, null, null, null, false)], 'finalPrice' => ['amount' => $this->_catalogData->getTaxPrice($option->getProduct(), $optionPrice, true, null, null, null, null, null, false)]], 'type' => $option->getPriceType(), 'name' => $option->getTitle()];
     return $data;
 }