cvargas 15 years ago
parent
commit
4b666a2805

+ 4 - 5
tests/all.test2.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/exercice/hotpotatoes.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/webservices/user_import/import.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/admin/calendar.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/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/conference/get_translation.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/install/install_upgrade.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/webservices/user_import/import.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();

+ 25 - 52
tests/main/admin/calendar.lib.test.php

@@ -24,9 +24,9 @@ class TestCalendar extends UnitTestCase {
  	public function testDisplayMinimonthcalendar(){
  		ob_start();
  		global $DaysShort;
- 		$agendaitems=array('abc','cde');
- 		$month=11;
- 		$year=2008;
+ 		$agendaitems=array('test','test2');
+ 		$month=01;
+ 		$year=2010;
  		$monthName='';
  		$res = display_minimonthcalendar($agendaitems, $month, $year, $monthName);
  		ob_end_clean();
@@ -207,8 +207,8 @@ class TestCalendar extends UnitTestCase {
  	public function testGetAgendaitems(){
  		global $_user;
 		global $_configuration;
- 		$month='12';
- 		$year='2009';
+ 		$month=01;
+ 		$year=2010;
  		$res = get_agendaitems($month, $year);
  		if(is_array($res)) {
  			$this->assertTrue(is_array($res));
@@ -262,8 +262,8 @@ class TestCalendar extends UnitTestCase {
 
  	public function testGetDayAgendaitems() {
  		$courses_dbs=array();
- 		$month='12';
- 		$year='2009';
+ 		$month=01;
+ 		$year=2010;
  		$day='1';
  		$res = get_day_agendaitems($courses_dbs, $month, $year, $day);
  		$this->assertTrue(is_array($res));
@@ -272,69 +272,45 @@ class TestCalendar extends UnitTestCase {
 
  	public function testGetWeekAgendaitems() {
  		$courses_dbs=array();
- 		$year='2009';
- 		$month='12';
+ 		$month=01;
+ 		$year=2010;
 		$res = get_week_agendaitems($courses_dbs, $month, $year);
  		$this->assertTrue(is_array($res));
  	}
 
- 	public function testGetRepeatedEventsDayView(){
- 		
- 		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(
-				'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';			
+ 	public function testGetRepeatedEventsDayView(){	
+ 			$y=0;
+			$m=0;
+			$d=0;
+ 			$start = mktime(0,0,0,$m,$d,$y);
+ 			$end = mktime(23,59,59,$m,$d,$y);
+ 			$params = array();
+			$course_code = 'COURSEX';			
 			$course_info = api_get_course_info($course_code);			
 			$resul = get_repeated_events_day_view($course_info,$start,$end,$params);		
 	 		$this->assertTrue(is_array($resul));
-	 	
-		}
  	}
 
  	public function testGetRepeatedEventsWeekView(){
- 		$course_info = 'COD21';
+ 		$course_info = 'COURSEX';
  		$resul = get_repeated_events_week_view($course_info, 0, 0, '');
  		$this->assertTrue(is_array($resul));
  	}
 
  	public function testGetRepeatedEventsMonthView(){
- 		$course_code='COD21';
+ 		$course_code='COURSEX';
  		$course_info = api_get_course_info($course_code);
  		$resul= get_repeated_events_month_view($course_info,0,0,'');
 		$this->assertTrue(is_array($resul));
 		//var_dump($resul);
-
 	}
 
 	public function testGetRepeatedEventsListView(){
-		$course_code='COD21';
+		$course_code='COURSEX';
  		$course_info = api_get_course_info($course_code);
 		$resul = get_repeated_events_list_view($course_info,0,0,'');
 		$this->assertTrue(is_array($resul));
 		//var_dump($resul);
-		
 	}
 
  	public function testIsRepeatedEvent() {
@@ -378,7 +354,7 @@ class TestCalendar extends UnitTestCase {
  */
  	public function testAgendaAddItem(){
  		global $_course;
- 		$course_code='COD21';
+ 		$course_code='COURSEX';
  		$course_info = api_get_course_info($course_code);
  		$title='test';
  		$content='test function';
@@ -400,8 +376,8 @@ class TestCalendar extends UnitTestCase {
  */
  	public function testGetCalendarItems(){
  		global $_course;
- 		$month='12';
- 		$year='2009';
+ 		$month=01;
+ 		$year=2010;
 		$res = get_calendar_items($month, $year);
  		$this->assertTrue(is_array($res));
  		//var_dump($res);
@@ -427,13 +403,10 @@ class TestCalendar extends UnitTestCase {
  	}
 
 public function testDeleteAgendaItem(){
- 		global $_course;
- 	 	$course_code='COD21';
+ 	 	$course_code='COURSEX';
 		$id=1;
 		$res = delete_agenda_item($id);
-		$res = $this->tcourse->delete_course($course_code);	
-		$this->assertTrue(is_null($res));
- 		//var_dump($res);
+		$this->assertTrue(is_bool($res));
  	}
 }
 ?>

+ 2 - 2
tests/main/admin/statistics/statistics.lib.test.php

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

+ 5 - 38
tests/main/chat/chat_functions.lib.test.php

@@ -16,32 +16,7 @@ class TestChatFunctions extends UnitTestCase {
 
 
 	function testuser_connected_in_chat () {
-		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(
-				'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);
-		
-		}
+		$course_code = 'COURSEX';
 		$user_id=1;			
 		$course_info = api_get_course_info($course_code);
 		$database_name = $course_info['dbName'];
@@ -51,7 +26,7 @@ class TestChatFunctions extends UnitTestCase {
 	
 
 	function testUsersListInChat () {
-		$course_code = 'COD21';
+		$course_code = 'COURSEX';
 		$course_info = api_get_course_info($course_code);
 		$database_name = $course_info['dbName'];
 		$res = users_list_in_chat($database_name);
@@ -76,7 +51,7 @@ class TestChatFunctions extends UnitTestCase {
 	
 
 	function testExitOfChat () {
-		$course_code = 'COD21';
+		$course_code = 'COURSEX';
 		$course_info = api_get_course_info($course_code);
 		$database_name = $course_info['dbName'];
 		$this->CreateChatConnection($database_name);
@@ -89,21 +64,13 @@ class TestChatFunctions extends UnitTestCase {
 	
 	
 		function testDisconnectUserOfChat() {
-			
 		$_SESSION['is_courseAdmin'] = 1;
-		$course_code = 'COD21';
-		
+		$course_code = 'COURSEX';
 		$course_info = api_get_course_info($course_code);
 		$database_name = $course_info['dbName'];
-		
 		$this->CreateChatConnection($database_name);		
 		$res = disconnect_user_of_chat($database_name);
 		$this->assertTrue(is_null($res));
-		
-		$resu = $this->tcourse->delete_course($course_code);
-
-	}	
-
-	
+	}		
 }
 ?>

+ 8 - 35
tests/main/exercice/hotpotatoes.lib.test.php

@@ -21,7 +21,7 @@ class TestHotpotatoes extends UnitTestCase {
 	}
 
 	function testFillFolderName() {
-		$name='12doceletras';
+		$name='testnameofthefolder';
 		$nsize=12;
 		$res=FillFolderName($name,$nsize);
 		$this->assertTrue(is_string($res));
@@ -29,7 +29,7 @@ class TestHotpotatoes extends UnitTestCase {
 	}
 
 	function testGenerateHiddenList() {
-		$imgparams=array('abc');
+		$imgparams=array('test');
 		$res=GenerateHiddenList($imgparams);
 		$this->assertTrue(is_string($res));
 		//var_dump($res);
@@ -45,40 +45,14 @@ class TestHotpotatoes extends UnitTestCase {
 	}
 
 	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(
-				'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_code = 'COURSEX';			
 			$path = 'exercice_submit.php';
 			$query ="select comment from $dbTable where path='$path'";
 			$res=GetComment($path,$course_code);
-			
 			$this->assertTrue(is_string($res));
 			//var_dump($res);
-				}
+			
 		}
 
 	/*  Deprecated
@@ -121,7 +95,7 @@ class TestHotpotatoes extends UnitTestCase {
 	}
 
 	function testGetQuizName() {
-		$course_code = 'COD21';	
+		$course_code = 'COURSEX';	
 		$fname='exercice_submit.php';
 		$fpath='main/exercice/exercice_submit.php';
 		$res=GetQuizName($fname,$fpath);
@@ -147,7 +121,7 @@ class TestHotpotatoes extends UnitTestCase {
 
 	function testhotpotatoes_initWithRemoveFolder() {
 		$base = '/tmp/';
-		$baseWorkDir=$base.'test123/';
+		$baseWorkDir=$base.'test/';
 		$res=hotpotatoes_init($baseWorkDir);
 		$this->assertTrue($res);
 		rmdir($baseWorkDir);
@@ -198,11 +172,10 @@ class TestHotpotatoes extends UnitTestCase {
 	}
 
 	function testWriteFileCont() {
-		$course_code = 'COD21';	
+		$course_code = 'COURSEX';	
 		$full_file_path='/main/exercice/';
 		$content='test test test';
-		$res=WriteFileCont($full_file_path,$content);
-		$resu = CourseManager::delete_course($course_code);	
+		$res=WriteFileCont($full_file_path,$content);	
 		$this->assertTrue(is_bool($res));
 		//var_dump($res);
 	}