public function testGetFullActionName() { $this->_request->expects($this->once())->method('getRequestedRouteName')->will($this->returnValue('adminhtml')); $this->_request->expects($this->once())->method('getRequestedControllerName')->will($this->returnValue('index')); $this->_request->expects($this->once())->method('getRequestedActionName')->will($this->returnValue('index')); $this->assertEquals('adminhtml_index_index', $this->_actionAbstract->getFullActionName()); }
protected function setUp() { $this->_layout = $this->getMockBuilder('Mage_Core_Model_Layout')->disableOriginalConstructor()->setMethods(array('helper', 'getChildBlock', 'getChildName'))->getMock(); $this->_request = $this->getMockBuilder('Mage_Core_Controller_Request_Http')->disableOriginalConstructor()->setMethods(array('getParam'))->getMock(); $this->_request->expects($this->any())->method('getParam')->with('user_id')->will($this->returnValue(1)); $helper = new Magento_Test_Helper_ObjectManager($this); $this->_block = $helper->getBlock('Mage_Webapi_Block_Adminhtml_User_Edit', array('urlBuilder' => $this->getMockBuilder('Mage_Backend_Model_Url')->disableOriginalConstructor()->getMock(), 'layout' => $this->_layout, 'request' => $this->_request)); }
/** * @dataProvider updateDataProvider * @param int $roleId * @param array $filters * @param bool $isAjax * @param mixed $param */ public function testUpdate($roleId, $filters, $isAjax, $param) { $this->_request->expects($this->any())->method('getParam')->will($this->returnValueMap(array(array('role_id', null, $roleId), array('filter', '', $filters)))); $this->_request->expects($this->any())->method('isAjax')->will($this->returnValue($isAjax)); if ($param) { $this->_collection->expects($this->once())->method('addFieldToFilter')->with('role_id', $param); } else { $this->_collection->expects($this->never())->method('addFieldToFilter'); } /** @var Mage_Webapi_Model_Acl_Role_UsersUpdater $model */ $model = $this->_helper->getModel('Mage_Webapi_Model_Acl_Role_UsersUpdater', array('request' => $this->_request, 'backendHelper' => $this->_backendHelper)); $this->assertEquals($this->_collection, $model->update($this->_collection)); }
/** * 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()); }
public function setUp() { $this->_menuMock = $this->getMock('Mage_Backend_Model_Menu', array(), array(), '', false); $this->_menuConfigMock = $this->getMock('Mage_Backend_Model_Menu_Config', array(), array(), '', false); $this->_menuConfigMock->expects($this->any())->method('getMenu')->will($this->returnValue($this->_menuMock)); $this->_coreSessionMock = $this->getMock('Mage_Core_Model_Session', array('getFormKey'), array(), '', false); $this->_coreSessionMock->expects($this->any())->method('getFormKey')->will($this->returnValue('salt')); $this->_coreHelperMock = $this->getMock('Mage_Core_Helper_Data', array('getHash'), array(), '', false); $this->_coreHelperMock->expects($this->any())->method('getHash')->will($this->returnArgument(0)); $mockItem = $this->getMock('Mage_Backend_Model_Menu_Item', array(), array(), '', false); $mockItem->expects($this->any())->method('isDisabled')->will($this->returnValue(false)); $mockItem->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); $mockItem->expects($this->any())->method('getId')->will($this->returnValue('Mage_Adminhtml::system_acl_roles')); $mockItem->expects($this->any())->method('getAction')->will($this->returnValue('adminhtml/user_role')); $this->_menuMock->expects($this->any())->method('get')->with($this->equalTo('Mage_Adminhtml::system_acl_roles'))->will($this->returnValue($mockItem)); $helperMock = $this->getMock('Mage_Backend_Helper_Data', array(), array(), '', false); $helperMock->expects($this->any())->method('getAreaFrontName')->will($this->returnValue($this->_areaFrontName)); $this->_storeConfigMock = $this->getMock('Mage_Core_Model_Store_Config', array(), array(), '', false); $this->_storeConfigMock->expects($this->any())->method('getConfig')->with(Mage_Backend_Model_Url::XML_PATH_STARTUP_MENU_ITEM)->will($this->returnValue('Mage_Adminhtml::system_acl_roles')); $this->_model = new Mage_Backend_Model_Url($helperMock, $this->_coreHelperMock, $this->_coreSessionMock, $this->_storeConfigMock, $this->_menuConfigMock); $this->_requestMock = $this->getMock('Mage_Core_Controller_Request_Http', array(), array(), '', false); $this->_model->setRequest($this->_requestMock); }