# # 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("80%", $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_edit"; if (check_permission($proid, $page)) { top_bar($proid, $page); print $t->translate('News can be posted by the project owner(s)') . ".\n<br><p>\n"; if (!isset($submit) || empty($submit)) { if (isset($preview) && !empty($preview)) { news_preview($proid); } newsform($proid); } else { news_insert($proid, $auth->auth["uname"], $subject, $text); } } end_content(); require "include/footer.inc"; @page_close();
function testNews_insert() { global $db; $db_config = new mock_db_configure(2); $row = array(0 => $this->_generate_array(array("proid", "user", "subject", "text"), 0)); $db_q = array(0 => "INSERT news SET proid='%s',user_news='%s'," . "subject_news='%s',text_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]["proid"], $row[0]["user"], $row[0]["subject"], $row[0]["text"]), 0); $db_config->add_query(sprintf($db_q[2], $row[0]["proid"]), 0); $db_config->add_query(sprintf($db_q[1], $row[0]["proid"]), 1); $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_insert($row[0]["proid"], $row[0]["user"], $row[0]["subject"], $row[0]["text"]); $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); }