# # This is the index file which shows the recent apps # # This program is free software. You can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 or later of the GPL. ###################################################################### require "include/prepend.php3"; page_open(array("sess" => "SourceAgency_Session")); if (isset($auth) && !empty($auth->auth["perm"])) { page_close(); page_open(array("sess" => "SourceAgency_Session", "auth" => "SourceAgency_Auth", "perm" => "SourceAgency_Perm")); } require "include/header.inc"; require "include/newslib.inc"; $bx = new box("100%", $th_box_frame_color, $th_box_frame_width, $th_box_title_bgcolor, $th_box_title_font_color, $th_box_title_align, $th_box_body_bgcolor, $th_box_body_font_color, $th_box_body_align); start_content(); $page = "news"; if (check_proid($proid)) { top_bar($proid, $page); htmlp_image("ic/b.png", 0, 60, 60, "Summary"); print $t->translate("News are posted by the project initiator. " . "Any other contribution can be done by " . "filling out a General Comment") . ".<p>\n"; if (is_project_initiator($proid)) { print "<p align=right>[ " . html_link("news_edit.php", array("proid" => $proid), $t->translate("Submit News")) . " ]\n"; } newsshow($proid); lib_comment_it($proid, "General", "0", "0", "", $t->translate("General Comments")); } end_content(); require "include/footer.inc"; @page_close();
function testNewsshow() { global $db, $bx, $t; $db_config = new mock_db_configure(7); $proid = array(0 => "proid_0", 1 => "proid_1", 2 => "proid_2"); $db_q = array(0 => "SELECT * FROM news,auth_user WHERE proid='%s' " . "AND user_news=username ORDER BY creation_news " . "DESC", 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"); $row = array(0 => $this->_generate_array(array("subject_news", "creation_news", "user_news", "text_news"), 0), 1 => $this->_generate_array(array("subject_news", "creation_news", "user_news", "text_news"), 1), 2 => $this->_generate_array(array("subject_news", "creation_news", "user_news", "text_news"), 2), 3 => $this->_generate_array(array("user_cmt", "creation_cmt", "subject_cmt", "id"), 3)); $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_query(sprintf($db_q[1], $proid[1], "News", $row[0]["creation_news"], "0"), 2); $db_config->add_query(sprintf($db_q[0], $proid[2]), 3); $db_config->add_query(sprintf($db_q[1], $proid[2], "News", $row[1]["creation_news"], "0"), 4); $db_config->add_query(sprintf($db_q[1], $proid[2], "News", $row[2]["creation_news"], "0"), 5); $db_config->add_query(sprintf($db_q[1], $proid[2], "News", $row[2]["creation_news"], $row[3]["id"]), 6); $db_config->add_num_row(0, 0); $db_config->add_num_row(1, 1); $db_config->add_num_row(0, 2); $db_config->add_num_row(2, 3); $db_config->add_num_row(0, 4); $db_config->add_num_row(1, 5); $db_config->add_num_row(0, 6); $db_config->add_record($row[0], 1); $db_config->add_record($row[1], 3); $db_config->add_record($row[2], 3); $db_config->add_record($row[3], 5); // // first call, no records // $bx = $this->_create_default_box(); $db = new DB_SourceAgency(); capture_reset_and_start(); newsshow($proid[0]); $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>"); // // second call, one record but no comment on it. // $bx = $this->_create_default_box(); $db = new DB_SourceAgency(); capture_reset_and_start(); newsshow($proid[1]); $this->set_text(capture_stop_and_get()); $this->set_msg("test 2"); $this->_testFor_string_length(894); $this->_checkFor_a_box('News', '%s: ' . $row[0]['subject_news']); $this->_testFor_lib_nick($row[0]['user_news']); $this->_testFor_lib_comment_it($proid[1], 'News', $row[0]['creation_news'], '0', 'Re:' . $row[0]['subject_news'], $t->translate('Comment This News!')); // // third call, two records, the second has a comment which makes // a recursive call to show_comments_on_it which in turn has no rows // $bx = $this->_create_default_box(); $db = new DB_SourceAgency(); capture_reset_and_start(); newsshow($proid[2]); $this->set_text(capture_stop_and_get()); $this->set_msg('test 3'); $this->_testFor_string_length(1943); $this->_checkFor_a_box('News', '%s: ' . $row[1]['subject_news']); $this->_checkFor_a_box('News', '%s: ' . $row[2]['subject_news']); $this->_testFor_lib_nick($row[1]['user_news']); $this->_testFor_lib_nick($row[2]['user_news']); $this->_testFor_lib_comment_it($proid[2], 'News', $row[2]['creation_news'], '0', 'Re:' . $row[2]['subject_news'], $t->translate('Comment This News!')); // check that the database component did not fail $this->_check_db($db_config); }