public function testGetRowUrl() { $itemMock = $this->getMock('Varien_Object', array(), array(), '', false); $rowUrlGenerator = $this->getMock('Mage_Backend_Model_Widget_Grid_Row_UrlGenerator', array(), array(), '', false); $rowUrlGenerator->expects($this->once())->method('getUrl')->with($this->equalTo($itemMock))->will($this->returnValue('http://localhost/mng/item/edit')); $model = new Mage_Backend_Block_Widget_Grid_ColumnSet(array('layout' => $this->_layoutMock, 'helper' => $this->_helperMock, 'rowUrl' => array('generator' => $rowUrlGenerator))); $url = $model->getRowUrl($itemMock); $this->assertEquals('http://localhost/mng/item/edit', $url); }
public function testToHtmlPreparesColumns() { $this->_columnSetMock->expects($this->once())->method('setRendererType'); $this->_columnSetMock->expects($this->once())->method('setFilterType'); $this->_columnSetMock->expects($this->once())->method('setSortable'); $this->_block->setColumnRenderers(array('filter' => 'Filter_Class')); $this->_block->setColumnFilters(array('filter' => 'Filter_Class')); $this->_block->setSortable(false); $this->_block->toHtml(); }
public function testGetTotals() { $collection = $this->_getTestCollection(); $this->_prepareLayoutWithGrid($this->_prepareGridMock($collection)); $this->_totalsMock->expects($this->once())->method('countTotals')->with($collection)->will($this->returnValue(new Varien_Object(array('test1' => '3', 'test2' => '2')))); $this->assertEquals(new Varien_Object(array('test1' => '3', 'test2' => '2')), $this->_block->getTotals()); }
public function testBeforeToHtmlAddsClassToLastColumn() { $this->_columnMock->expects($this->any())->method('addHeaderCssClass')->with($this->equalTo('last')); $this->_block->toHtml(); }
public function testGetMainButtonsHtmlReturnsEmptyStringIfFiltersArentVisible() { $this->_columnSetMock->expects($this->once())->method('isFilterVisible')->will($this->returnValue(false)); $this->_block->getMainButtonsHtml(); }
/** * Preparing layout * * @return Mage_Catalog_Block_Product_Configurable_AssociatedSelector_Backend_Grid_ColumnSet */ protected function _prepareLayout() { parent::_prepareLayout(); $product = $this->_getProduct(); $attributes = $this->_productType->getUsedProductAttributes($product); foreach ($attributes as $attribute) { /** @var $attribute Mage_Catalog_Model_Entity_Attribute */ /** @var $block Mage_Backend_Block_Widget_Grid_Column */ $block = $this->addChild($attribute->getAttributeCode(), 'Mage_Backend_Block_Widget_Grid_Column', array('header' => $attribute->getStoreLabel(), 'index' => $attribute->getAttributeCode(), 'type' => 'options', 'options' => $this->getOptions($attribute->getSource()), 'sortable' => false)); $block->setId($attribute->getAttributeCode())->setGrid($this); } return $this; }