function testAlready_involved_in_this_step()
 {
     $db_config = new mock_db_configure(8);
     // 4 pages, 2 cases each
     $db_q = array(0 => $this->queries['already_involved_in_this_step']);
     $pages = array(0 => "sponsoring_edit", 1 => "step1_edit", 2 => "developing_edit", 3 => "step4_edit");
     $tables = array(0 => "sponsoring", 1 => "consultants", 2 => "developing", 3 => "referees");
     $who = array(0 => "sponsor", 1 => "consultant", 2 => "developer", 3 => "referee");
     // first test: unknown page
     $this->assertEquals(0, already_involved_in_this_step('', '', ''), "test 1");
     // tests 1 to 9: check each page in turn ...
     for ($page_idx = 0; $page_idx < 4; $page_idx++) {
         for ($jdx = 0; $jdx < 2; $jdx++) {
             $db_config->add_query(sprintf($db_q[0], $tables[$page_idx], 'p', $who[$page_idx], 'u'), $page_idx * 2 + $jdx);
             $db_config->add_num_row($jdx, $page_idx * 2 + $jdx);
             $this->assertEquals($jdx, already_involved_in_this_step('p', $pages[$page_idx], 'u'), "PageIdx = {$page_idx}, Jdx = {$jdx}");
         }
     }
     $this->_check_db($db_config);
 }
start_content();
$page = 'sponsoring_edit';
if (check_permission($proid, $page)) {
    top_bar($proid, $page);
    if (is_not_set_or_empty($submit)) {
        if (is_set_and_not_empty($preview)) {
            sponsoring_preview($proid);
        } else {
            if (!is_project_initiator($proid)) {
                require 'include/configurelib.inc';
                configure_show($proid);
                print "<br><p>\n";
            }
        }
        /* now check whether the user is already sponsoring */
        if (already_involved_in_this_step($proid, $page, $auth->auth['uname'])) {
            $db->query("SELECT * FROM sponsoring WHERE proid='{$proid}' AND " . "sponsor='" . $auth->auth['uname'] . "'");
            $db->next_record();
            global $budget, $sponsoring_text;
            $budget = $db->f('budget');
            $sponsoring_text = $db->f('sponsoring_text');
            $ary = timestamp_to_date($db->f('valid'));
            global $valid_day, $valid_month, $valid_year;
            $valid_day = $ary['day'];
            $valid_month = $ary['month'];
            $valid_year = $ary['year'];
            $ary = timestamp_to_date($db->f('begin'));
            global $begin_day, $begin_month, $begin_year;
            $begin_day = $ary['day'];
            $begin_month = $ary['month'];
            $begin_year = $ary['year'];