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()); }
/** * @magentoDataFixture roleDataFixture */ public function testGetRole() { $this->_model->loadByUsername(Magento_Test_Bootstrap::ADMIN_NAME); $role = $this->_model->getRole(); $this->assertInstanceOf('Mage_User_Model_Role', $role); $this->assertEquals(1, $role->getId()); $this->_model->setRoleId(self::$_newRole->getId())->save(); $role = $this->_model->getRole(); $this->assertEquals(self::$_newRole->getId(), $role->getId()); }
/** * 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()); }
/** * Get role users * * @param Mage_User_Model_Role $role * @return array */ public function getRoleUsers(Mage_User_Model_Role $role) { $read = $this->_getReadAdapter(); $binds = array('role_id' => $role->getId(), 'role_type' => 'U'); $select = $read->select()->from($this->getMainTable(), array('user_id'))->where('parent_id = :role_id')->where('role_type = :role_type')->where('user_id > 0'); return $read->fetchCol($select, $binds); }
/** * 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(); }