/** * This method performs data validation for the username uniqueness * * @param OA_Dll_UserInfo $oUser * @param OA_Dll_UserInfo $oOldUser * @return boolean */ function _validateUsername(&$oUser, $oOldUser = null) { if (isset($oUser->username)) { $oldUsername = empty($oOldUser) ? '' : $oOldUser->username; if (!OA_Permission::isUsernameAllowed($oUser->username, $oldUsername)) { $this->raiseError(self::ERROR_USERNAME_NOT_UNIQUE); return false; } } return true; }
/** * This method performs data validation for the username uniqueness * * @param OA_Dll_UserInfo $oUser * @param OA_Dll_UserInfo $oOldUser * @return boolean */ function _validateUsername(&$oUser, $oOldUser = null) { if (isset($oUser->username)) { $oldUsername = empty($oOldUser) ? '' : $oOldUser->username; if (!OA_Permission::isUsernameAllowed($oUser->username, $oldUsername)) { $this->raiseError('Username must be unique'); return false; } } return true; }
function testIsUsernameAllowed() { // If the names are the same then true $this->assertTrue(OA_Permission::isUsernameAllowed('foo', 'foo')); // Check users as client, affiliate, agency $doClients = OA_Dal::factoryDO('clients'); $doClients->reportlastdate = '2007-04-02 12:00:00'; $clientId = DataGenerator::generateOne($doClients); $username = '******' . rand(1, 1000); $aUser = array('contact_name' => 'contact', 'email_address' => '*****@*****.**', 'username' => $username, 'password' => 'password'); $doClient = OA_Dal::staticGetDO('clients', $clientId); $doClient->createUser($aUser); $this->assertFalse(OA_Permission::isUsernameAllowed($username, 'foo')); $this->assertTrue(OA_Permission::isUsernameAllowed('newname', 'foo')); }