public function setUp() { $roleAdmin = new Mage_User_Model_Role(); $roleAdmin->load(Magento_Test_Bootstrap::ADMIN_ROLE_NAME, 'role_name'); Mage::app()->getRequest()->setParam('rid', $roleAdmin->getId()); $aclMock = $this->getMock('Magento_Acl'); $aclMock->expects($this->any())->method('has')->will($this->returnValue(true)); $this->_block = new Mage_User_Block_Role_Tab_Edit(array('acl' => $aclMock)); }
public function testEditRoleAction() { $roleAdmin = new Mage_User_Model_Role(); $roleAdmin->load(Magento_Test_Bootstrap::ADMIN_ROLE_NAME, 'role_name'); $this->getRequest()->setParam('rid', $roleAdmin->getId()); $this->dispatch('backend/admin/user_role/editrole'); $this->assertContains('Role Information', $this->getResponse()->getBody()); $this->assertContains("Edit Role '" . $roleAdmin->getRoleName() . "'", $this->getResponse()->getBody()); }
/** * Get admin role model * * @return Mage_User_Model_Role */ public function getRole() { if (null === $this->_role) { $this->_role = Mage::getModel('Mage_User_Model_Role'); $roles = $this->getRoles(); if ($roles && isset($roles[0]) && $roles[0]) { $this->_role->load($roles[0]); } } return $this->_role; }
public function testGetRoleUsers() { $this->assertEmpty($this->_model->getRoleUsers()); $this->_model->load(Magento_Test_Bootstrap::ADMIN_ROLE_NAME, 'role_name'); $this->assertNotEmpty($this->_model->getRoleUsers()); }
/** * Creates predefined admin user to be used by tests, where admin session is required */ protected function _createAdminUser() { $user = new Mage_User_Model_User(); $user->setData(array('firstname' => 'firstname', 'lastname' => 'lastname', 'email' => '*****@*****.**', 'username' => self::ADMIN_NAME, 'password' => self::ADMIN_PASSWORD, 'is_active' => 1)); $user->save(); $roleAdmin = new Mage_User_Model_Role(); $roleAdmin->load(self::ADMIN_ROLE_NAME, 'role_name'); $roleUser = new Mage_User_Model_Role(); $roleUser->setData(array('parent_id' => $roleAdmin->getId(), 'tree_level' => $roleAdmin->getTreeLevel() + 1, 'role_type' => Mage_User_Model_Acl_Role_User::ROLE_TYPE, 'user_id' => $user->getId(), 'role_name' => $user->getFirstname())); $roleUser->save(); }