Tests also were modified + the whoisonline.php

skala
Julio Montoya 16 years ago
parent 5f8bc0710b
commit d831a332f2
  1. 36
      tests/main/inc/lib/online.inc.test.php
  2. 75
      tests/test_manager.inc.php
  3. 8
      whoisonline.php

@ -90,11 +90,43 @@ class TestOnline extends UnitTestCase {
//var_dump($rarray); //var_dump($rarray);
} }
function testWhoIsOnline() { function testwho_is_online() {
$valid=''; $valid='';
$res=WhoIsOnline($valid); $res=who_is_online($valid);
$this->assertTrue(is_array($res)); $this->assertTrue(is_array($res));
//var_dump($res); //var_dump($res);
} }
function testwho_is_online_in_this_course_count() {
/* $uid='';
$valid='';
$rarray = array();
$barray = array();
$login_user_id= '';
$login_date= '';
array_push($rarray,$barray);
array_push($barray,$login_user_id);
array_push($barray,$login_date);
$res=who_is_online_in_this_course_count($uid, $valid, $coursecode=null);
if(!empty($barray)){
$this->assertTrue(is_array($barray));
//var_dump($str);
} else {
$this->assertTrue(is_bool($barray));
//var_dump($rarray);
}
//var_dump($rarray);*/
}
function testwho_is_online_count() {
/* $valid='';
$res=who_is_online_count($valid);
$this->assertTrue(is_array($res));
//var_dump($res);*/
}
} }
?> ?>

@ -1,38 +1,30 @@
<?php <?php
// $Id: test_manager.inc.php 2010-02-17 12:07:00Z aportugal $ /* For licensing terms, see /license.txt */
/* For licensing terms, see /chamilo_license.txt */
/** /**
==============================================================================
* Code library for load functions than are needed to test * Code library for load functions than are needed to test
* *
* @author Arthur Portugal, Principal author * @author Arthur Portugal, Principal author
* @package chamilo.tests * @package chamilo.tests
==============================================================================
*/ */
/** /**
* @todo shouldn't these settings be moved to the test_suite.php * @todo shouldn't these settings be moved to the test_suite.php
* if these are really configuration then we can make require_once in each tests * if these are really configuration then we can make require_once in each tests file.
* file.
* @todo use this file to load in the setup in each file test. * @todo use this file to load in the setup in each file test.
* @todo use this file to destroy in the teardown in each file test. * @todo use this file to destroy in the teardown in each file test.
* @todo check for duplication of "require_once" files with test_suite.php * @todo check for duplication of "require_once" files with test_suite.php
* @author aportugal * @author Arthur Portugal
*/ */
/* /*
==============================================================================
INIT SECTION INIT SECTION
==============================================================================
*/ */
ini_set('memory_limit','256M'); ini_set('memory_limit','256M');
ini_set('max_execution_time','0'); ini_set('max_execution_time','0');
/* /*
-----------------------------------------------------------
Included libraries Included libraries
-----------------------------------------------------------
*/ */
$maindir = dirname(__FILE__).'/../main/'; $maindir = dirname(__FILE__).'/../main/';
$incdir = dirname(__FILE__).'/../main/inc/'; $incdir = dirname(__FILE__).'/../main/inc/';
@ -100,11 +92,7 @@ ob_end_clean();
class TestManager { class TestManager {
/** /* MAIN CODE */
==============================================================================
MAIN CODE
==============================================================================
*/
/** /**
* This function create in the database a test course and will also load sessions. * This function create in the database a test course and will also load sessions.
@ -115,12 +103,7 @@ class TestManager {
function create_test_course($course_code = 'COURSETEST') { function create_test_course($course_code = 'COURSETEST') {
/* /* Table definitions */
-----------------------------------------------------------
Table definitions
-----------------------------------------------------------
*/
$table_course = Database::get_main_table(TABLE_MAIN_COURSE); $table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$course_table = Database::get_main_table(TABLE_MAIN_COURSE); $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$course_cat_table = Database::get_main_table(TABLE_MAIN_CATEGORY); $course_cat_table = Database::get_main_table(TABLE_MAIN_CATEGORY);
@ -128,24 +111,16 @@ $course_cat_table = Database::get_main_table(TABLE_MAIN_CATEGORY);
global $_configuration, $_user, $_course, $cidReq; global $_configuration, $_user, $_course, $cidReq;
$cidReq = $course_code; $cidReq = $course_code;
/* /* Check if the course exists */
-----------------------------------------------------------
Check if the course exists
-----------------------------------------------------------
*/
$sql = "SELECT code FROM $table_course WHERE code = '$cidReq' "; $sql = "SELECT code FROM $table_course WHERE code = '$cidReq' ";
$rs = Database::query($sql, __FILE__, __LINE__); $rs = Database::query($sql, __FILE__, __LINE__);
$row = Database::fetch_row($rs); $row = Database::fetch_row($rs);
/* /* Create the course in the database */
-----------------------------------------------------------
Create the course in the database
-----------------------------------------------------------
*/
if (empty($row[0])) { if (empty($row[0])) {
// create a course // Create a course
$course_datos = array( $course_datos = array(
'wanted_code'=> $cidReq, 'wanted_code'=> $cidReq,
'title'=>$cidReq, 'title'=>$cidReq,
@ -171,11 +146,7 @@ $sql = "SELECT course.*, course_category.code faCode, course_category.name faNa
$result = Database::query($sql,__FILE__,__LINE__); $result = Database::query($sql,__FILE__,__LINE__);
/* /* Create the session */
-----------------------------------------------------------
Create the session
-----------------------------------------------------------
*/
if (Database::num_rows($result)>0) { if (Database::num_rows($result)>0) {
$cData = Database::fetch_array($result); $cData = Database::fetch_array($result);
@ -202,21 +173,13 @@ if (Database::num_rows($result)>0) {
api_session_register('_course'); api_session_register('_course');
} }
/* /* Load the session */
-----------------------------------------------------------
Load the session
-----------------------------------------------------------
*/
$_SESSION['_user']['user_id'] = 1; $_SESSION['_user']['user_id'] = 1;
$_SESSION['is_courseAdmin'] = 1; $_SESSION['is_courseAdmin'] = 1;
$_SESSION['show'] = showall; $_SESSION['show'] = showall;
/* /* Load the user */
-----------------------------------------------------------
Load the user
-----------------------------------------------------------
*/
$_user['user_id'] = $_SESSION['_user']['user_id']; $_user['user_id'] = $_SESSION['_user']['user_id'];
} }
@ -230,12 +193,6 @@ $_user['user_id'] = $_SESSION['_user']['user_id'];
function delete_test_course($course_code) { function delete_test_course($course_code) {
$code = $course_code; $code = $course_code;
/*
-----------------------------------------------------------
Delete the course
-----------------------------------------------------------
*/
$res = CourseManager::delete_course($code); $res = CourseManager::delete_course($code);
$path = api_get_path(SYS_PATH).'archive'; $path = api_get_path(SYS_PATH).'archive';
@ -250,15 +207,9 @@ if ($handle = opendir($path)) {
closedir($handle); closedir($handle);
} }
/* // Check api session destroy
-----------------------------------------------------------
Check api session destroy
-----------------------------------------------------------
*/
if (!headers_sent() && session_id() != "") { if (!headers_sent() && session_id() != "") {
$res=api_session_destroy(); $res=api_session_destroy();
} }
} }
} }

@ -119,16 +119,14 @@ if ($_GET['chatid'] != '') {
if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) || ((api_get_setting('showonline', 'users') == 'true' || api_get_setting('showonline', 'course') == 'true') && $_user['user_id'])) { if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) || ((api_get_setting('showonline', 'users') == 'true' || api_get_setting('showonline', 'course') == 'true') && $_user['user_id'])) {
if(isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) { if(isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
$user_list = Who_is_online_in_this_course($_user['user_id'], api_get_setting('time_limit_whosonline'), $_GET['cidReq']); $user_list = who_is_online_in_this_course($_user['user_id'], api_get_setting('time_limit_whosonline'), $_GET['cidReq']);
} else { } else {
$user_list = WhoIsOnline(api_get_setting('time_limit_whosonline')); $user_list = who_is_online(api_get_setting('time_limit_whosonline'));
} }
$total = count($user_list); $total = count($user_list);
if (!isset($_GET['id'])) { if (!isset($_GET['id'])) {
Display::display_header(get_lang('UsersOnLineList')); Display::display_header(get_lang('UsersOnLineList'));
if (api_get_setting('allow_social_tool') == 'true') { if (api_get_setting('allow_social_tool') == 'true') {
if (!api_is_anonymous()) { if (!api_is_anonymous()) {
echo '<div id="social-content-left">'; echo '<div id="social-content-left">';
@ -139,7 +137,7 @@ if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) ||
if ($_GET['id'] == '') { if ($_GET['id'] == '') {
echo '<p><a class="refresh" href="javascript:window.location.reload()">'.get_lang('Refresh').'</a></p>'; //echo '<p><a class="refresh" href="javascript:window.location.reload()">'.get_lang('Refresh').'</a></p>';
} /*else { } /*else {
if (0) { if (0) {
// if ($_user['user_id'] && $_GET["id"] != $_user['user_id']) { // if ($_user['user_id'] && $_GET["id"] != $_user['user_id']) {

Loading…
Cancel
Save