aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_framework
diff options
context:
space:
mode:
authorFyorl <gaelreth@gmail.com>2012-07-08 20:22:19 +0100
committerOleg Pudeyev <oleg@bsdpower.com>2012-12-06 22:10:09 -0500
commit70050020699d9eab9b97bda342e0e928d1591de8 (patch)
tree166fa0e9f4d5d3728f6416d35fc2ae82d8fabf45 /tests/test_framework
parent18bcb9f8042fe657db993c3e44cba48b27ec5627 (diff)
downloadforums-70050020699d9eab9b97bda342e0e928d1591de8.tar
forums-70050020699d9eab9b97bda342e0e928d1591de8.tar.gz
forums-70050020699d9eab9b97bda342e0e928d1591de8.tar.bz2
forums-70050020699d9eab9b97bda342e0e928d1591de8.tar.xz
forums-70050020699d9eab9b97bda342e0e928d1591de8.zip
[ticket/10972] Added methods for creating and deleting basic users
Modified the login method to allow logging in of an arbitrary user. Also added tests for the new functionality. PHPBB3-10972
Diffstat (limited to 'tests/test_framework')
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php45
1 files changed, 43 insertions, 2 deletions
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 7c03f874e9..dfbfe2565e 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -194,7 +194,48 @@ class phpbb_functional_test_case extends phpbb_test_case
$db_conn_mgr->recreate_db();
}
- protected function login()
+ /**
+ * Creates a new user with limited permissions
+ *
+ * @param string $username Also doubles up as the user's password
+ */
+ protected function create_user($username)
+ {
+ // Required by unique_id
+ global $config;
+
+ if (!is_array($config))
+ {
+ $config = array();
+ }
+
+ $config['rand_seed'] = '';
+ $config['rand_seed_last_update'] = time() + 600;
+
+ $db = $this->get_db();
+ $query = "
+ INSERT INTO " . self::$config['table_prefix'] . "users
+ (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd)
+ VALUES
+ (0, 2, 'user', 'user', 0, '" . phpbb_hash($username) . "', 'nobody@example.com', 'en', 1, 0, '', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', '')
+ ";
+
+ $db->sql_query($query);
+ }
+
+ /**
+ * Deletes a user
+ *
+ * @param string $username The username of the user to delete
+ */
+ protected function delete_user($username)
+ {
+ $db = $this->get_db();
+ $query = "DELETE FROM " . self::$config['table_prefix'] . "users WHERE username = '" . $db->sql_escape($username) . "'";
+ $db->sql_query($query);
+ }
+
+ protected function login($username = 'admin')
{
$this->add_lang('ucp');
@@ -202,7 +243,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text());
$form = $crawler->selectButton($this->lang('LOGIN'))->form();
- $login = $this->client->submit($form, array('username' => 'admin', 'password' => 'admin'));
+ $login = $this->client->submit($form, array('username' => $username, 'password' => $username));
$cookies = $this->cookieJar->all();