protected function setUp() { $this->_layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false); $this->_columnSetMock = $this->_getColumnSetMock(); $returnValueMap = [['grid', 'grid.columnSet', 'grid.columnSet'], ['grid', 'reset_filter_button', 'reset_filter_button'], ['grid', 'search_button', 'search_button']]; $this->_layoutMock->expects($this->any())->method('getChildName')->will($this->returnValueMap($returnValueMap)); $this->_layoutMock->expects($this->any())->method('getBlock')->with('grid.columnSet')->will($this->returnValue($this->_columnSetMock)); $this->_layoutMock->expects($this->any())->method('createBlock')->with('Magento\\Backend\\Block\\Widget\\Button')->will($this->returnValue(\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Backend\\Block\\Widget\\Button'))); $this->_layoutMock->expects($this->any())->method('helper')->with('Magento\\Framework\\Json\\Helper\\Data')->will($this->returnValue(\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\Json\\Helper\\Data'))); $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Backend\\Block\\Widget\\Grid'); $this->_block->setLayout($this->_layoutMock); $this->_block->setNameInLayout('grid'); }
protected function setUp() { $this->_columnMock = $this->getMock('Magento\\Backend\\Block\\Widget\\Grid\\Column', ['setSortable', 'setRendererType', 'setFilterType'], [], '', false); $this->_layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false); $this->_layoutMock->expects($this->any())->method('getChildBlocks')->will($this->returnValue(['column' => $this->_columnMock])); $this->_factoryMock = $this->getMock('Magento\\Backend\\Model\\Widget\\Grid\\Row\\UrlGeneratorFactory', [], [], '', false); $this->_subtotalsMock = $this->getMock('Magento\\Backend\\Model\\Widget\\Grid\\SubTotals', [], [], '', false); $this->_totalsMock = $this->getMock('Magento\\Backend\\Model\\Widget\\Grid\\Totals', [], [], '', false); $arguments = ['layout' => $this->_layoutMock, 'generatorFactory' => $this->_factoryMock, 'totals' => $this->_totalsMock, 'subtotals' => $this->_subtotalsMock]; $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_block = $objectManagerHelper->getObject('Magento\\Backend\\Block\\Widget\\Grid\\ColumnSet', $arguments); $this->_block->setNameInLayout('grid.columnSet'); }