_columnMock = $this->createPartialMock( \Magento\Backend\Block\Widget\Grid\Column::class, ['setSortable', 'setRendererType', 'setFilterType', 'addHeaderCssClass', 'setGrid'] ); $this->_layoutMock = $this->createMock(\Magento\Framework\View\Layout::class); $this->_layoutMock->expects( $this->any() )->method( 'getChildBlocks' )->will( $this->returnValue([$this->_columnMock]) ); $context = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( \Magento\Framework\View\Element\Template\Context::class, ['layout' => $this->_layoutMock] ); $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( \Magento\Framework\View\LayoutInterface::class )->createBlock( \Magento\Backend\Block\Widget\Grid\ColumnSet::class, '', ['context' => $context] ); $this->_block->setTemplate(null); } public function testBeforeToHtmlAddsClassToLastColumn() { $this->_columnMock->expects($this->any())->method('addHeaderCssClass')->with($this->equalTo('last')); $this->_block->toHtml(); } }