コード例 #1
0
 function testFaqshow()
 {
     global $t, $bx;
     $db_config = new mock_db_configure(1);
     $d = $this->_generate_records(array('question', 'answer'), 1);
     $db_config->add_query('fubar', 0);
     $db_config->add_record($d[0], 0);
     $db = new DB_SourceAgency();
     $db->query('fubar');
     $db->next_record();
     $bx = $this->_create_default_box();
     $this->capture_call('faqshow', 778, array(&$db));
     $this->_checkFor_box_full($t->translate('Question') . '</B>: ' . $d[0]['question'], '<b>' . $t->translate('Answer') . '</b>: ' . $d[0]['answer']);
     $this->_check_db($db_config);
 }
コード例 #2
0
 function testDoco_show()
 {
     global $bx;
     $d = $this->_generate_records(array('page', 'header', 'doco'), 1);
     $db_config = new mock_db_configure(1);
     $db_config->add_query('fubar', 0);
     $db_config->add_record($d[0], 0);
     $db = new DB_SourceAgency();
     $db->query('fubar');
     $db->next_record();
     $bx = $this->_create_default_box();
     $this->capture_call('doco_show', 753, array(&$db));
     $this->_checkFor_box_full($d[0]['page'] . ': ' . $d[0]['header'], $d[0]['doco']);
     $this->_check_db($db_config);
 }
コード例 #3
0
 function testShow_referees()
 {
     global $t, $bx, $db;
     $db_config = new mock_db_configure(2);
     $pid1 = "this sit he proid";
     $pid2 = "this sit he proid two";
     $q = $this->queries['show_referees'];
     $db_config->add_query(sprintf($q, $pid1), 0);
     $db_config->add_num_row(0, 0);
     $db_config->add_num_row(0, 0);
     $db_config->add_query(sprintf($q, $pid2), 1);
     $dat = $this->_generate_records(array('username', 'status', 'creation'), 5);
     $db_config->add_num_row(count($dat), 1);
     $db_config->add_num_row(count($dat), 1);
     for ($idx = 0; $idx < count($dat); $idx++) {
         $db_config->add_record($dat[$idx], 1);
     }
     // test one, no record/data
     $bx = $this->_create_default_box();
     $db = new DB_SourceAgency();
     capture_reset_and_start();
     show_referees($pid1);
     $this->set_text(capture_stop_and_get());
     $this->push_msg("Test One");
     $this->_testFor_string_length(72);
     $msg = $t->translate("There are no developers that have " . "offered themselves as referees");
     $this->_testFor_pattern($this->_to_regexp($msg));
     $this->pop_msg();
     // test two, data is defined
     $bx = $this->_create_default_box();
     $db = new DB_SourceAgency();
     capture_reset_and_start();
     show_referees($pid2);
     $this->set_text(capture_stop_and_get());
     $this->push_msg("Test Two");
     $this->_testFor_string_length(4940);
     $msg = $t->translate("There are no developers that have " . "offered themselves as referees");
     $this->reverse_next_test();
     $this->_testFor_pattern($this->_to_regexp($msg));
     $this->_checkFor_a_box('Referees');
     $this->_checkFor_columns(4);
     $this->_checkFor_column_titles(array('Number', 'Username', 'Status', 'Creation'), '', '', '');
     $colors = array(0 => '#FFFFFF', 1 => 'gold');
     for ($idx = 0; $idx < count($dat); $idx++) {
         $v = array("<b>" . ($idx + 1) . "</b>", '<b>' . lib_nick($dat[$idx]['username']) . '</b>', '<b>' . show_status($dat[$idx]['status']) . '</b>', '<b>' . timestr(mktimestamp($dat[$idx]['creation'])) . '</b>');
         $this->push_msg("Test {$idx}");
         $this->_checkFor_column_values($v, '', '', $colors[$idx % 2]);
         $this->pop_msg();
     }
     $this->pop_msg();
     $this->_check_db($db_config);
 }
コード例 #4
0
 function testPut_decision_step5_into_database()
 {
     global $db, $auth, $queries;
     $uname = 'this is the username';
     $auth->set_uname($uname);
     $fname = 'put_decision_step5_into_database';
     $qs = array(0 => $queries[$fname . "_1"], 1 => $queries[$fname . "_2"], 2 => $queries[$fname . "_3"], 3 => $queries['monitor_mail']);
     $db_config = new mock_db_configure(6);
     $args = $this->_generate_records(array('proid', 'your_vote', 'milestone_number', 'count'), 10);
     // test one no records
     $db_config->add_query(sprintf($qs[0], $args[0]['proid'], $uname, $args[0]['milestone_number'], $args[0]['count']), 0);
     $db_config->add_num_row(0, 0);
     $db_config->add_query(sprintf($qs[1], $args[0]['proid'], $uname, $args[0]['milestone_number'], $args[0]['count'], $args[0]['your_vote']), 0);
     /* monitor_mail query */
     $db_config->add_query(sprintf($qs[3], $args[0]['proid'], ''), 1);
     $db_config->add_record(false, 1);
     $db = new DB_SourceAgency();
     $this->capture_call($fname, 0, $args[0]);
     // test two: one record, decision equals your_vote
     $db_config->add_query(sprintf($qs[0], $args[1]['proid'], $uname, $args[1]['milestone_number'], $args[1]['count']), 2);
     $db_config->add_num_row(1, 2);
     $db_config->add_record(array('decision' => $args[1]['your_vote']), 2);
     /* monitor_mail query */
     $db_config->add_query(sprintf($qs[3], $args[1]['proid'], ''), 3);
     $db_config->add_record(false, 3);
     $db = new DB_SourceAgency();
     $this->capture_call($fname, 28, $args[1]);
     $this->assertEquals("You have already voted that\n", $this->get_text());
     // test three: one record, decision does not equal your_vote
     $db_config->add_query(sprintf($qs[0], $args[2]['proid'], $uname, $args[2]['milestone_number'], $args[2]['count']), 4);
     $db_config->add_num_row(1, 4);
     $db_config->add_record(array('decision' => $args[2]['your_vote'] . "NOT EQUALS"), 4);
     $db_config->add_query(sprintf($qs[2], $args[2]['your_vote'], $args[2]['proid'], $uname, $args[2]['milestone_number'], $args[2]['count']), 4);
     /* monitor_mail query */
     $db_config->add_query(sprintf($qs[3], $args[2]['proid'], ''), 5);
     $db_config->add_record(false, 5);
     $db = new DB_SourceAgency();
     $this->capture_call($fname, 71, $args[2]);
     $this->assertEquals("Vote changed. Old: <b>" . $args[2]['your_vote'] . "NOT EQUALS" . "</b> New: <b>" . $args[2]['your_vote'] . "</b>", $this->get_text());
     $this->_check_db($db_config);
 }
コード例 #5
0
 function testTop_bar()
 {
     $db_config = new mock_db_configure(2);
     $fname = 'top_bar';
     $qs = array(0 => $this->queries['summary_1']);
     $args = $this->_generate_records(array('proid', 'page'), 2);
     $db_config->add_query(sprintf($qs[0], $args[0]['proid']), 0);
     $db_config->add_num_row(0, 0);
     $db_config->add_query(sprintf($qs[0], $args[1]['proid']), 1);
     $db_config->add_num_row(1, 1);
     $db_config->add_record(array('project_title' => 'fubar', 'status' => 2), 1);
     // test one
     $this->capture_call($fname, 2258, $args[0]);
     // test two
     $this->capture_call($fname, 2564, $args[1]);
     $this->_check_db($db_config);
 }
コード例 #6
0
 function testComments_show()
 {
     // FIXME: only tests whether the arguments are checked, not
     // FIXME: whether the displaying of the data is working
     global $db, $bx;
     $db_config = new mock_db_configure(6);
     $db_q = array(0 => "SELECT * FROM comments, auth_user WHERE " . "proid='%s' AND type='%s' AND " . "number='%s' AND id='%s' AND ref='%s' " . "AND user_cmt=username ORDER BY " . "creation_cmt ASC", 1 => "SELECT * FROM comments, auth_user WHERE " . "proid='%s' AND type='%s' AND " . "number='%s' %s AND ref='%s' " . "AND user_cmt=username ORDER BY " . "creation_cmt ASC");
     // 6 calls in total
     $dat = $this->_generate_records(array("proid", "type_cmt", "number", "cmt_id", "ref"), 6);
     $dat[1]["number"] = "";
     $dat[2]["cmt_id"] = "";
     $dat[2]["number"] = "";
     $dat[3]["cmt_id"] = "";
     $dat[3]["ref"] = "";
     $dat[4]["ref"] = "";
     $dat[4]["number"] = "";
     $dat[5]["ref"] = "";
     $dat[5]["number"] = "";
     $dat[5]["cmt_id"] = "";
     $db_config->add_query(sprintf($db_q[0], $dat[0]["proid"], $dat[0]["type_cmt"], $dat[0]["number"], $dat[0]["cmt_id"], $dat[0]["ref"]), 0);
     $db_config->add_query(sprintf($db_q[0], $dat[1]["proid"], $dat[1]["type_cmt"], "0", $dat[1]["cmt_id"], $dat[1]["ref"]), 1);
     $db_config->add_query(sprintf($db_q[1], $dat[2]["proid"], $dat[2]["type_cmt"], "0", $dat[2]["cmt_id"], $dat[2]["ref"]), 2);
     $db_config->add_query(sprintf($db_q[1], $dat[3]["proid"], $dat[3]["type_cmt"], $dat[3]["number"], $dat[3]["cmt_id"], "0"), 3);
     $db_config->add_query(sprintf($db_q[0], $dat[4]["proid"], $dat[4]["type_cmt"], "0", $dat[4]["cmt_id"], "0"), 4);
     $db_config->add_query(sprintf($db_q[1], $dat[5]["proid"], $dat[5]["type_cmt"], "0", $dat[5]["cmt_id"], "0"), 5);
     // make calls
     for ($idx = 0; $idx < 6; $idx++) {
         $db = new DB_SourceAgency();
         $bx = $this->_create_default_box();
         $this->push_msg('test ' . $idx);
         $this->capture_call('comments_show', 0, &$dat[$idx]);
         $this->pop_msg();
     }
     $this->_check_db($db_config);
 }
コード例 #7
0
 function testNews_modify()
 {
     global $db;
     $db_config = new mock_db_configure(2);
     $row = array(0 => $this->_generate_array(array("proid", "user", "subject", "text", "creation"), 0));
     $db_q = array(0 => "UPDATE news SET user_news='%s', subject_news=" . "'%s', text_news='%s' WHERE proid='%s' AND " . "creation_news='%s'", 1 => "SELECT email_usr FROM auth_user,monitor " . "WHERE monitor.username=auth_user.username " . "AND proid='%s' AND importance='high'", 2 => "SELECT * FROM news,auth_user WHERE proid='%s' " . "AND user_news=username ORDER BY " . "creation_news DESC");
     $db_config->add_query(sprintf($db_q[0], $row[0]["user"], $row[0]["subject"], $row[0]["text"], $row[0]["proid"], $row[0]["creation"]), 0);
     $db_config->add_query(sprintf($db_q[1], $row[0]["proid"]), 1);
     $db_config->add_query(sprintf($db_q[2], $row[0]["proid"]), 0);
     $db_config->add_num_row(0, 0);
     $db_config->add_record(false, 0);
     $db_config->add_record(false, 1);
     //
     // first call, no records
     //
     $db = new DB_SourceAgency();
     capture_reset_and_start();
     news_modify($row[0]["proid"], $row[0]["user"], $row[0]["subject"], $row[0]["text"], $row[0]["creation"]);
     $this->set_text(capture_stop_and_get());
     $this->set_msg('test 1');
     $this->_testFor_string_length(67);
     $this->_testFor_pattern("<p>There have not been posted any news " . "by the project owner[(]s[)][.]<p>\n");
     // check that the database component did not fail
     $this->_check_db($db_config);
 }
コード例 #8
0
 function testAdmprojects_insert()
 {
     global $db;
     $qs = array(0 => "UPDATE description SET status = '%s' " . "WHERE proid='%s'", 1 => "SELECT project_title FROM description " . "WHERE proid='%s'", 2 => "INSERT history SET proid='%s',history_user="******"'BerliOS editor',type='Review',action=" . "'Project reviewed by a SourceAgency Editor'", 3 => "SELECT email_usr FROM auth_user,description " . "WHERE username=description_user AND proid='%s'");
     $db_config = new mock_db_configure(11);
     $args = $this->_generate_records(array('proid'), 11);
     $d = $this->_generate_records(array('project_title'), 11);
     $d2 = $this->_generate_records(array('email_usr'), 11);
     for ($idx = -5; $idx < 6; $idx++) {
         $jdx = $idx + 5;
         $db_config->add_query(sprintf($qs[0], $idx, $args[$jdx]['proid']), $jdx);
         $db_config->add_query(sprintf($qs[1], $args[$jdx]['proid']), $jdx);
         $db_config->add_record($d[$jdx], $jdx);
         if ($idx > -1) {
             $db_config->add_query(sprintf($qs[2], $args[$jdx]['proid']), $jdx);
         }
         $db_config->add_query(sprintf($qs[3], $args[$jdx]['proid']), $jdx);
         $d2[$jdx]['email_usr'] = '';
         $db_config->add_record($d2[$jdx], $jdx);
         $db = new DB_SourceAgency();
         $this->capture_call('admprojects_insert', 0, array($args[$jdx]['proid'], $idx));
     }
     $this->_check_db($db_config);
 }
コード例 #9
0
 function testCooperation_modify()
 {
     global $db;
     $qs = array(0 => "UPDATE cooperation SET developer='%s', cost='%s' " . "WHERE devid='%s' AND creation='%s'", 1 => "SELECT * FROM cooperation,auth_user WHERE devid='%s' " . "AND developer=username ORDER BY creation DESC");
     $args = $this->_generate_records(array('devid', 'developer', 'cost', 'creation'), 2);
     $db_config = new mock_db_configure(1);
     $db_config->add_query(sprintf($qs[0], $args[0]['developer'], $args[0]['cost'], $args[0]['devid'], $args[0]['creation']), 0);
     $db_config->add_query(sprintf($qs[1], $args[0]['devid']), 0);
     $db_config->add_num_row(0, 0);
     $str = "<p>There have not been posted any cooperation proposals " . "by any developer.<p>\n";
     $db = new DB_SourceAgency();
     $this->capture_call('cooperation_modify', strlen($str), $args[0]);
     $this->assertEquals($str, $this->get_text());
     $this->_check_db($db_config);
 }
コード例 #10
0
 function testRatings_in_history()
 {
     global $db, $t, $bx, $queries;
     $fname = 'ratings_in_history';
     $db_config = new mock_db_configure(2);
     $qs = array(0 => $queries[$fname]);
     $args = $this->_generate_records(array('proid', 'history_user'), 10);
     $db_config->add_query(sprintf($qs[0], $args[0]['proid'], $args[0]['history_user'], $args[0]['history_user']), 0);
     $db_config->add_affected_rows(0, 0);
     $db_config->add_query(sprintf($qs[0], $args[1]['proid'], $args[1]['history_user'], $args[1]['history_user']), 1);
     $db_config->add_affected_rows(1, 1);
     // test one, insert failed
     $db = new DB_SourceAgency();
     $bx = $this->_create_default_box();
     $this->capture_call($fname, 0, $args[0]);
     // test two, insert succeeds
     $db = new DB_SourceAgency();
     $bx = $this->_create_default_box();
     $this->capture_call($fname, 782, $args[1]);
     $this->_check_db($db_config);
 }
コード例 #11
0
 function testPersonal_ratings_short()
 {
     global $bx, $t;
     $fname = 'personal_ratings_short';
     $q = "SELECT rating FROM ratings WHERE to_whom='%s'";
     $db_config = new mock_db_configure(2);
     $args = $this->_generate_records(array('username'), 10);
     $d1 = $this->_generate_records(array('rating'), 10);
     // test one: no records
     $db_config->add_query(sprintf($q, $args[0]['username']), 0);
     $db_config->add_num_row(0, 0);
     $bx = $this->_create_default_box();
     $this->capture_call($fname, 676, $args[0]);
     $this->_checkFor_a_box('Rating');
     $str = $t->translate('Not rated yet');
     $this->_testFor_pattern($this->_to_regexp($str));
     // test two: records
     $db_config->add_query(sprintf($q, $args[1]['username']), 1);
     $db_config->add_num_row(1, 1);
     $avg = 0;
     for ($idx = 0; $idx < count($d1); $idx++) {
         $d1[$idx]['rating'] = $idx;
         $db_config->add_record($d1[$idx], 1);
         $avg += $idx;
     }
     $avg /= count($d1);
     $db_config->add_record(false, 1);
     $bx = $this->_create_default_box();
     $this->capture_call($fname, 810, $args[1]);
     $this->_checkFor_a_box('Rating');
     $str = $t->translate('Global personal rating: ') . $avg . " (rated " . count($d1) . " times)<p align=right>\n";
     $this->_testFor_pattern($this->_to_regexp($str));
     $this->_testFor_html_link('personal_ratings.php3', array('username' => $args[1]['username']), $t->translate('See complete ratings...'));
     $this->_check_db($db_config);
 }
コード例 #12
0
 function testConfigure_show()
 {
     global $t, $bx, $db, $sess, $queries;
     $qs = array(0 => $queries['configure_form']);
     $args = $this->_generate_records(array('proid'), 3);
     $dat = $this->_generate_records(array('quorum', 'consultants', 'other_tech_contents', 'sponsor', 'other_developing_proposals', 'developer'), 2);
     $db_config = new mock_db_configure(3);
     // test one
     $db_config->add_query(sprintf($qs[0], $args[0]['proid']), 0);
     $db_config->add_num_row(0, 0);
     // test two
     $db_config->add_query(sprintf($qs[0], $args[1]['proid']), 1);
     $db_config->add_num_row(1, 1);
     $db_config->add_record($dat[0], 1);
     $db_config->add_record(false, 1);
     // test three
     $db_config->add_query(sprintf($qs[0], $args[2]['proid']), 2);
     $db_config->add_num_row(1, 2);
     $dat[1]['quorum'] = '';
     $dat[1]['sponsor'] = '';
     $dat[1]['developer'] = '';
     $db_config->add_record($dat[1], 2);
     $db_config->add_record(false, 2);
     // test one: no results
     $str = "<p>" . $t->translate("The project parameters have not been " . "configured by the project owner(s)") . ".<p>\n";
     $db = new DB_SourceAgency();
     $bx = $this->_create_default_box();
     $this->capture_call('configure_show', strlen($str), $args[0]);
     $this->assertEquals($str, $this->get_text(), "test 1");
     // test two: one record with all values set
     $db = new DB_SourceAgency();
     $bx = $this->_create_default_box();
     $this->capture_call('configure_show', 944, $args[1]);
     $this->_checkFor_configure_show($dat[0]);
     // test three: one record with unset values
     $db = new DB_SourceAgency();
     $bx = $this->_create_default_box();
     $this->capture_call('configure_show', 975, $args[2]);
     $this->_checkFor_configure_show($dat[1]);
     $this->_check_db($db_config);
 }
コード例 #13
0
 function testConsultants_insert()
 {
     global $db, $bx, $t;
     $db_config = new mock_db_configure(2);
     $db_q = array(0 => "INSERT consultants SET proid='%s'," . "consultant='%s',status='P'");
     $dat = $this->_generate_records(array("proid", "user"), 2);
     $db_config->add_query(sprintf($db_q[0], $dat[0]["proid"], $dat[0]["user"]), 0);
     // show_consultants also uses the global db and show_consultants
     // is called by consultants_insert.
     $db_config->ignore_all_errors(0);
     // instance 1 is created by monitor_mail(...) which is also called
     // by consultants_insert
     $db_config->ignore_all_errors(1);
     $db = new DB_SourceAgency();
     $bx = $this->_create_default_box();
     $this->capture_call('consultants_insert', 1494, &$dat[0]);
     // the basics for show_consultants(...), assume that the rest
     // is also present
     $this->_checkFor_a_box('Consultants');
     $this->_checkFor_columns(4);
     $this->_check_db($db_config);
 }
コード例 #14
0
 function testHistory_extract_table()
 {
     global $db;
     global $history, $i, $proid, $what, $who, $subject;
     $q = "SELECT * FROM %s WHERE proid='%s'";
     $q2 = "SELECT developer FROM developing WHERE developing.devid='%s'";
     $i = -1;
     $proid = 'this os the proid';
     $what = array();
     $who = array();
     $subject = array();
     $history = array();
     $db_config = new mock_db_configure(4);
     $args = $this->_generate_records(array('table_name', 'table_creation', 'table_user', 'table_subject'), 3);
     // test one
     $db_config->add_query(sprintf($q, $args[0]['table_name'], $proid), 0);
     $db_config->add_record(false, 0);
     $db = new DB_SourceAgency();
     $this->capture_call('history_extract_table', 0, $args[0]);
     $this->assertEquals(0, count($history));
     // test two
     $db_config->add_query(sprintf($q, $args[1]['table_name'], $proid), 1);
     $d = $this->_generate_array(array($args[1]['table_creation'], $args[1]['table_user'], $args[1]['table_subject']), 1);
     $db_config->add_record($d, 1);
     $db_config->add_record(false, 1);
     $db = new DB_SourceAgency();
     $this->capture_call('history_extract_table', 0, $args[1]);
     $key = substr($history[0], -9);
     $this->assertEquals($d[$args[1]['table_creation']], $history[0]);
     $this->assertEquals($d[$args[1]['table_user']], $who[$key]);
     $this->assertEquals($d[$args[1]['table_subject']], $subject[$key]);
     $this->assertEquals($args[1]['table_name'], $what[$key]);
     // test three
     $i = -1;
     $proid = 'this os the proid';
     $what = array();
     $who = array();
     $subject = array();
     $history = array();
     $args[2]['table_user'] = '******';
     $db_config->add_query(sprintf($q, $args[2]['table_name'], $proid), 2);
     $d = $this->_generate_array(array($args[2]['table_creation'], $args[2]['table_user'], $args[2]['table_subject'], 'devid'), 2);
     $db_config->add_record($d, 2);
     $db_config->add_record(false, 2);
     $db_config->add_query(sprintf($q2, $d['devid']), 3);
     $d2 = $this->_generate_array(array('developer'), 1);
     $db_config->add_record($d2, 3);
     $db = new DB_SourceAgency();
     $this->capture_call('history_extract_table', 0, $args[2]);
     $key = substr($history[0], -9);
     $this->assertEquals($d[$args[2]['table_creation']], $history[0]);
     $this->assertEquals($d2['developer'], $who[$key]);
     $this->assertEquals($d[$args[2]['table_subject']], $subject[$key]);
     $this->assertEquals($args[2]['table_name'], $what[$key]);
     $this->_check_db($db_config);
 }
コード例 #15
0
 function testDeveloping_modify_form()
 {
     global $bx, $t, $sess, $db;
     global $cost, $license, $cooperation, $valid_day, $valid_month, $valid_year, $start_day, $start_month, $start_year, $duration, $creation, $queries;
     $cost = 'ths is the cost';
     $license = 'thsi is the license';
     $cooperation = 'this is the coopeartion';
     $valid_day = 'this is the valid_day';
     $valid_month = 'thsi si the valid month';
     $valid_year = 'this is the valid year';
     $start_day = 'this is the start day';
     $start_month = 'this is the start month';
     $start_year = 'this is the start year';
     $duration = 'this is the duration';
     $creation = 'tjhis si the creation';
     $args = $this->_generate_array(array('proid', 'content_id'), 10);
     $fname = 'developing_modify_form';
     $db_config = new mock_db_configure(2);
     $qs = array(0 => $queries[$fname]);
     $db_config->add_query($qs[0], 0);
     $db_config->add_query($qs[0], 1);
     $db_config->add_num_row(1, 0);
     $db_config->add_num_row(1, 1);
     $db_config->add_record(false, 0);
     $db_config->add_record(false, 1);
     $bx = $this->_create_default_box();
     capture_reset_and_start();
     call_user_func_array($fname, $args);
     $this->set_text(capture_stop_and_get());
     $this->_testFor_string_length(4217 + strlen($sess->self_url()));
     $this->assertRegexp('/Undefined variable:  start/', $GLOBALS['err_msg']);
     $this->_checkFor_a_form('PHP_SELF', array('proid' => $args['proid']), 'POST');
     $this->_checkFor_a_box('Developement proposal modification');
     $this->_checkFor_submit_preview_buttons();
     $start = '';
     $valid = '';
     $tv = array(html_input_text('cost', 12, 12, $cost) => array('Cost', '<b>%s</b> (12): '), license($license) => array('License', '<b>%s</b> (12): '), html_input_text('cooperation', 12, 12, $cooperation) => array('Developer cooperation wanted?', '<b>%s</b> (SELECT BOX) '), html_input_text('valid', 14, 14, $valid) => array('Valid until (select box)', '<b>%s</b>: '), html_input_text('start', 14, 14, $start) => array('Start (Select box)', '<b>%s</b>: '), html_input_text('duration', 3, 3, $duration) => array('Duration (Select box)', '<b>%s</b>: '));
     while (list($val, $key) = each($tv)) {
         $this->_checkFor_column_titles(array($key[0]), 'right', '30%', '', $key[1]);
         $this->_checkFor_column_values(array($val));
     }
     $this->_check_db($db_config);
 }
コード例 #16
0
 function testshow_selected_content()
 {
     global $t, $bx, $db;
     $qs = array(0 => $this->queries['show_selected_content']);
     $db_config = new mock_db_configure(1);
     $args = $this->_generate_records(array('proid'), 1);
     $dat = $this->_generate_records(array('creation', 'username', 'skills', 'platform', 'architecture', 'docs', 'environment', 'specification'), 1);
     $db_config->add_query(sprintf($qs[0], $args[0]['proid']), 0);
     $db_config->add_record($dat[0], 0);
     $db = new DB_SourceAgency();
     $bx = $this->_create_default_box();
     $this->capture_call('show_selected_content', 944, $args[0]);
     $str = '</a> - ' . timestr(mktimestamp($dat[0]['creation'])) . '</b>';
     $this->_testFor_pattern($this->_to_regexp($str));
     $this->_testFor_lib_nick($dat[0]['username']);
     $template = "<b>%s:</b> %s\n";
     $v = array('Skills' => $dat[0]['skills'], 'Plattform' => $dat[0]['platform'], 'Architecture' => $dat[0]['architecture'], 'Environment' => $dat[0]['environment'], 'Documentation' => $dat[0]['docs'], 'Technical Specification' => $dat[0]['specification']);
     while (list($key, $val) = each($v)) {
         $str = sprintf($template, $t->translate($key), $val);
         $this->_testFor_pattern('[<]..?[>]' . $this->_to_regexp($str));
     }
     $this->_check_db($db_config);
 }
コード例 #17
0
 function testViews_show()
 {
     global $t, $bx, $db, $sess;
     $db_config = new mock_db_configure(3);
     $qs = array(0 => "SELECT * FROM views,description WHERE views.proid" . "=description.proid AND views.proid='%s'", 1 => "SELECT * FROM comments,auth_user WHERE proid='%s' AND " . "type='%s' AND number='%s' AND ref='%s' AND user_cmt" . "=username ORDER BY creation_cmt ASC");
     $args = $this->_generate_records(array('proid'), 2);
     $d = $this->_generate_records(array('creation', 'description_user', 'configure', 'news', 'comments', 'history', 'step3', 'step4', 'step5', 'cooperation', 'views'), 1);
     // test one: no records
     $db_config->add_query(sprintf($qs[0], $args[0]['proid']), 0);
     $db_config->add_num_row(0, 0);
     // test two: one record
     $db_config->add_query(sprintf($qs[0], $args[1]['proid']), 1);
     $db_config->add_num_row(1, 1);
     $db_config->add_record($d[0], 1);
     $db_config->add_record(false, 1);
     $db_config->add_query(sprintf($qs[1], $args[1]['proid'], 'Views', '0', '0'), 2);
     $db_config->add_num_row(0, 2);
     // test one
     $db = new DB_SourceAgency();
     $this->capture_call('views_show', 46, $args[0]);
     $this->assertEquals("<p>The views have not been configured yet.<p>\n", $this->get_text(), 'Line: ' . __LINE__);
     // test two
     $db = new DB_SourceAgency();
     $bx = $this->_create_default_box();
     $this->capture_call('views_show', 4698 + strlen(timestr(mktimestamp($d[0]['creation']))), $args[1]);
     $this->_checkFor_a_box('Project Information Access');
     $this->_testFor_lib_nick($d[0]['description_user']);
     $str = " - " . timestr(mktimestamp($d[0]['creation'])) . "</b>";
     $this->_testFor_pattern($this->_to_regexp($str));
     $titles = array("View Project Configuration", "Write and Modify news", "Write comments", "See Project History", "See Step 3 (Milestones)", "See Step 4 (Referees)", "See Step 5 (Project Follow-up)", "See Developing Cooperation Proposals", "Project Permission Access");
     $this->_checkFor_column_titles($titles, 'right', '30%', '', '<b>%s</b>: ');
     $this->_testFor_lib_comment_it($args[1]['proid'], "Views", "", "0", "", "Comments on the views?");
     $values = array($d[0]["views"], $d[0]["cooperation"], $d[0]["step5"], $d[0]["step4"], $d[0]["step3"], $d[0]["history"], $d[0]["comments"], $d[0]["news"], $d[0]["configure"]);
     $this->_checkFor_column_values($values);
     $this->_check_db($db_config);
 }
コード例 #18
0
 function testBrowse_list()
 {
     global $db;
     $q = "SELECT * FROM description WHERE %s='%%s'";
     $q2 = "SELECT * FROM description,tech_content WHERE " . "description.proid=tech_content.proid AND " . "%s='%%s'";
     $qs = array('license' => "SELECT * FROM description,developing WHERE " . "description.proid=developing.proid AND " . "license = '%s'", 'project_name' => 'SELECT * FROM description WHERE status' . " > 0 AND  project_title LIKE '%s%%'", 'type' => sprintf($q, 'type'), 'steps' => sprintf($q, 'status'), 'volume' => sprintf($q, 'volume'), 'date' => sprintf($q, 'creation'), 'audience' => sprintf($q, ''), 'os' => sprintf($q, ''), 'language' => sprintf($q, ''), 'platform' => sprintf($q2, 'platform'), 'architecture' => sprintf($q2, 'architecture'), 'environment' => sprintf($q2, 'environment'));
     $db_config = new mock_db_configure(1);
     $args = array('by' => '', 'what' => 'this si teh waht value');
     $db = new DB_SourceAgency();
     while (list($by, $query) = each($qs)) {
         $args['by'] = $by;
         $db_config->add_query(sprintf($query, $args['what']), 0);
         $db_config->add_record(FALSE, 0);
         $this->capture_call('browse_list', 0, $args, true);
     }
     $this->_check_db($db_config);
 }
コード例 #19
0
 function testMonitor_insert()
 {
     global $db, $t;
     $fname = 'monitor_insert';
     $qs = array(0 => $this->queries[$fname . '_1'], 1 => $this->queries[$fname . '_2'], 2 => $this->queries['monitor_modify'], 3 => $this->queries['monitor_mail_3'], 4 => $this->queries['monitor_show']);
     $db_config = new mock_db_configure(4);
     $args = $this->_generate_records(array('proid', 'username', 'importance'), 10);
     $creation = 'thisd ithe creation';
     // test one: number of rows > 0 ==> monitor_modify called
     $db_config->add_query(sprintf($qs[0], $args[0]['proid'], $args[0]['username']), 0);
     $db_config->add_num_row(10, 0);
     $db_config->add_record(array('creation' => $creation), 0);
     $db_config->add_query(sprintf($qs[2], $args[0]['importance'], $args[0]['proid'], $args[0]['username']), 0);
     /** monitor mail call **/
     $db_config->add_query(sprintf($qs[3], $args[0]['proid']), 1);
     $db_config->add_record(false, 1);
     /** monitor show call **/
     $db_config->add_query(sprintf($qs[4], $args[0]['proid']), 0);
     $db_config->add_num_row(0, 0);
     $db = new DB_SourceAgency();
     $this->capture_call($fname, 41, $args[0]);
     // test two: number of rows == 0, insert and monitor_{mail,show} called
     $db_config->add_query(sprintf($qs[0], $args[1]['proid'], $args[1]['username']), 2);
     $db_config->add_num_row(0, 2);
     $db_config->add_query(sprintf($qs[1], $args[1]['proid'], $args[1]['username'], $args[1]['importance']), 2);
     /** monitor mail call **/
     $db_config->add_query(sprintf($qs[3], $args[1]['proid']), 3);
     $db_config->add_record(false, 3);
     /** monitor show call **/
     $db_config->add_query(sprintf($qs[4], $args[1]['proid']), 2);
     $db_config->add_num_row(0, 2);
     $db = new DB_SourceAgency();
     $this->capture_call($fname, 41, $args[1]);
     $this->_check_db($db_config);
 }
コード例 #20
0
 function testIs_first_sponsor_or_dev()
 {
     global $auth;
     $auth->set_perm("this is the permission");
     $auth->set_uname("this is the user name");
     $db_config = new mock_db_configure(10);
     $db_q = array(0 => $this->queries["is_main_developer"], 1 => $this->queries["is_first_sponsor_or_dev"], 2 => $this->queries["is_accepted_sponsor"], 3 => $this->queries["is_accepted_developer"]);
     $args = $this->_generate_records(array("proid"), 4);
     // case 1: is_main_developer => true
     $db_config->add_query(sprintf($db_q[3], $args[0]["proid"], $auth->auth["uname"]), 0);
     $db_config->add_num_row(1, 0);
     $db_config->add_query(sprintf($db_q[0], $args[0]["proid"], $auth->auth["uname"]), 1);
     $db_config->add_num_row(1, 1);
     $this->assertEquals(1, is_first_sponsor_or_dev($args[0]["proid"]));
     // case 2: is_main_developer => false, is_accepted_sponsor => false
     $db_config->add_query(sprintf($db_q[3], $args[1]["proid"], $auth->auth["uname"]), 2);
     $db_config->add_num_row(0, 2);
     // is_main_developer fails
     $db_config->add_query(sprintf($db_q[2], $args[1]["proid"], $auth->auth["uname"]), 3);
     $db_config->add_num_row(0, 3);
     // is_accepted_sponsor fails
     // FIXME: this is a bug, is_first_sponsor_or_dev should
     // FIXME: return something
     $this->assertEquals("", is_first_sponsor_or_dev($args[1]["proid"]));
     // case 3: is_main_developer => false, is_accepted_sponser => true
     // case 3: and num_rows returns value greater than zero
     $db_config->add_query(sprintf($db_q[3], $args[2]["proid"], $auth->auth["uname"]), 4);
     $db_config->add_num_row(0, 4);
     // is_main_developer fails
     $db_config->add_query(sprintf($db_q[2], $args[2]["proid"], $auth->auth["uname"]), 5);
     $db_config->add_num_row(1, 5);
     // is_accepted_sponsor succeeds
     $db_config->add_query(sprintf($db_q[1], $auth->auth["uname"]), 6);
     $db_config->add_num_row(1, 6);
     // is_first_sponsor_or_dev succeeds
     $this->assertEquals(1, is_first_sponsor_or_dev($args[2]["proid"]));
     // case 4: is_main_developer => false, is_accepted_sponser => true
     // case 4: and num_rows returns zero or less.
     $db_config->add_query(sprintf($db_q[3], $args[3]["proid"], $auth->auth["uname"]), 7);
     $db_config->add_num_row(0, 7);
     // is_main_developer fails
     $db_config->add_query(sprintf($db_q[2], $args[3]["proid"], $auth->auth["uname"]), 8);
     $db_config->add_num_row(1, 8);
     // is_accepted_sponsor succeeds
     $db_config->add_query(sprintf($db_q[1], $auth->auth["uname"]), 9);
     $db_config->add_num_row(0, 9);
     // is_first_sponsor_or_dev succeeds
     $this->assertEquals(0, is_first_sponsor_or_dev($args[3]["proid"]));
     $this->_check_db($db_config);
 }
コード例 #21
0
 function testSponsoring_insert()
 {
     global $db, $auth;
     $auth->set_uname("this is the username");
     $auth->set_perm("this is the permission");
     $db_config = new mock_db_configure(14);
     $db_q = array(0 => "SELECT COUNT(*) FROM sponsoring WHERE " . "proid='%s'", 1 => "INSERT sponsoring SET proid='%s',sponsor='%s'" . ",sponsoring_text='%s',budget='%s', status=" . "'%s', valid='%s',begin='%s',finish='%s'", 2 => "UPDATE configure SET sponsor='%s' WHERE " . "proid='%s'", 3 => "SELECT * FROM description WHERE proid='%s' " . "AND description_user='******'", 4 => "SELECT * FROM sponsoring,auth_user WHERE " . "proid='%s' AND sponsor=username ORDER BY " . "sponsoring.creation ASC", 5 => "SELECT * FROM sponsoring WHERE proid='%s' AND " . "sponsor='%s'", 6 => "UPDATE sponsoring SET sponsoring_text='%s', " . "budget='%s', status='%s', valid='%s'," . "begin='%s', finish='%s' " . "WHERE proid='%s' AND sponsor='%s'");
     $args = $this->_generate_records(array("proid", "user", "s_text", "budget", "v_day", "v_month", "v_year", "b_day", "b_month", "b_year", "f_day", "f_month", "f_year"), 4);
     $rows = $this->_generate_records(array("COUNT(*)"), 4);
     // first call
     $db_config->add_query(sprintf($db_q[0], $args[0]["proid"]), 0);
     $v = date_to_timestamp($args[0]["v_day"], $args[0]["v_month"], $args[0]["v_year"]);
     $b = date_to_timestamp($args[0]["b_day"], $args[0]["b_month"], $args[0]["b_year"]);
     $f = date_to_timestamp($args[0]["f_day"], $args[0]["f_month"], $args[0]["f_year"]);
     // query for checking the number of sponsoring the user has made
     $db_config->add_query(sprintf($db_q[5], $args[0]["proid"], $args[0]["user"]), 0);
     // insert query
     $db_config->add_query(sprintf($db_q[1], $args[0]["proid"], $args[0]["user"], $args[0]["s_text"], $args[0]["budget"], "P", $v, $b, $f), 0);
     // query for the show_sponsorings call
     $db_config->add_query(sprintf($db_q[4], $args[0]["proid"]), 0);
     // instance for the monitor_mail call
     $db_config->ignore_all_errors(1);
     // instance created by the is_project_initiator
     $db_config->add_query(sprintf($db_q[3], $args[0]["proid"], $auth->auth["uname"]), 2);
     $rows[0]["COUNT(*)"] = 1;
     // status is 'P' (proposed)
     $db_config->add_record($rows[0], 0);
     // sponsoring_insert
     $db_config->add_record(false, 0);
     // show_sponsorings
     // two if statements
     $db_config->add_num_row(0, 0);
     $db_config->add_num_row(0, 0);
     $db_config->add_num_row(1, 0);
     // show_sponsorings
     $db_config->add_num_row(1, 2);
     // 2nd call to is_project_initiator
     // second call
     $db_config->add_query(sprintf($db_q[0], $args[1]["proid"]), 3);
     $v = date_to_timestamp($args[1]["v_day"], $args[1]["v_month"], $args[1]["v_year"]);
     $b = date_to_timestamp($args[1]["b_day"], $args[1]["b_month"], $args[1]["b_year"]);
     $f = date_to_timestamp($args[1]["f_day"], $args[1]["f_month"], $args[1]["f_year"]);
     // query for checking the number of sponsoring the user has made
     $db_config->add_query(sprintf($db_q[5], $args[1]["proid"], $args[1]["user"]), 3);
     $db_config->add_query(sprintf($db_q[1], $args[1]["proid"], $args[1]["user"], $args[1]["s_text"], $args[1]["budget"], "A", $v, $b, $f), 3);
     // this is the update query
     $db_config->add_query(sprintf($db_q[2], $auth->auth["uname"], $args[1]["proid"]), 3);
     // query for the show_sponsorings call
     $db_config->add_query(sprintf($db_q[4], $args[1]["proid"]), 3);
     // 1st call to is_project_initiator
     $db_config->add_query(sprintf($db_q[3], $args[1]["proid"], $auth->auth["uname"]), 4);
     // instance for the monitor_mail call
     $db_config->ignore_all_errors(5);
     // instance created by the second call to is_project_initiator
     $db_config->add_query(sprintf($db_q[3], $args[1]["proid"], $auth->auth["uname"]), 6);
     $rows[1]["COUNT(*)"] = 0;
     // status is 'A'
     $db_config->add_record($rows[1], 3);
     // sponsoring_insert
     $db_config->add_record(false, 3);
     // show_sponsorings
     $db_config->add_num_row(0, 3);
     // if ( $db->num_rows() == 1 ) {
     $db_config->add_num_row(0, 3);
     // if ( $db->num_rows() == 0 ) {
     $db_config->add_num_row(1, 3);
     // show_sponsorings
     $db_config->add_num_row(0, 4);
     // 1st call to is_project_initiator
     $db_config->add_num_row(0, 6);
     // 2nd call to is_project_initiator
     // third call, check that an update query is executed if the
     // user already has a sponsorship.
     $db_config->add_query(sprintf($db_q[0], $args[2]["proid"]), 7);
     $v = date_to_timestamp($args[2]["v_day"], $args[2]["v_month"], $args[2]["v_year"]);
     $b = date_to_timestamp($args[2]["b_day"], $args[2]["b_month"], $args[2]["b_year"]);
     $f = date_to_timestamp($args[2]["f_day"], $args[2]["f_month"], $args[2]["f_year"]);
     // query for checking the number of sponsoring the user has made
     $db_config->add_query(sprintf($db_q[5], $args[2]["proid"], $args[2]["user"]), 7);
     // update query because user has already contributed
     $args[2]["budget"] = 1;
     $db_config->add_query(sprintf($db_q[6], $args[2]["s_text"], $args[2]["budget"], "P", $v, $b, $f, $args[2]["proid"], $args[2]["user"]), 7);
     // query for the show_sponsorings call
     $db_config->add_query(sprintf($db_q[4], $args[2]["proid"]), 7);
     // instance for the monitor_mail call
     $db_config->ignore_all_errors(8);
     $db_config->ignore_all_errors(9);
     // instance created by the is_project_initiator
     $db_config->add_query(sprintf($db_q[3], $args[2]["proid"], $auth->auth["uname"]), 10);
     $rows[2]["COUNT(*)"] = 1;
     // status is 'P' (proposed)
     $rows[2]["budget"] = 0;
     // old_budget should be less than new budget
     $db_config->add_record($rows[2], 7);
     // sponsoring_insert
     $db_config->add_record($rows[2], 7);
     // sponsoring_insert
     $db_config->add_record(false, 7);
     // show_sponsorings
     $db_config->add_num_row(1, 7);
     // user has already contributed
     $db_config->add_num_row(1, 7);
     // show_sponsorings
     $db_config->add_num_row(0, 10);
     // call to is_project_initiator
     // fourth call, this time the user has more than one sponsorship
     $db_config->add_query(sprintf($db_q[0], $args[3]["proid"]), 11);
     $v = date_to_timestamp($args[3]["v_day"], $args[3]["v_month"], $args[3]["v_year"]);
     $b = date_to_timestamp($args[3]["b_day"], $args[3]["b_month"], $args[3]["b_year"]);
     $f = date_to_timestamp($args[3]["f_day"], $args[3]["f_month"], $args[3]["f_year"]);
     // query for checking the number of sponsoring the user has made
     $db_config->add_query(sprintf($db_q[5], $args[3]["proid"], $args[3]["user"]), 11);
     // query for the show_sponsorings call
     $db_config->add_query(sprintf($db_q[4], $args[3]["proid"]), 11);
     // instance for the monitor_mail call
     $db_config->ignore_all_errors(11);
     $db_config->ignore_all_errors(12);
     // instance created by the is_project_initiator
     $db_config->add_query(sprintf($db_q[3], $args[3]["proid"], $auth->auth["uname"]), 13);
     $rows[3]["COUNT(*)"] = 1;
     // status is 'P' (proposed)
     $db_config->add_record($rows[3], 11);
     // sponsoring_insert
     $db_config->add_record(false, 11);
     // show_sponsorings
     $db_config->add_num_row(2, 11);
     // user has already contributed
     $db_config->add_num_row(2, 11);
     // user has already contributed
     $db_config->add_num_row(1, 11);
     // show_sponsorings
     $db_config->add_num_row(0, 13);
     // call to is_project_initiator
     // ********************************************************************
     // first call
     $db = new DB_SourceAgency();
     $this->set_msg('test 1');
     $this->capture_call('sponsoring_insert', 442, $args[0]);
     $this->_testFor_pattern("<a href=\"personal[.]php3[?]username="******"this[+]is[+]the[+]username\" class=" . "\"\">Personal Page<\\/a>");
     // second call, status = A and is not project initiator
     $db = new DB_SourceAgency();
     $this->set_msg('test 2');
     $this->capture_call('sponsoring_insert', 141, $args[1]);
     $this->_testFor_pattern("<p><b>Congratulations<\\/b>. You are the " . "first sponsor. You can <a href=\"" . "configure_edit.php3[?]proid=proid_1\" " . "class=\"\">configure this project<\\/a>");
     // third call: user has already contributed and wishes to make
     // a change to that contribution
     $db = new DB_SourceAgency();
     $this->set_msg('test 3');
     $this->capture_call('sponsoring_insert', 0, $args[2]);
     // fourth call: user has made too many contributions
     $db = new DB_SourceAgency();
     $this->set_msg('test 4');
     $this->capture_call('sponsoring_insert', 137, $args[3]);
     $this->_testFor_pattern("<p><b>Database Failure:<\\/b> it seems you " . "have more than one sponsorship! Please " . "advice the administrator and have the " . "database corrected.");
     // finally check that everything went smoothly with the DB
     $this->_check_db($db_config);
 }