public function testPrepareLayoutInfoAdded() { $address = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Address')->disableOriginalConstructor()->setMethods(array('format', '__wakeup'))->getMock(); $this->_addressFactory->expects($this->once())->method('create')->will($this->returnValue($address)); $layout = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->getMock(); $this->_block->setLayout($layout); $this->assertNotEmpty($this->_block->getRenderedInfo()); }
public function testSetTemplateNoProduct() { $this->_helper->expects($this->once())->method('isStockAlertAllowed')->will($this->returnValue(true)); $this->_helper->expects($this->never())->method('getSaveUrl'); $this->_registry->expects($this->any())->method('registry')->with('current_product')->will($this->returnValue(null)); $this->_block->setLayout($this->_layout); $this->_block->setTemplate('path/to/template.phtml'); $this->assertEquals('', $this->_block->getTemplate()); $this->assertNull($this->_block->getSignupUrl()); }
/** * @covers \Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid::getItems */ public function testGetItems() { $productId = 8; $itemQty = 23; $layoutMock = $this->getMock('Magento\\Framework\\View\\LayoutInterface'); $blockMock = $this->getMock('Magento\\Framework\\View\\Element\\AbstractBlock', ['getItems'], [], '', false); $itemMock = $this->getMock('Magento\\Sales\\Model\\Quote\\Item', array('getProduct', 'setHasError', 'setQty', 'getQty', '__sleep', '__wakeup'), array(), '', false); $productMock = $this->getMock('Magento\\Catalog\\Model\\Product', array('getStockItem', 'getID', '__sleep', '__wakeup'), array(), '', false); $checkMock = $this->getMock('Magento\\Framework\\Object', ['getMessage', 'getHasError'], [], '', false); $layoutMock->expects($this->once())->method('getParentName')->will($this->returnValue('parentBlock')); $layoutMock->expects($this->once())->method('getBlock')->with('parentBlock')->will($this->returnValue($blockMock)); $blockMock->expects($this->once())->method('getItems')->will($this->returnValue(array($itemMock))); $itemMock->expects($this->any())->method('getChildren')->will($this->returnValue(array($itemMock))); $itemMock->expects($this->any())->method('getProduct')->will($this->returnValue($productMock)); $itemMock->expects($this->any())->method('getQty')->will($this->returnValue($itemQty)); $productMock->expects($this->any())->method('getId')->will($this->returnValue($productId)); $productMock->expects($this->any())->method('getStatus')->will($this->returnValue(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)); $checkMock->expects($this->any())->method('getMessage')->will($this->returnValue('Message')); $checkMock->expects($this->any())->method('getHasError')->will($this->returnValue(false)); $this->stockItemService->expects($this->once())->method('checkQuoteItemQty')->with($this->equalTo($productId), $this->equalTo($itemQty), $this->equalTo($itemQty))->will($this->returnValue($checkMock)); $this->block->getQuote()->setIsSuperMode(true); $items = $this->block->setLayout($layoutMock)->getItems(); $this->assertEquals('Message', $items[0]->getMessage()); $this->assertEquals(true, $this->block->getQuote()->getIsSuperMode()); }
public function testSetGetLayout() { $this->assertNull($this->_helper->getLayout()); $this->assertInstanceof(get_class($this->_helper), $this->_helper->setLayout(Mage::app()->getLayout())); $this->assertInstanceOf('Mage_Core_Model_Layout', $this->_helper->getLayout()); }