skala
cvargas 16 years ago
commit 4b666a2805
  1. 9
      tests/all.test2.php
  2. 77
      tests/main/admin/calendar.lib.test.php
  3. 4
      tests/main/admin/statistics/statistics.lib.test.php
  4. 43
      tests/main/chat/chat_functions.lib.test.php
  5. 43
      tests/main/exercice/hotpotatoes.lib.test.php

@ -29,28 +29,27 @@ class AllTests2 extends TestSuite {
//$this->addTestFile(dirname(__FILE__).'/main/conference/get_translation.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/conference/get_translation.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/exercice/hotpotatoes.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/exercice/hotpotatoes.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/newscorm/scorm.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/newscorm/scorm.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/survey/survey.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/survey/survey.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/user/userInfoLib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/user/userInfoLib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/webservices/user_import/import.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/webservices/user_import/import.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/work/work.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/work/work.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/install/install_upgrade.lib.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/install/install_upgrade.lib.test.php');
/*
$this->addTestFile(dirname(__FILE__).'/main/admin/calendar.lib.test.php'); $this->addTestFile(dirname(__FILE__).'/main/admin/calendar.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/admin/statistics/statistics.lib.test.php'); $this->addTestFile(dirname(__FILE__).'/main/admin/statistics/statistics.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/auth/lost_password.lib.test.php'); $this->addTestFile(dirname(__FILE__).'/main/auth/lost_password.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/auth/openid/xrds.lib.test.php'); $this->addTestFile(dirname(__FILE__).'/main/auth/openid/xrds.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/auth/openid/openid.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/chat/chat_functions.lib.test.php'); $this->addTestFile(dirname(__FILE__).'/main/chat/chat_functions.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/conference/get_translation.lib.test.php'); $this->addTestFile(dirname(__FILE__).'/main/conference/get_translation.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/exercice/hotpotatoes.lib.test.php'); $this->addTestFile(dirname(__FILE__).'/main/exercice/hotpotatoes.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/newscorm/scorm.lib.test.php'); $this->addTestFile(dirname(__FILE__).'/main/newscorm/scorm.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/install/install_upgrade.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/survey/survey.lib.test.php'); $this->addTestFile(dirname(__FILE__).'/main/survey/survey.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/user/userInfoLib.test.php'); $this->addTestFile(dirname(__FILE__).'/main/user/userInfoLib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/webservices/user_import/import.lib.test.php'); $this->addTestFile(dirname(__FILE__).'/main/webservices/user_import/import.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/work/work.lib.test.php'); $this->addTestFile(dirname(__FILE__).'/main/work/work.lib.test.php');
*/ $this->addTestFile(dirname(__FILE__).'/main/install/install_upgrade.lib.test.php');
} }
} }
$test = &new AllTests2(); $test = &new AllTests2();

@ -24,9 +24,9 @@ class TestCalendar extends UnitTestCase {
public function testDisplayMinimonthcalendar(){ public function testDisplayMinimonthcalendar(){
ob_start(); ob_start();
global $DaysShort; global $DaysShort;
$agendaitems=array('abc','cde'); $agendaitems=array('test','test2');
$month=11; $month=01;
$year=2008; $year=2010;
$monthName=''; $monthName='';
$res = display_minimonthcalendar($agendaitems, $month, $year, $monthName); $res = display_minimonthcalendar($agendaitems, $month, $year, $monthName);
ob_end_clean(); ob_end_clean();
@ -207,8 +207,8 @@ class TestCalendar extends UnitTestCase {
public function testGetAgendaitems(){ public function testGetAgendaitems(){
global $_user; global $_user;
global $_configuration; global $_configuration;
$month='12'; $month=01;
$year='2009'; $year=2010;
$res = get_agendaitems($month, $year); $res = get_agendaitems($month, $year);
if(is_array($res)) { if(is_array($res)) {
$this->assertTrue(is_array($res)); $this->assertTrue(is_array($res));
@ -262,8 +262,8 @@ class TestCalendar extends UnitTestCase {
public function testGetDayAgendaitems() { public function testGetDayAgendaitems() {
$courses_dbs=array(); $courses_dbs=array();
$month='12'; $month=01;
$year='2009'; $year=2010;
$day='1'; $day='1';
$res = get_day_agendaitems($courses_dbs, $month, $year, $day); $res = get_day_agendaitems($courses_dbs, $month, $year, $day);
$this->assertTrue(is_array($res)); $this->assertTrue(is_array($res));
@ -272,69 +272,45 @@ class TestCalendar extends UnitTestCase {
public function testGetWeekAgendaitems() { public function testGetWeekAgendaitems() {
$courses_dbs=array(); $courses_dbs=array();
$year='2009'; $month=01;
$month='12'; $year=2010;
$res = get_week_agendaitems($courses_dbs, $month, $year); $res = get_week_agendaitems($courses_dbs, $month, $year);
$this->assertTrue(is_array($res)); $this->assertTrue(is_array($res));
} }
public function testGetRepeatedEventsDayView(){ public function testGetRepeatedEventsDayView(){
$y=0;
global $_configuration; $m=0;
$d=0;
require_once api_get_path(SYS_PATH).'tests/main/inc/lib/add_course.lib.inc.test.php'; $start = mktime(0,0,0,$m,$d,$y);
$end = mktime(23,59,59,$m,$d,$y);
// create a course $params = array();
$course_code = 'COURSEX';
$course_datos = array(
'wanted_code'=> 'COD21',
'title'=>'metodologia de calculo diferencial',
'tutor_name'=>'R. J. Wolfagan',
'category_code'=>'2121',
'course_language'=>'english',
'course_admin_id'=>'1211',
'db_prefix'=> $_configuration['db_prefix'].'COD21',
'db_prefix'=> $_configuration['db_prefix'].'COD21',
'firstExpirationDelay'=>'112'
);
$res = create_course($course_datos['wanted_code'], $course_datos['title'],
$course_datos['tutor_name'], $course_datos['category_code'],
$course_datos['course_language'],$course_datos['course_admin_id'],
$course_datos['db_prefix'], $course_datos['firstExpirationDelay']);
if ($res) {
$start = 0;
$end = 0;
$params='';
$course_code = 'COD21';
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
$resul = get_repeated_events_day_view($course_info,$start,$end,$params); $resul = get_repeated_events_day_view($course_info,$start,$end,$params);
$this->assertTrue(is_array($resul)); $this->assertTrue(is_array($resul));
}
} }
public function testGetRepeatedEventsWeekView(){ public function testGetRepeatedEventsWeekView(){
$course_info = 'COD21'; $course_info = 'COURSEX';
$resul = get_repeated_events_week_view($course_info, 0, 0, ''); $resul = get_repeated_events_week_view($course_info, 0, 0, '');
$this->assertTrue(is_array($resul)); $this->assertTrue(is_array($resul));
} }
public function testGetRepeatedEventsMonthView(){ public function testGetRepeatedEventsMonthView(){
$course_code='COD21'; $course_code='COURSEX';
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
$resul= get_repeated_events_month_view($course_info,0,0,''); $resul= get_repeated_events_month_view($course_info,0,0,'');
$this->assertTrue(is_array($resul)); $this->assertTrue(is_array($resul));
//var_dump($resul); //var_dump($resul);
} }
public function testGetRepeatedEventsListView(){ public function testGetRepeatedEventsListView(){
$course_code='COD21'; $course_code='COURSEX';
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
$resul = get_repeated_events_list_view($course_info,0,0,''); $resul = get_repeated_events_list_view($course_info,0,0,'');
$this->assertTrue(is_array($resul)); $this->assertTrue(is_array($resul));
//var_dump($resul); //var_dump($resul);
} }
public function testIsRepeatedEvent() { public function testIsRepeatedEvent() {
@ -378,7 +354,7 @@ class TestCalendar extends UnitTestCase {
*/ */
public function testAgendaAddItem(){ public function testAgendaAddItem(){
global $_course; global $_course;
$course_code='COD21'; $course_code='COURSEX';
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
$title='test'; $title='test';
$content='test function'; $content='test function';
@ -400,8 +376,8 @@ class TestCalendar extends UnitTestCase {
*/ */
public function testGetCalendarItems(){ public function testGetCalendarItems(){
global $_course; global $_course;
$month='12'; $month=01;
$year='2009'; $year=2010;
$res = get_calendar_items($month, $year); $res = get_calendar_items($month, $year);
$this->assertTrue(is_array($res)); $this->assertTrue(is_array($res));
//var_dump($res); //var_dump($res);
@ -427,13 +403,10 @@ class TestCalendar extends UnitTestCase {
} }
public function testDeleteAgendaItem(){ public function testDeleteAgendaItem(){
global $_course; $course_code='COURSEX';
$course_code='COD21';
$id=1; $id=1;
$res = delete_agenda_item($id); $res = delete_agenda_item($id);
$res = $this->tcourse->delete_course($course_code); $this->assertTrue(is_bool($res));
$this->assertTrue(is_null($res));
//var_dump($res);
} }
} }
?> ?>

@ -75,7 +75,7 @@ class TestStatistics extends UnitTestCase{
} }
public function testRescale(){ public function testRescale(){
$data=array('aas','aaa'.'aab'); $data=array('test','test2','test3');
$max = 500; $max = 500;
$res = Statistics::rescale($data, $max); $res = Statistics::rescale($data, $max);
$this->assertTrue($res); $this->assertTrue($res);
@ -86,7 +86,7 @@ class TestStatistics extends UnitTestCase{
public function testPrintStats(){ public function testPrintStats(){
ob_start(); ob_start();
$title='testing'; $title='testing';
$stats=array('aa','bb','cc'); $stats=array('test','test2','test3');
$show_total = true; $show_total = true;
$is_file_size = false; $is_file_size = false;
$res = Statistics::print_stats($title, $stats, $show_total = true, $is_file_size = false); $res = Statistics::print_stats($title, $stats, $show_total = true, $is_file_size = false);

@ -16,32 +16,7 @@ class TestChatFunctions extends UnitTestCase {
function testuser_connected_in_chat () { function testuser_connected_in_chat () {
global $_configuration; $course_code = 'COURSEX';
require_once api_get_path(SYS_PATH).'tests/main/inc/lib/add_course.lib.inc.test.php';
// create a course
$course_datos = array(
'wanted_code'=> 'COD21',
'title'=>'metodologia de calculo diferencial',
'tutor_name'=>'R. J. Wolfagan',
'category_code'=>'2121',
'course_language'=>'english',
'course_admin_id'=>'1211',
'db_prefix'=> $_configuration['db_prefix'].'COD21',
'db_prefix'=> $_configuration['db_prefix'].'COD21',
'firstExpirationDelay'=>'112'
);
$res = create_course($course_datos['wanted_code'], $course_datos['title'],
$course_datos['tutor_name'], $course_datos['category_code'],
$course_datos['course_language'],$course_datos['course_admin_id'],
$course_datos['db_prefix'], $course_datos['firstExpirationDelay']);
if ($res) {
$course_code = 'COD21';
$course_info = api_get_course_info($course_code);
}
$user_id=1; $user_id=1;
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
$database_name = $course_info['dbName']; $database_name = $course_info['dbName'];
@ -51,7 +26,7 @@ class TestChatFunctions extends UnitTestCase {
function testUsersListInChat () { function testUsersListInChat () {
$course_code = 'COD21'; $course_code = 'COURSEX';
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
$database_name = $course_info['dbName']; $database_name = $course_info['dbName'];
$res = users_list_in_chat($database_name); $res = users_list_in_chat($database_name);
@ -76,7 +51,7 @@ class TestChatFunctions extends UnitTestCase {
function testExitOfChat () { function testExitOfChat () {
$course_code = 'COD21'; $course_code = 'COURSEX';
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
$database_name = $course_info['dbName']; $database_name = $course_info['dbName'];
$this->CreateChatConnection($database_name); $this->CreateChatConnection($database_name);
@ -89,21 +64,13 @@ class TestChatFunctions extends UnitTestCase {
function testDisconnectUserOfChat() { function testDisconnectUserOfChat() {
$_SESSION['is_courseAdmin'] = 1; $_SESSION['is_courseAdmin'] = 1;
$course_code = 'COD21'; $course_code = 'COURSEX';
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
$database_name = $course_info['dbName']; $database_name = $course_info['dbName'];
$this->CreateChatConnection($database_name); $this->CreateChatConnection($database_name);
$res = disconnect_user_of_chat($database_name); $res = disconnect_user_of_chat($database_name);
$this->assertTrue(is_null($res)); $this->assertTrue(is_null($res));
}
$resu = $this->tcourse->delete_course($course_code);
}
} }
?> ?>

@ -21,7 +21,7 @@ class TestHotpotatoes extends UnitTestCase {
} }
function testFillFolderName() { function testFillFolderName() {
$name='12doceletras'; $name='testnameofthefolder';
$nsize=12; $nsize=12;
$res=FillFolderName($name,$nsize); $res=FillFolderName($name,$nsize);
$this->assertTrue(is_string($res)); $this->assertTrue(is_string($res));
@ -29,7 +29,7 @@ class TestHotpotatoes extends UnitTestCase {
} }
function testGenerateHiddenList() { function testGenerateHiddenList() {
$imgparams=array('abc'); $imgparams=array('test');
$res=GenerateHiddenList($imgparams); $res=GenerateHiddenList($imgparams);
$this->assertTrue(is_string($res)); $this->assertTrue(is_string($res));
//var_dump($res); //var_dump($res);
@ -45,40 +45,14 @@ class TestHotpotatoes extends UnitTestCase {
} }
function testGetComment() { function testGetComment() {
global $dbTable;
global $_configuration;
require_once api_get_path(SYS_PATH).'tests/main/inc/lib/add_course.lib.inc.test.php';
// create a course
$course_datos = array( $course_code = 'COURSEX';
'wanted_code'=> 'COD21',
'title'=>'metodologia de calculo diferencial',
'tutor_name'=>'R. J. Wolfagan',
'category_code'=>'2121',
'course_language'=>'english',
'course_admin_id'=>'1211',
'db_prefix'=> $_configuration['db_prefix'].'COD21',
'db_prefix'=> $_configuration['db_prefix'].'COD21',
'firstExpirationDelay'=>'112'
);
$res = create_course($course_datos['wanted_code'], $course_datos['title'],
$course_datos['tutor_name'], $course_datos['category_code'],
$course_datos['course_language'],$course_datos['course_admin_id'],
$course_datos['db_prefix'], $course_datos['firstExpirationDelay']);
if ($res) {
$start = 0;
$end = 0;
$params='';
$course_code = 'COD21';
$path = 'exercice_submit.php'; $path = 'exercice_submit.php';
$query ="select comment from $dbTable where path='$path'"; $query ="select comment from $dbTable where path='$path'";
$res=GetComment($path,$course_code); $res=GetComment($path,$course_code);
$this->assertTrue(is_string($res)); $this->assertTrue(is_string($res));
//var_dump($res); //var_dump($res);
}
} }
/* Deprecated /* Deprecated
@ -121,7 +95,7 @@ class TestHotpotatoes extends UnitTestCase {
} }
function testGetQuizName() { function testGetQuizName() {
$course_code = 'COD21'; $course_code = 'COURSEX';
$fname='exercice_submit.php'; $fname='exercice_submit.php';
$fpath='main/exercice/exercice_submit.php'; $fpath='main/exercice/exercice_submit.php';
$res=GetQuizName($fname,$fpath); $res=GetQuizName($fname,$fpath);
@ -147,7 +121,7 @@ class TestHotpotatoes extends UnitTestCase {
function testhotpotatoes_initWithRemoveFolder() { function testhotpotatoes_initWithRemoveFolder() {
$base = '/tmp/'; $base = '/tmp/';
$baseWorkDir=$base.'test123/'; $baseWorkDir=$base.'test/';
$res=hotpotatoes_init($baseWorkDir); $res=hotpotatoes_init($baseWorkDir);
$this->assertTrue($res); $this->assertTrue($res);
rmdir($baseWorkDir); rmdir($baseWorkDir);
@ -198,11 +172,10 @@ class TestHotpotatoes extends UnitTestCase {
} }
function testWriteFileCont() { function testWriteFileCont() {
$course_code = 'COD21'; $course_code = 'COURSEX';
$full_file_path='/main/exercice/'; $full_file_path='/main/exercice/';
$content='test test test'; $content='test test test';
$res=WriteFileCont($full_file_path,$content); $res=WriteFileCont($full_file_path,$content);
$resu = CourseManager::delete_course($course_code);
$this->assertTrue(is_bool($res)); $this->assertTrue(is_bool($res));
//var_dump($res); //var_dump($res);
} }

Loading…
Cancel
Save