###################################################################### # SourceAgency: # ================================================ # # Copyright (c) 2001-2003 by # Gregorio Robles (grex@scouts-es.org) # # BerliOS SourceAgency: http://sourceagency.berlios.de # BerliOS - The OpenSource Mediator: http://www.berlios.de # # 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/personallib.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 = "personal_ratings"; personal_comments_long($auth->auth["uname"]); end_content(); require "include/footer.inc"; page_close();
function testPersonal_comments_long() { global $bx; $user1 = "fubar"; $user2 = "snafu"; $db_config = new mock_db_configure(4); $db_q = array(0 => "SELECT * FROM comments WHERE user_cmt='%s' " . "AND comments.proid", 1 => "SELECT COUNT(*) FROM comments WHERE " . "proid='%s' AND type='%s' AND ref='%s'", 2 => "SELECT * FROM description WHERE proid='%s'"); $db_config->add_query(sprintf($db_q[0], $user1), 0); $db_config->add_query(sprintf($db_q[0], $user2), 1); $db_config->add_num_row(0, 0); // fubar generates zero // comments_long now does two calls to num_row $db_config->add_num_row(0, 0); $db_config->add_record(false, 0); $db_config->add_num_row(2, 1); // snafu generates two // comments_long now makes two calls to num_row $db_config->add_num_row(2, 1); $row1 = $this->_generate_array(array('id', 'proid', 'type', 'number', 'subject_cmt', 'creation_cmt', 'ref'), 1); $db_config->add_record($row1, 1); $row2 = $this->_generate_array(array('id', 'proid', 'type', 'number', 'subject_cmt', 'creation_cmt', 'ref'), 2); $db_config->add_record($row2, 1); $db_config->add_record(false, 1); // sub-queries $db_config->add_query(sprintf($db_q[1], $row1['proid'], $row1['type'], $row1['id']), 2); $row3 = array('COUNT(*)' => 'this is count start row3'); $db_config->add_record($row3, 2); $db_config->add_query(sprintf($db_q[2], $row1['proid']), 2); $row4 = array('proid' => 'proid_row4', 'project_title' => 'project title row4'); $db_config->add_record($row4, 2); $db_config->add_query(sprintf($db_q[1], $row2['proid'], $row2['type'], $row2['id']), 3); $row5 = array('COUNT(*)' => 'this is count start row5'); $db_config->add_record($row5, 3); $db_config->add_query(sprintf($db_q[2], $row2['proid']), 3); $row6 = array('proid' => 'proid_row6', 'project_title' => 'project title row6'); $db_config->add_record($row6, 3); // // fubar query // $bx = $this->_create_default_box(); capture_reset_and_start(); // here next_record will not be called personal_comments_long($user1); $this->set_text(capture_stop_and_get()); $this->set_msg('test 1'); $this->_testFor_string_length(723); $this->_testFor_pattern("All Comments by " . $user1); $this->_testFor_pattern("no comments posted\n"); $this->reverse_next_test(); $this->_testFor_pattern('See all the comments...'); // // snafu query // $bx = $this->_create_default_box(); capture_reset_and_start(); // here next_record will not be called personal_comments_long($user2); $this->set_text(capture_stop_and_get()); $this->set_msg('test 2'); $this->_testFor_string_length(1298); $this->_testFor_pattern("All Comments by " . $user2); $this->reverse_next_test(); $this->_testFor_pattern('no comments posted'); $this->reverse_next_test(); $this->_testFor_pattern('See all the comments...'); $this->_testFor_comment_line($row1['type'], $row1['proid'], $row1['number'], $row1['ref'], $row1['subject_cmt'], $row3['COUNT(*)'], $row4['proid'], $row4['project_title']); $this->_testFor_comment_line($row2['type'], $row2['proid'], $row2['number'], $row2['ref'], $row2['subject_cmt'], $row5['COUNT(*)'], $row6['proid'], $row6['project_title']); // if using a database, then ensure that it didn't fail $this->_check_db($db_config); }