aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_framework
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2012-12-10 06:09:59 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2012-12-10 06:25:51 -0500
commiteaa0319867783868a761c9ede5398d52351c38d5 (patch)
treea4adb4751b9699da20b87313d37c59a5c342d7be /tests/test_framework
parent3fe381eed561e724700b21789e28ea3efb1f7ef9 (diff)
parent3c542b852a99f62337c8cf1c6d3e6551c4e3dca1 (diff)
downloadforums-eaa0319867783868a761c9ede5398d52351c38d5.tar
forums-eaa0319867783868a761c9ede5398d52351c38d5.tar.gz
forums-eaa0319867783868a761c9ede5398d52351c38d5.tar.bz2
forums-eaa0319867783868a761c9ede5398d52351c38d5.tar.xz
forums-eaa0319867783868a761c9ede5398d52351c38d5.zip
Merge PR #1125 branch 'develop-olympus' into develop
* develop-olympus: [ticket/10972] Drop user deletion. [ticket/10972] Tweak user addition. [ticket/10972] Add destroy method to mock cache. [ticket/10972] Add mock null cache. [ticket/10972] Backport get_db from develop. [ticket/10972] Added explicit checks for creating duplicate users. [ticket/10972] Moved tests into appropriate places and added comments [ticket/10972] Added methods for creating and deleting basic users Conflicts: tests/mock/cache.php tests/test_framework/phpbb_functional_test_case.php
Diffstat (limited to 'tests/test_framework')
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php60
1 files changed, 58 insertions, 2 deletions
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 16e1ccaff9..6536ad8807 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -231,7 +231,61 @@ 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
+ * @return int ID of created user
+ */
+ 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;
+
+ // Required by user_add
+ global $db, $cache, $config, $phpbb_dispatcher;
+ $db = $this->get_db();
+ if (!function_exists('phpbb_mock_null_cache'))
+ {
+ require_once(__DIR__ . '/../mock/null_cache.php');
+ }
+ $cache = new phpbb_mock_null_cache;
+
+ if (!function_exists('utf_clean_string'))
+ {
+ require_once(__DIR__ . '/../../phpBB/includes/utf/utf_tools.php');
+ }
+ if (!function_exists('user_add'))
+ {
+ require_once(__DIR__ . '/../../phpBB/includes/functions_user.php');
+ }
+ $config = new phpbb_config(array());
+ set_config(null, null, null, $config);
+ set_config_count(null, null, null, $config);
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
+
+ $user_row = array(
+ 'username' => $username,
+ 'group_id' => 2,
+ 'user_email' => 'nobody@example.com',
+ 'user_type' => 0,
+ 'user_lang' => 'en',
+ 'user_timezone' => 0,
+ 'user_dateformat' => '',
+ 'user_password' => phpbb_hash($username),
+ );
+ return user_add($user_row);
+ }
+
+ protected function login($username = 'admin')
{
$this->add_lang('ucp');
@@ -239,7 +293,9 @@ 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'));
+ $crawler = $this->client->submit($form, array('username' => $username, 'password' => $username));
+ $this->assert_response_success();
+ $this->assertContains($this->lang('LOGIN_REDIRECT'), $crawler->filter('html')->text());
$cookies = $this->cookieJar->all();