コード例 #1
0
 public function testGetOptionHtml()
 {
     $option = $this->getMock('\\Magento\\Bundle\\Model\\Option', array('getType', '__wakeup'), array(), '', false);
     $option->expects($this->exactly(1))->method('getType')->will($this->returnValue('checkbox'));
     $optionBlock = $this->getMock('\\Magento\\Bundle\\Block\\Catalog\\Product\\View\\Type\\Bundle\\Option\\Checkbox', array('setOption', 'toHtml'), array(), '', false);
     $optionBlock->expects($this->any())->method('setOption')->will($this->returnValue($optionBlock));
     $optionBlock->expects($this->any())->method('toHtml')->will($this->returnValue('option html'));
     $layout = $this->getMock('Magento\\Framework\\View\\Layout', array('getChildName', 'getBlock'), array(), '', false);
     $layout->expects($this->any())->method('getChildName')->will($this->returnValue('name'));
     $layout->expects($this->any())->method('getBlock')->will($this->returnValue($optionBlock));
     $this->_bundleBlock->setLayout($layout);
     $this->assertEquals('option html', $this->_bundleBlock->getOptionHtml($option));
 }
コード例 #2
0
 /**
  * {@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);
     }
 }
コード例 #3
0
 public function testGetJsonConfigFixedPriceBundle()
 {
     $baseAmount = 123;
     $basePriceValue = 123123;
     $selections = [$this->createOptionSelection(1123, 'Selection 1', 23, [['price' => new MagentoObject(['base_amount' => $baseAmount, 'value' => $basePriceValue])]], true, true)];
     $bundleProductPrice = $this->getMockBuilder('\\Magento\\Bundle\\Model\\Product\\Price')->disableOriginalConstructor()->setMethods(['getLowestPrice'])->getMock();
     $bundleProductPrice->expects($this->at(0))->method('getLowestPrice')->with($this->product, $baseAmount)->will($this->returnValue(999));
     $bundleProductPrice->expects($this->at(1))->method('getLowestPrice')->with($this->product, $basePriceValue)->will($this->returnValue(888));
     $this->bundleProductPriceFactory->expects($this->once())->method('create')->will($this->returnValue($bundleProductPrice));
     $options = [$this->createOption(1, 'Title `1', $selections)];
     $finalPriceMock = $this->getPriceMock(['getPriceWithoutOption' => new MagentoObject(['value' => 100, 'base_amount' => 100])]);
     $regularPriceMock = $this->getPriceMock(['getAmount' => new MagentoObject(['value' => 110, 'base_amount' => 110])]);
     $prices = ['bundle_option' => $this->getAmountPriceMock($baseAmount, $regularPriceMock, [['item' => $selections[0], 'value' => $basePriceValue, 'base_amount' => 321321]]), \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE => $finalPriceMock, \Magento\Catalog\Pricing\Price\RegularPrice::PRICE_CODE => $regularPriceMock];
     $priceInfo = $this->getPriceInfoMock($prices);
     $this->product->expects($this->once())->method('hasPreconfiguredValues')->will($this->returnValue(true));
     $preconfiguredValues = new \Magento\Framework\DataObject(['bundle_option' => [1 => 123123111]]);
     $this->product->expects($this->once())->method('getPreconfiguredValues')->will($this->returnValue($preconfiguredValues));
     $this->_bundleBlock = $this->setupBundleBlock($options, $priceInfo, \Magento\Bundle\Model\Product\Price::PRICE_TYPE_FIXED);
     $jsonConfig = $this->_bundleBlock->getJsonConfig();
     $this->assertEquals(110, $jsonConfig['prices']['oldPrice']['amount']);
     $this->assertEquals(100, $jsonConfig['prices']['basePrice']['amount']);
     $this->assertEquals(100, $jsonConfig['prices']['finalPrice']['amount']);
 }
コード例 #4
0
 /**
  * {@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);
     }
 }