Esempio n. 1
0
 public function testReload()
 {
     $this->_model->loadByUsername(Magento_Test_Bootstrap::ADMIN_NAME);
     $this->_model->setFirstname('NewFirstName');
     $this->assertEquals('NewFirstName', $this->_model->getFirstname());
     $this->_model->reload();
     $this->assertEquals('firstname', $this->_model->getFirstname());
 }
Esempio n. 2
0
 /**
  * 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();
 }
Esempio n. 3
0
 /**
  * Create role for provided user of provided type
  *
  * @param $parentId
  * @param Mage_User_Model_User $user
  */
 protected function _createUserRole($parentId, Mage_User_Model_User $user)
 {
     if ($parentId > 0) {
         $parentRole = Mage::getModel('Mage_User_Model_Role')->load($parentId);
     } else {
         $role = new Varien_Object();
         $role->setTreeLevel(0);
     }
     if ($parentRole->getId()) {
         $data = new Varien_Object(array('parent_id' => $parentRole->getId(), 'tree_level' => $parentRole->getTreeLevel() + 1, 'sort_order' => 0, 'role_type' => 'U', 'user_id' => $user->getId(), 'role_name' => $user->getFirstname()));
         $insertData = $this->_prepareDataForTable($data, $this->getTable('admin_role'));
         $this->_getWriteAdapter()->insert($this->getTable('admin_role'), $insertData);
     }
 }