/** * Test testGetProductPriceHtml */ public function testGetProductPriceHtml() { $expectedPriceHtml = '<html>Expected Price html with price $30</html>'; $priceRenderBlock = $this->getMock('Magento\\Framework\\Pricing\\Render', ['render'], [], '', false); $product = $this->getMock('Magento\\Catalog\\Model\\Product', [], [], '', false); $this->layoutMock->expects($this->once())->method('getBlock')->with('product.price.render.default')->will($this->returnValue($priceRenderBlock)); $priceRenderBlock->expects($this->once())->method('render')->will($this->returnValue($expectedPriceHtml)); $this->assertEquals($expectedPriceHtml, $this->block->getProductPriceHtml($product, 'price_code', 'zone_code')); }
/** * {@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); } }
public function testGetImage() { $imageId = 'test_image_id'; $attributes = []; $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock(); $imageMock = $this->getMockBuilder('Magento\\Catalog\\Block\\Product\\Image')->disableOriginalConstructor()->getMock(); $this->imageBuilder->expects($this->once())->method('setProduct')->with($productMock)->willReturnSelf(); $this->imageBuilder->expects($this->once())->method('setImageId')->with($imageId)->willReturnSelf(); $this->imageBuilder->expects($this->once())->method('setAttributes')->with($attributes)->willReturnSelf(); $this->imageBuilder->expects($this->once())->method('create')->willReturn($imageMock); $this->assertInstanceOf('Magento\\Catalog\\Block\\Product\\Image', $this->block->getImage($productMock, $imageId, $attributes)); }
/** * Run test getMinimalQty method * * @param int $minSale * @param int|null $result * @return void * * @dataProvider dataProviderGetMinimalQty */ public function testGetMinimalQty($minSale, $result) { $id = 10; $websiteId = 99; $productMock = $this->getMock('Magento\\Catalog\\Model\\Product', ['getId', 'getStore'], [], '', false); $storeMock = $this->getMock('Magento\\Store\\Model\\Store', ['getWebsiteId'], [], '', false); $stockItemMock = $this->getMockForAbstractClass('Magento\\CatalogInventory\\Api\\Data\\StockItemInterface', [], '', false, true, true, ['getMinSaleQty']); $this->stockRegistryMock->expects($this->once())->method('getStockItem')->with($id, $websiteId)->will($this->returnValue($stockItemMock)); $productMock->expects($this->once())->method('getId')->will($this->returnValue($id)); $productMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $storeMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue($websiteId)); $stockItemMock->expects($this->once())->method('getMinSaleQty')->will($this->returnValue($minSale)); /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $productMock */ $this->assertEquals($result, $this->block->getMinimalQty($productMock)); }
/** * {@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); } }