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 testDeveloping_preview() { global $t, $bx, $auth; global $cost, $license, $cooperation, $valid_day, $valid_month, $valid_year, $start_day, $start_month, $start_year, $duration; $proid = 'this is the proid'; $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'; $slen = strlen(timestr(time())) + 1188; $bx = $this->_create_default_box(); $this->capture_call('developing_preview', $slen, array($proid)); $this->_checkFor_a_box('PREVIEW', '<center><b>%s</b></center>'); $this->_checkFor_a_box('Developing Proposal'); $v = array('Cost' => $cost . " euros", 'License' => $license, 'Cooperation' => $cooperation, 'Status' => 'Proposed', 'Validity' => timestr_middle(mktimestamp(date_to_timestamp($valid_day, $valid_month, $valid_year))), 'Start possible' => timestr_middle(mktimestamp(date_to_timestamp($start_day, $start_month, $start_year))), 'Duration' => $duration . " weeks"); while (list($key, $val) = each($v)) { $str = sprintf('<b>%s:</b> %s\\n', $t->translate($key), $val); $this->_testFor_pattern('[<]..?[>]' . $this->_to_regexp($str)); } }
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 testCalendar_box() { global $bx, $t; // 4 instances required: 2 for the no budget case, and 2 for the // budget is set case. $db_config = new mock_db_configure(4); $db_q = array(0 => $this->queries['calendar_box_1'], 1 => $this->queries['calendar_box_2']); $dat = array("r0" => "proid1", "e0" => 1, "r1" => "proid1", "e1" => 0, "r2" => "proid2", "e2" => 1, "r3" => "proid2", "e3" => 1); $db_config->add_query(sprintf($db_q[0], $dat["r0"]), 0); $db_config->add_query(sprintf($db_q[1], $dat["r1"]), 1); $db_config->add_query(sprintf($db_q[0], $dat["r2"]), 2); $db_config->add_query(sprintf($db_q[1], $dat["r3"]), 3); $db_config->add_num_row($dat["e1"], 1); $db_config->add_num_row($dat["e3"], 3); $row1 = $this->_generate_array(array("description_user", "volume", "type", "description_creation", "perms"), 1); $db_config->add_record($row1, 0); $row3 = $this->_generate_array(array("description_user", "volume", "type", "description_creation", "perms"), 2); $row3["perms"] = "devel"; $db_config->add_record($row3, 2); $row2 = array("SUM(budget)" => "INCORRECT"); $db_config->add_record($row2, 1); $row4 = array("SUM(budget)" => 1000); $db_config->add_record($row4, 3); // test one: no budget $bx = $this->_create_default_box(); $this->set_msg('test 1'); $this->capture_call('calendar_box', 3287, array(0 => $dat["r0"])); $this->_checkFor_columns(2); $titles = array("Project Owner(s)", "Project Type", "Project Nature", "Project Volume", "Current project budget", "Creation"); $this->_checkFor_column_titles($titles, 'left', '55%', '', '<b>%s:</b>'); $tStamp = mktimestamp($row1['description_creation']); $nature = "Unknown"; $budget = "0"; $values = array(' ' . $row1["description_user"], ' ' . $row1["type"], ' ' . $t->translate($nature), ' ' . $row1['volume'], "{$budget} euro", ' ' . timestr_middle($tStamp)); $this->_checkFor_column_values($values, 'left', '', ''); // test two: // This run has a budget and the budget value should be printed $bx = $this->_create_default_box(); $this->set_msg('test 2'); $this->capture_call('calendar_box', 3293, array(0 => $dat["r2"])); $this->_checkFor_columns(2); $titles = array("Project Owner(s)", "Project Type", "Project Nature", "Project Volume", "Current project budget", "Creation"); $this->_checkFor_column_titles($titles, 'left', '55%', '', '<b>%s:</b>'); $tStamp = mktimestamp($row3['description_creation']); $nature = "Developing"; $budget = $row4["SUM(budget)"]; $values = array(' ' . $row3["description_user"], ' ' . $row3["type"], ' ' . $t->translate($nature), ' ' . $row3['volume'], "{$budget} euro", ' ' . timestr_middle($tStamp)); $this->_checkFor_column_values($values, 'left', '', ''); // check that the database component did not fail $this->_check_db($db_config); }
function testSponsoring_preview() { global $auth, $sponsoring_text, $budget, $valid_day, $valid_month, $valid_year, $begin_day, $begin_month, $begin_year, $finish_day, $finish_month, $finish_year, $bx, $t; $auth->set_uname("this is the username"); $sponsoring_text = "this is the sponsoring text"; $budget = "this is the budget"; $valid_day = 3; $begin_day = 4; $finish_day = 5; $valid_month = 4; $begin_month = 5; $finish_month = 6; $valid_year = 2001; $begin_year = 2002; $finish_year = 2003; $bx = $this->_create_default_box(); $this->capture_call('sponsoring_preview', 1196 + strlen(timestr(time()))); $this->set_msg('test 1'); $this->_checkFor_a_box('PREVIEW', '<center><b>%s</b></center>'); $this->_checkFor_a_box('Sponsor Involvement'); $this->_testFor_lib_nick($auth->auth['uname']); $v = array('Status' => 'Proposed', 'Validity' => timestr_middle(mktimestamp(date_to_timestamp($valid_day, $valid_month, $valid_year))), 'Finish before' => timestr_middle(mktimestamp(date_to_timestamp($finish_day, $finish_month, $finish_year))), 'Begin wished' => timestr_middle(mktimestamp(date_to_timestamp($begin_day, $begin_month, $begin_year))), 'Max. sum of money' => "{$budget} euros", 'Comments to the involvement' => "{$sponsoring_text}"); while (list($key, $val) = each($v)) { $this->_testFor_pattern($this->_to_regexp('<b>' . $t->translate($key) . ':</b> ' . $val)); } }