public function testRenderPrice() { $this->_appConfig->expects($this->once())->method('getValue')->will($this->returnValue('USD')); $currency = $this->getMock('Zend_Currency', array(), array(), '', false); $currency->expects($this->once())->method('toCurrency')->with('100.0000')->will($this->returnValue('$100.00')); $this->_locale->expects($this->once())->method('getCurrency')->with('USD')->will($this->returnValue($currency)); $this->assertEquals('$100.00', $this->_block->renderPrice(100)); }
/** * @dataProvider getVariationWizardDataProvider * @param string $wizardBlockName * @param string $wizardHtml */ public function testGetVariationWizard($wizardBlockName, $wizardHtml) { $initData = ['some-key' => 'some-value']; $layout = $this->getMock('Magento\\Framework\\View\\LayoutInterface'); $wizardBlock = $this->getMock('Magento\\Ui\\Block\\Component\\StepsWizard', [], [], '', false); $layout->expects($this->any())->method('getChildName')->with(null, 'variation-steps-wizard')->willReturn($wizardBlockName); $layout->expects($this->any())->method('getBlock')->with($wizardBlockName)->willReturn($wizardBlock); $wizardBlock->expects($this->any())->method('setInitData')->with($initData); $wizardBlock->expects($this->any())->method('toHtml')->willReturn($wizardHtml); $this->_block->setLayout($layout); $this->assertEquals($wizardHtml, $this->_block->getVariationWizard($initData)); }
/** * Run test getProductStockQty method * * @return void */ public function testGetProductStockQty() { $productId = 10; $websiteId = 99; $qty = 100.0; $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, ['getQty']); $productMock->expects($this->once())->method('getId')->will($this->returnValue($productId)); $productMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $storeMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue($websiteId)); $this->stockRegistryMock->expects($this->once())->method('getStockItem')->with($productId, $websiteId)->will($this->returnValue($stockItemMock)); $stockItemMock->expects($this->once())->method('getQty')->will($this->returnValue($qty)); $this->assertEquals($qty, $this->_block->getProductStockQty($productMock)); }