Commit d46c9262 authored by Chris Graham's avatar Chris Graham
Browse files

Fixed MANTIS-4589 (Don't assume 'test' or 'admin' usernane exists)

parent 3f5640b1
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -93,4 +93,16 @@ class cms_test_case extends WebTestCase

        $this->dump($this->_browser->getContent());
    }

    function get_canonical_username($username)
    {
        if ($GLOBALS['FORUM_DRIVER']->get_member_from_username($username) === null) {
            if ($username == 'admin') {
                $username = $GLOBALS['FORUM_DB']->query_select_value('f_members', 'id', array('m_primary_group' => db_get_first_id() + 1));
            } elseif ($username == 'test') {
                $username = $GLOBALS['FORUM_DB']->query_value_if_there('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE m_primary_group<>' .strval(db_get_first_id()) . ' AND m_primary_group<>' .strval(db_get_first_id() + 1));
            }
        }
        return $username;
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ class search_test_set extends cms_test_case
        }

        foreach (array(0, 1) as $safe_mode) {
            foreach (array('admin', 'test') as $username) {
            foreach (array($this->get_canonical_username('admin'), $this->get_canonical_username('test')) as $username) {
                $url = build_url($url_parts + array('keep_su' => $username, 'keep_safe_mode' => $safe_mode), get_module_zone('search'));
                $data = http_download_file($url->evaluate(), null, true, false, 'Composr', null, array(get_session_cookie() => get_session_id()));
                $this->assertTrue(strpos($data, do_lang('NO_RESULTS_SEARCH')) !== false); // We expect no results, but also no crash!