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);
 }
Ejemplo n.º 2
0
# Copyright (c) 2001-2003 by
#             Gregorio Robles (grex@scouts-es.org)
#
# BerliOS SourceAgency: http://sourcewell.berlios.de
# BerliOS - The OpenSource Mediator: http://www.berlios.de
#
#
#
# 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/monitorlib.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 = "monitor";
if (check_permission($proid, $page)) {
    top_bar($proid, $page);
    print $t->translate('Users that are monitoring this project') . ".<p>\n";
    monitor_show($proid);
}
end_content();
require "include/footer.inc";
@page_close();