Beispiel #1
0
 public function testGetJsonConfig()
 {
     $regularPrice = 11.0;
     $finalPrice = 10.0;
     $price = 5.0;
     $oldPrice = 4.0;
     $linkPrice = 3.0;
     $linkIncludeTaxPrice = 4.0;
     $linkExcludeTaxPrice = 3.0;
     $linkId = 42;
     $config = ['price' => $price, 'oldPrice' => $oldPrice, 'links' => [$linkId => ['price' => $linkPrice, 'oldPrice' => $linkPrice, 'inclTaxPrice' => $linkIncludeTaxPrice, 'exclTaxPrice' => $linkExcludeTaxPrice]]];
     $linkAmountMock = $this->getMock('Magento\\Framework\\Pricing\\Amount\\Base', [], [], '', false);
     $linkAmountMock->expects($this->once())->method('getValue')->will($this->returnValue($linkIncludeTaxPrice));
     $linkAmountMock->expects($this->once())->method('getBaseAmount')->will($this->returnValue($linkExcludeTaxPrice));
     $amountMock = $this->getMock('Magento\\Framework\\Pricing\\Amount\\Base', [], [], '', false);
     $amountMock->expects($this->once())->method('getValue')->will($this->returnValue($finalPrice));
     $typeInstanceMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Type\\Simple', ['getLinks'], [], '', false);
     $typeInstanceMock->expects($this->once())->method('getLinks')->will($this->returnValue([$this->getLinkMock($linkPrice, $linkId)]));
     $this->productMock->expects($this->once())->method('getTypeInstance')->will($this->returnValue($typeInstanceMock));
     $regularPriceMock = $this->getMock('Magento\\Catalog\\Pricing\\Price\\RegularPrice', [], [], '', false);
     $regularPriceMock->expects($this->once())->method('getValue')->will($this->returnValue($regularPrice));
     $finalPriceMock = $this->getMock('Magento\\Catalog\\Pricing\\Price\\FinalPrice', [], [], '', false);
     $finalPriceMock->expects($this->at(0))->method('getAmount')->will($this->returnValue($amountMock));
     $finalPriceMock->expects($this->at(1))->method('getCustomAmount')->with($linkPrice)->will($this->returnValue($linkAmountMock));
     $this->coreHelper->expects($this->at(0))->method('currency')->with($finalPrice, false, false)->will($this->returnValue($price));
     $this->coreHelper->expects($this->at(1))->method('currency')->with($regularPrice, false, false)->will($this->returnValue($oldPrice));
     $this->coreHelper->expects($this->at(2))->method('currency')->with($linkPrice, false, false)->will($this->returnValue($linkPrice));
     $this->coreHelper->expects($this->at(3))->method('currency')->with($linkIncludeTaxPrice, false, false)->will($this->returnValue($linkIncludeTaxPrice));
     $this->coreHelper->expects($this->at(4))->method('currency')->with($linkExcludeTaxPrice, false, false)->will($this->returnValue($linkExcludeTaxPrice));
     $this->priceInfoMock->expects($this->at(0))->method('getPrice')->with(FinalPrice::PRICE_CODE)->will($this->returnValue($finalPriceMock));
     $this->priceInfoMock->expects($this->at(1))->method('getPrice')->with(RegularPrice::PRICE_CODE)->will($this->returnValue($regularPriceMock));
     $this->priceInfoMock->expects($this->at(2))->method('getPrice')->with(FinalPrice::PRICE_CODE)->will($this->returnValue($finalPriceMock));
     $this->assertEquals(json_encode($config), $this->linksBlock->getJsonConfig());
 }
 /**
  * {@inheritdoc}
  */
 public function getImage($product, $imageId, $attributes = array())
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getImage');
     if (!$pluginInfo) {
         return parent::getImage($product, $imageId, $attributes);
     } else {
         return $this->___callPlugins('getImage', func_get_args(), $pluginInfo);
     }
 }
Beispiel #3
0
 public function testGetJsonConfig()
 {
     $linkPrice = 3.0;
     $linkId = 42;
     $config = ['links' => [$linkId => ['finalPrice' => $linkPrice]]];
     $linkAmountMock = $this->getMock('Magento\\Framework\\Pricing\\Amount\\AmountInterface', [], [], '', false);
     $linkAmountMock->expects($this->once())->method('getValue')->will($this->returnValue($linkPrice));
     $typeInstanceMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Type\\Simple', ['getLinks'], [], '', false);
     $typeInstanceMock->expects($this->once())->method('getLinks')->will($this->returnValue([$this->getLinkMock($linkPrice, $linkId)]));
     $this->productMock->expects($this->once())->method('getTypeInstance')->will($this->returnValue($typeInstanceMock));
     $finalPriceMock = $this->getMock('Magento\\Catalog\\Pricing\\Price\\FinalPrice', [], [], '', false);
     $finalPriceMock->expects($this->once())->method('getCustomAmount')->with($linkPrice)->will($this->returnValue($linkAmountMock));
     $this->priceInfoMock->expects($this->once())->method('getPrice')->with(FinalPrice::PRICE_CODE)->will($this->returnValue($finalPriceMock));
     $json = json_encode($config);
     $this->jsonEncoder->expects($this->once())->method('encode')->with($config)->will($this->returnValue($json));
     $encodedJsonConfig = $this->linksBlock->getJsonConfig();
     $this->assertEquals(json_encode($config), $encodedJsonConfig);
 }
 /**
  * {@inheritdoc}
  */
 public function offsetGet($offset)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'offsetGet');
     if (!$pluginInfo) {
         return parent::offsetGet($offset);
     } else {
         return $this->___callPlugins('offsetGet', func_get_args(), $pluginInfo);
     }
 }