function testComments_preview()
 {
     global $t, $bx, $auth, $subject, $text;
     $auth->set_uname('this is the username');
     $subject = 'this is the subject';
     $text = 'this is the text//\\//\\fubar[[]][*](?)';
     $db_config = new mock_db_configure(1);
     $db_config->add_query("SELECT email_usr FROM auth_user WHERE " . "username='******'");
     $bx = $this->_create_default_box();
     $this->capture_call('comments_preview', 983 + strlen(timestr(time())), array(''));
     $this->_checkFor_a_box('Comment', '%s ' . stripslashes($subject));
     $this->_checkFor_a_box('PREVIEW', '<center><b>%s</b></center>');
     $ps = array(0 => $this->_to_regexp(lib_nick($auth->auth['uname'])), 1 => $this->_to_regexp("<p>" . stripslashes($text) . "\n"));
     $this->_testFor_patterns($ps, 2);
     $this->_check_db($db_config);
 }
 function _testFor_show_admprojects_basics(&$d, $bgc)
 {
     global $t;
     $this->_checkFor_a_box('Pending Project Administration');
     $this->_checkFor_columns(7);
     $v = array('Project Title' => array('', '15%', ''), 'Type' => array('center', '10%', ''), 'Description' => array('center', '30%', ''), 'User' => array('center', '10%', ''), 'Volume' => array('center', '7%', ''), 'Configured?' => array('center', '7%', ''), 'Creation' => array('center', '12%', ''));
     while (list($key, $va) = each($v)) {
         $this->_checkFor_column_titles(array($key), $va[0], $va[1], $va[2]);
     }
     $v = array(html_link('summary.php3', array('proid' => $d['proid']), $d['project_title']) => array('', '', $bgc), $d['type'] => array('', '', $bgc), $d['description'] => array('', '', $bgc), lib_nick($d['description_user']) => array('center', '', $bgc), $d['volume'] => array('center', '', $bgc), timestr_short(mktimestamp($d['description_creation'])) => array('center', '', $bgc));
     while (list($key, $va) = each($v)) {
         $this->_checkFor_column_titles(array($key), $va[0], $va[1], $va[2]);
     }
     $this->_testFor_box_colspan(8, 'center', '#FFFFF', '&nbsp;');
     $this->_testFor_box_colspan(8, 'center', '#FEDCBA', $t->translate('Sponsored projects'));
     $this->_testFor_box_colspan(8, 'center', '#ABCDEF', $t->translate('Developing projects'));
     $this->_checkFor_a_form('PHP_SELF', array(), 'POST');
 }
 function testShow_consultants()
 {
     global $db, $t, $bx;
     $db_config = new mock_db_configure(2);
     $db_q = array(0 => "SELECT * FROM consultants,auth_user WHERE " . "proid='%s' AND username=consultant ORDER " . "BY creation");
     $dat = $this->_generate_records(array("proid"), 2);
     $rows = $this->_generate_records(array("username", "status", "creation"), 3);
     $db_config->add_query(sprintf($db_q[0], $dat[0]["proid"]), 0);
     $db_config->add_query(sprintf($db_q[0], $dat[1]["proid"]), 1);
     $db_config->add_num_row(0, 0);
     $db_config->add_num_row(3, 1);
     $db_config->add_record($rows[0], 1);
     $db_config->add_record($rows[1], 1);
     $db_config->add_record($rows[2], 1);
     // first test: no data to list, print error message
     $db = new DB_SourceAgency();
     $bx = new box();
     $this->set_msg("test 1");
     $this->capture_call('show_consultants', 64, &$dat[0]);
     $this->_testFor_pattern("No developers have offered " . "themselves as consultants yet");
     // second test: three pieces of data
     $db = new DB_SourceAgency();
     $bx = $this->_create_default_box();
     $this->set_msg('test 2');
     $this->capture_call('show_consultants', 3573, &$dat[1]);
     $this->_checkFor_a_box('Consultants');
     $this->_checkFor_columns(4);
     $this->_checkFor_column_titles(array("Number", "Username", "Status", "Creation"), '', '', '');
     $colors = array(1 => 'gold', 0 => '#FFFFFF');
     for ($idx = 1; $idx < 4; $idx++) {
         $row = $rows[$idx - 1];
         $this->set_msg("Test {$idx}");
         $this->_testFor_box_next_row_of_columns();
         $this->_checkFor_column_values(array('<b>' . $idx . '</b>', '<b>' . lib_nick($row['username']), '<b>' . show_status($row["status"]) . '</b>', '<b>' . timestr(mktimestamp($row["creation"])) . '</b>'), '', '', $colors[$idx % 2]);
     }
     $this->_check_db($db_config);
 }
 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);
 }
 function _checkFor_show_proposals($proid, &$row, $count_star_1, $count_star_2)
 {
     global $t, $sess;
     $strings = array('><b>' . $t->translate('Developing Proposal') . '</b><', '<b>' . lib_nick($row['username']) . ' - ' . timestr(mktimestamp($row['creation'])) . "</b>\n");
     foreach ($strings as $str) {
         $this->_testFor_pattern($this->_to_regexp($str));
     }
     $tv = array('Cost' => $row['cost'] . " euros", 'License' => $row['license'], 'Status' => show_status($row['status']), 'Valid' => timestr_middle(mktimestamp($row['valid'])), 'Start' => timestr_middle(mktimestamp($row['start'])), 'Duration' => $row['duration'] . " weeks");
     while (list($key, $val) = each($tv)) {
         $str = sprintf("<b>%s:</b> %s\n", $t->translate($key), $val);
         $this->_testFor_pattern("[<]..?[>]" . $this->_to_regexp($str));
     }
     /** check for a cooperation link or not .... **/
     $str1 = html_link('cooperation.php3', array('proid' => $proid, 'devid' => $row['devid']), 'Cooperation') . ' [' . $count_star_1 . ']';
     $str2 = 'Cooperation [' . $count_star_1 . ']';
     if ($row['cooperation'] != 'No') {
         if ($count_star_1) {
             $this->_testFor_pattern($this->_to_regexp($str1));
             $this->reverse_next_test();
             $this->_testFor_pattern($this->_to_regexp($str2));
         } else {
             $this->reverse_next_test();
             $this->_testFor_pattern($this->_to_regexp($str1));
             $this->_testFor_pattern($this->_to_regexp($str2));
         }
     } else {
         $this->reverse_next_test();
         $this->_testFor_pattern($this->_to_regexp($str1));
         $this->reverse_next_test();
         $this->_testFor_pattern($this->_to_regexp($str2));
     }
     /** check for a comments link **/
     $str1 = html_link('comments.php3', array('proid' => $proid, 'type' => 'proposals', 'number' => $row['devid']), 'Comments') . ' [' . $count_star_2 . "]\n";
     $str2 = 'Comments [0]';
     if ($count_star_2 > 0) {
         $this->_testFor_pattern($this->_to_regexp($str1));
         $this->reverse_next_test();
         $this->_testFor_pattern($this->_to_regexp($str2));
     } else {
         $this->reverse_next_test();
         $this->_testFor_pattern($this->_to_regexp($str1));
         $this->_testFor_pattern($this->_to_regexp($str2));
     }
     $str = "<FONT SIZE=-1>[ <a href=\"" . $sess->url("comments_edit.php3") . $sess->add_query(array("proid" => $proid, "type" => "proposal", "number" => $row["devid"])) . "\">Comment This Proposal</a> ]</FONT><p>\n";
     $this->_testFor_pattern($this->_to_regexp($str));
 }
 function testSummary_news()
 {
     global $sess, $t;
     $fname = 'summary_news';
     $db_config = new mock_db_configure(5);
     $qs = array(0 => $this->queries[$fname . '_1'], 1 => $this->queries[$fname . '_2']);
     $args = $this->_generate_records(array('proid'), 10);
     $d1 = $this->_generate_records(array('creation_news', 'subject_news', 'user_news'), 10);
     // 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($d1[0], 1);
     $db_config->add_record(false, 1);
     $db_config->add_query(sprintf($qs[1], $args[1]['proid'], $d1[0]['creation_news']), 2);
     $db_config->add_num_row(0, 2);
     // test three
     $db_config->add_query(sprintf($qs[0], $args[2]['proid']), 3);
     $db_config->add_num_row(1, 3);
     $db_config->add_record($d1[1], 3);
     $db_config->add_record(false, 3);
     $db_config->add_query(sprintf($qs[1], $args[2]['proid'], $d1[1]['creation_news']), 4);
     $db_config->add_num_row(1, 4);
     $db_config->add_num_row(1, 4);
     $this->capture_call($fname, 189, $args[0]);
     $strings = array("&nbsp;" . $t->translate("There have not been posted any news by the " . "project owner(s)") . ".\n", "<p align=right><a href=\"" . $sess->url("news_edit.php3") . $sess->add_query(array("proid" => $args[0]['proid'])) . "\"><FONT SIZE=\"-1\">[" . $t->translate("Submit News") . "]</FONT></a>&nbsp;&nbsp;" . "<br>&nbsp;\n");
     foreach ($strings as $str) {
         $this->_testFor_pattern($this->_to_regexp($str));
     }
     $this->capture_call($fname, 269, $args[1]);
     $strings = array(html_link('news.php3', array('proid' => $args[1]['proid']), '<b>' . $d1[0]['subject_news'] . '</b><br>'), "<b><font size=\"-1\">&nbsp;" . lib_nick($d1[0]['user_news']) . ' - ' . timestr_comment(mktimestamp($d1[0]['creation_news'])) . "</b></font><br>\n", "<p align=right><a href=\"" . $sess->url("news_edit.php3") . $sess->add_query(array("proid" => $args[1]['proid'])) . "\"><FONT SIZE=\"-1\">[" . $t->translate("Submit News") . "]</FONT></a>&nbsp;&nbsp;" . "<br>&nbsp;\n");
     foreach ($strings as $str) {
         $this->_testFor_pattern($this->_to_regexp($str));
     }
     $this->capture_call($fname, 407, $args[2]);
     $strings = array(html_link('news.php3', array('proid' => $args[2]['proid']), '<b>' . $d1[1]['subject_news'] . '</b><br>'), "<b><font size=\"-1\">&nbsp;" . lib_nick($d1[1]['user_news']) . ' - ' . timestr_comment(mktimestamp($d1[1]['creation_news'])) . "</b></font><br>\n", "<p align=right><a href=\"" . $sess->url("news_edit.php3") . $sess->add_query(array("proid" => $args[2]['proid'])) . "\"><FONT SIZE=\"-1\">[" . $t->translate("Submit News") . "]</FONT></a>&nbsp;&nbsp;" . "<br>&nbsp;\n", "&nbsp;<font size=-1>[ 1 " . html_link('comments.php3', array('proid' => $args[2]['proid'], 'type' => 'News', 'number' => $d1[1]['creation_news'], 'ref' => '0'), $t->translate('comments')) . $t->translate(' on it') . " ]</font>\n");
     foreach ($strings as $str) {
         $this->_testFor_pattern($this->_to_regexp($str));
     }
     $this->_check_db($db_config);
 }
 function testMonitor_show()
 {
     global $db, $t, $bx;
     $db_config = new mock_db_configure(2);
     $proid = array(0 => "proid_0", 1 => "proid_1");
     $db_q = array(0 => $this->queries['monitor_show']);
     $db_config->add_query(sprintf($db_q[0], $proid[0]), 0);
     $db_config->add_query(sprintf($db_q[0], $proid[1]), 1);
     $db_config->add_num_row(0, 0);
     $db_config->add_num_row(4, 1);
     $row = $this->_generate_records(array("username", "perms", "importance", "creation"), 4);
     $db_config->add_record($row[0], 1);
     $db_config->add_record($row[1], 1);
     $db_config->add_record($row[2], 1);
     $db_config->add_record($row[3], 1);
     //
     // first call, no records
     //
     $db = new DB_SourceAgency();
     $bx = $this->_create_default_box();
     capture_reset_and_start();
     monitor_show($proid[0]);
     $this->set_text(capture_stop_and_get());
     $this->set_msg('test 1');
     $this->_testFor_string_length(41);
     $this->_testFor_pattern("<p>" . $t->translate("Nobody is monitoring this " . "project") . "[.]<p>\n");
     //
     // second call, 4 records
     //
     $db = new DB_SourceAgency();
     $bx = $this->_create_default_box();
     capture_reset_and_start();
     monitor_show($proid[1]);
     $this->set_text(capture_stop_and_get());
     $this->set_msg('test 2');
     $this->_testFor_string_length(5255);
     $color = array(0 => "gold", 1 => "#FFFFFF");
     $this->_checkFor_a_box('All these users are monitor this project');
     $this->_checkFor_columns(5);
     $w = array('Number' => '10%', 'Username' => '20%', 'Type' => '20%', 'Importance filter' => '20%', 'Creation' => '30%');
     while (list($key, $val) = each($w)) {
         $this->_checkFor_column_titles(array($key), 'center', $val, '');
     }
     for ($idx = 0; $idx < 4; $idx++) {
         $this->set_msg('test ' . $idx);
         $this->_testFor_box_column('center', '', $color[$idx % 2], '<b>' . ($idx + 1) . '</b>');
         $this->_testFor_box_column('center', '', $color[$idx % 2], '<b>' . lib_nick($row[$idx]['username']) . '</b>');
         $this->_testFor_box_column('center', '', $color[$idx % 2], '<b>' . $row[$idx]['perms'] . '</b>');
         $this->_testFor_box_column('center', '', $color[$idx % 2], '<b>' . $row[$idx]['importance'] . '</b>');
         $str = timestr_middle(mktimestamp($row[$idx]['creation']));
         $this->_testFor_box_column('center', '', $color[$idx % 2], '<b>' . $str . '</b>');
     }
     // finally check that everything went smoothly with the DB
     $this->_check_db($db_config);
 }
 function testViews_preview()
 {
     global $t, $auth, $bx, $configure, $news, $comments, $history, $step3, $step4, $step5, $cooperation, $views;
     $auth->set_uname('this is the username');
     $configure = "this is the configure";
     $news = "this is the news";
     $comments = "these are the comments";
     $history = 'this is the history';
     $step3 = "tjos si step 3";
     $step4 = "tjsp ios tje step 4";
     $step5 = 'this is the stpe 5';
     $cooperation = "tjhs is the cooperation";
     $views = "this is the virw";
     $proid = 'thsi is th proid';
     // created by the call to the lib_show_comments_on_it function
     $db_config = new mock_db_configure(1);
     $db_config->add_query("SELECT * FROM comments,auth_user WHERE proid" . "='{$proid}' AND type='Views' AND number='0' " . "AND ref='0' AND user_cmt=username " . "ORDER BY creation_cmt ASC", 0);
     $db_config->add_num_row(0, 0);
     $bx = $this->_create_default_box();
     $this->capture_call('views_preview', 5020 + strlen(timestr(time())), array(&$proid));
     $this->_checkFor_a_box('PREVIEW', "<center><b>%s</b></center>");
     $this->_checkFor_a_box('Project Information Access');
     $this->_testFor_pattern($this->_to_regexp(lib_nick($auth->auth['uname'])));
     $v = array("View Project Configuration" => $configure, "Write and Modify news" => $news, "Write comments" => $comments, "See Project History" => $history, "See Step 3 (Milestones)" => $step3, "See Step 4 (Referees)" => $step4, "See Step 5 (Project Follow-up)" => $step5, "See Developing Cooperation Proposals" => $cooperation, "Project Permission Access" => $views);
     while (list($key, $val) = each($v)) {
         $this->_checkFor_column_titles(array($key), 'right', '30%', '', "<b>%s</b>: ");
         $this->_checkFor_column_values(array($val));
     }
     $this->_testFor_lib_comment_it($proid, 'Views', '', '0', '', $t->translate('Comments on the views?'));
     $this->_check_db($db_config);
 }