mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 03:54:10 +01:00
[ticket/10972] Added explicit checks for creating duplicate users.
PHPBB3-10972
This commit is contained in:
parent
cafc7feca1
commit
d33accb687
@ -30,6 +30,11 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
*/
|
||||
protected $lang = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $created_users = array();
|
||||
|
||||
static protected $config = array();
|
||||
static protected $already_installed = false;
|
||||
|
||||
@ -197,14 +202,18 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
/**
|
||||
* Creates a new user with limited permissions
|
||||
*
|
||||
* Note that creating two users with the same name results in undefined
|
||||
* login behaviour. Always call delete_user after running a test that
|
||||
* Always call delete_user after running a test that
|
||||
* requires create_user.
|
||||
*
|
||||
* @param string $username Also doubles up as the user's password
|
||||
*/
|
||||
protected function create_user($username)
|
||||
{
|
||||
if (isset($this->created_users[$username]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Required by unique_id
|
||||
global $config;
|
||||
|
||||
@ -225,6 +234,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
";
|
||||
|
||||
$db->sql_query($query);
|
||||
$this->created_users[$username] = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -234,6 +244,11 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
*/
|
||||
protected function delete_user($username)
|
||||
{
|
||||
if (isset($this->created_users[$username]))
|
||||
{
|
||||
unset($this->created_users[$username]);
|
||||
}
|
||||
|
||||
$db = $this->get_db();
|
||||
$query = "DELETE FROM " . self::$config['table_prefix'] . "users WHERE username = '" . $db->sql_escape($username) . "'";
|
||||
$db->sql_query($query);
|
||||
|
Loading…
x
Reference in New Issue
Block a user