Beispiel #1
0
 /**
  * Test getHeaderText method
  */
 public function testGetHeaderText()
 {
     $apiUser = new Varien_Object();
     $this->_block->setApiUser($apiUser);
     $this->assertEquals('New API User', $this->_block->getHeaderText());
     $apiUser->setId(1)->setApiKey('test-api');
     /** @var PHPUnit_Framework_MockObject_MockObject $coreHelper  */
     $coreHelper = $this->getMockBuilder('Mage_Core_Helper_Data')->disableOriginalConstructor()->setMethods(array('escapeHtml'))->getMock();
     $coreHelper->expects($this->once())->method('escapeHtml')->with($apiUser->getApiKey())->will($this->returnArgument(0));
     $this->_layout->expects($this->once())->method('helper')->with('Mage_Core_Helper_Data')->will($this->returnValue($coreHelper));
     $this->assertEquals("Edit API User 'test-api'", $this->_block->getHeaderText());
 }
Beispiel #2
0
 protected function setUp()
 {
     $this->_layoutMock = $this->getMock('Mage_Core_Model_Layout', array(), array(), '', false);
     $this->_columnSetMock = $this->getMock('Mage_Backend_Block_Widget_Grid_ColumnSet', array(), $this->_prepareConstructorArguments());
     $returnValueMap = array(array('grid', 'grid.columnSet', 'grid.columnSet'), array('grid', 'reset_filter_button', 'reset_filter_button'), array('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('Mage_Backend_Block_Widget_Button')->will($this->returnValue(Mage::app()->getLayout()->createBlock('Mage_Backend_Block_Widget_Button')));
     $this->_block = Mage::app()->getLayout()->createBlock('Mage_Backend_Block_Widget_Grid');
     $this->_block->setLayout($this->_layoutMock);
     $this->_block->setNameInLayout('grid');
 }
Beispiel #3
0
 /**
  * Test for _beforeToHtml method
  *
  * @dataProvider beforeToHtmlDataProvider
  * @param object $apiRole
  * @param array $expectedTabIds
  */
 public function testBeforeToHtml($apiRole, $expectedTabIds)
 {
     $this->_block->setApiRole($apiRole);
     $mainBlock = $this->_helper->getBlock('Mage_Core_Block_Text');
     $resourceBlock = $this->_helper->getBlock('Mage_Core_Block_Text');
     $userBlock = $this->_helper->getBlock('Mage_Core_Block_Text');
     $this->_layout->expects($this->any())->method('getBlock')->will($this->returnValueMap(array(array('webapi.role.edit.tab.main', $mainBlock), array('webapi.role.edit.tab.resource', $resourceBlock), array('webapi.role.edit.tab.users.grid', $userBlock))));
     $this->_request->expects($this->any())->method('getParam')->will($this->returnValueMap(array(array('active_tab', null, 'main_section'))));
     // todo: do checks using toHtml() when DI is implemented for abstract blocks
     $toHtmlMethod = new ReflectionMethod($this->_block, '_beforeToHtml');
     $toHtmlMethod->setAccessible(true);
     $toHtmlMethod->invoke($this->_block);
     $this->assertEquals($expectedTabIds, $this->_block->getTabsIds());
     $this->assertEquals($apiRole, $mainBlock->getApiRole());
     $this->assertEquals($apiRole, $resourceBlock->getApiRole());
 }