parent
							
								
									7ac9b687fb
								
							
						
					
					
						commit
						8ec98d0b24
					
				@ -1,174 +1,188 @@ | 
				
			|||||||
<?php | 
					<?php | 
				
			||||||
require_once(api_get_path(LIBRARY_PATH).'add_course.lib.inc.php'); | 
					require_once(api_get_path(LIBRARY_PATH).'add_course.lib.inc.php'); | 
				
			||||||
 | 
					require_once(api_get_path(LIBRARY_PATH).'debug.lib.inc.php'); | 
				
			||||||
 | 
					require_once(api_get_path(LIBRARY_PATH).'course.lib.php'); | 
				
			||||||
 | 
					
 | 
				
			||||||
class TestAddCourse extends UnitTestCase { | 
					class TestAddCourse extends UnitTestCase { | 
				
			||||||
 | 
					
 | 
				
			||||||
	function TestAddCourse() { | 
						function TestAddCourse() { | 
				
			||||||
        $this->UnitTestCase('Courses creation tests'); | 
					        $this->UnitTestCase('Courses creation tests'); | 
				
			||||||
    } | 
					    } | 
				
			||||||
 | 
						 | 
				
			||||||
    function testRegisterCourse() { | 
					 | 
				
			||||||
	    global $_configuration; | 
					 | 
				
			||||||
        //($courseSysCode, $courseScreenCode, $courseRepository, $courseDbName, | 
					 | 
				
			||||||
		//$titular, $category, $title, $course_language, $uidCreator, $expiration_date = "", $teachers=array()) | 
					 | 
				
			||||||
	    $course = array( | 
					 | 
				
			||||||
		    'courseSysCode'=> 'COD12', | 
					 | 
				
			||||||
		    'courseScreenCode' =>'221', | 
					 | 
				
			||||||
		    'courseRepository' =>'21', | 
					 | 
				
			||||||
		    'courseDbName' => $_configuration['db_prefix'].'ARITM', | 
					 | 
				
			||||||
		    'titular' =>'R. Wofgar', | 
					 | 
				
			||||||
		    'category' =>'Math', | 
					 | 
				
			||||||
		    'title' =>'metodologia de calculo diferencial', | 
					 | 
				
			||||||
		    'course_language' =>'English', | 
					 | 
				
			||||||
		    'uidCreator'=> '212', | 
					 | 
				
			||||||
			 	); | 
					 | 
				
			||||||
	 	$res = register_course($course['courseSysCode'],$course['courseScreenCode'], | 
					 | 
				
			||||||
	 						   $course['courseRepository'],$course['courseDbName'],$course['titular'], | 
					 | 
				
			||||||
	 						   $course['category'],$course['title'],$course['course_language'], | 
					 | 
				
			||||||
	 						   $course['uidCreator'],null,null); | 
					 | 
				
			||||||
	 	$this->assertPattern('/\d/',$res); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	} | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function TestCreateCourse(){ | 
					    function TestCreateCourse(){ | 
				
			||||||
		global $_configuration; | 
							global $_configuration; | 
				
			||||||
		//$wanted_code, $title, $tutor_name, $category_code, | 
					 | 
				
			||||||
		//$course_language, $course_admin_id, $db_prefix, | 
					 | 
				
			||||||
		//$firstExpirationDelay | 
					 | 
				
			||||||
		$course_datos = array( | 
							$course_datos = array( | 
				
			||||||
				'wanted_code'=> 'COD12', | 
									'wanted_code'=> 'COD16', | 
				
			||||||
				'title'=>'metodologia de calculo diferencial', | 
									'title'=>'prueba01', | 
				
			||||||
				'tutor_name'=>'R. J. Wolfagan', | 
									'tutor_name'=>'R. J. Wolfagan', | 
				
			||||||
				'category_code'=>'2121', | 
									'category_code'=>'2121', | 
				
			||||||
				'course_language'=>'english', | 
									'course_language'=>'english', | 
				
			||||||
				'course_admin_id'=>'1211', | 
									'course_admin_id'=>'1211', | 
				
			||||||
				'db_prefix'=> $_configuration['db_prefix'].'COD12', | 
									'db_prefix'=> $_configuration['db_prefix'], | 
				
			||||||
				'firstExpirationDelay'=>'112' | 
									'firstExpirationDelay'=>'112' | 
				
			||||||
				); | 
									); | 
				
			||||||
		//$keys = define_course_keys($wanted_code, "", $db_prefix); | 
					 | 
				
			||||||
		$res = create_course($course_datos['wanted_code'], $course_datos['title'], | 
							$res = create_course($course_datos['wanted_code'], $course_datos['title'], | 
				
			||||||
							 $course_datos['tutor_name'], $course_datos['category_code'], | 
												 $course_datos['tutor_name'], $course_datos['category_code'], | 
				
			||||||
							 $course_datos['course_language'],$course_datos['course_admin_id'], | 
												 $course_datos['course_language'],$course_datos['course_admin_id'], | 
				
			||||||
							 $course_datos['db_prefix'], $course_datos['firstExpirationDelay']); | 
												 $course_datos['db_prefix'], $course_datos['firstExpirationDelay']); | 
				
			||||||
 | 
							$this->assertTrue(is_bool($res)); | 
				
			||||||
		$this->assertFalse($res===0); | 
							 | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					    | 
				
			||||||
 | 
					    function testRegisterCourse() { | 
				
			||||||
 | 
						    global $_configuration; | 
				
			||||||
 | 
					         $course = array( | 
				
			||||||
 | 
							    'courseSysCode'=> 'COD16', | 
				
			||||||
 | 
							    'courseScreenCode' =>'COD16', | 
				
			||||||
 | 
							    'courseRepository' =>'C16', | 
				
			||||||
 | 
							    'courseDbName' => $_configuration['db_prefix'].'ARITM', | 
				
			||||||
 | 
							    'titular' =>'R. Wofgar', | 
				
			||||||
 | 
							    'category' =>'Math', | 
				
			||||||
 | 
							    'title' =>'metodologia de calculo diferencial', | 
				
			||||||
 | 
							    'course_language' =>'English', | 
				
			||||||
 | 
							    'uidCreator'=> '212', | 
				
			||||||
 | 
								); | 
				
			||||||
 | 
						    $res = register_course($course['courseSysCode'],$course['courseScreenCode'], | 
				
			||||||
 | 
						 					   $course['courseRepository'],$course['courseDbName'], | 
				
			||||||
 | 
						 					   $course['titular'],$course['category'],$course['title'], | 
				
			||||||
 | 
						 					   $course['course_language'],$course['uidCreator'], | 
				
			||||||
 | 
						 					   null,null | 
				
			||||||
 | 
						 					   ); | 
				
			||||||
 | 
						    | 
				
			||||||
 | 
						    $this->assertTrue($res === 0); | 
				
			||||||
 | 
						    $res = CourseManager::delete_course($course['courseSysCode']); | 
				
			||||||
 | 
					    	 | 
				
			||||||
    } | 
					    } | 
				
			||||||
 | 
					      | 
				
			||||||
    function TestGenerateCourseCode(){ | 
					    function TestGenerateCourseCode(){ | 
				
			||||||
    	global $charset; | 
					    	global $charset; | 
				
			||||||
    	$course_title = 'matemáticas'; | 
					    	$course_title = 'matemáticas'; | 
				
			||||||
    	$res = generate_course_code($course_title); | 
					    	$res = generate_course_code($course_title); | 
				
			||||||
    	$this->assertTrue($res); | 
					    	$this->assertTrue($res); | 
				
			||||||
 | 
					 | 
				
			||||||
	} | 
						} | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	function TestDefineCourseKeys(){ | 
						function TestDefineCourseKeys(){ | 
				
			||||||
		//$wantedCode, $prefix4all = "", $prefix4baseName = "", | 
					 | 
				
			||||||
		//$prefix4path = "", $addUniquePrefix = false, $useCodeInDepedentKeys = true | 
					 | 
				
			||||||
		global $prefixAntiNumber, $_configuration; | 
							global $prefixAntiNumber, $_configuration; | 
				
			||||||
		$wantedCode = generate_course_code($wantedCode); | 
							$wantedCode = generate_course_code($wantedCode); | 
				
			||||||
		$res = define_course_keys(generate_course_code($wantedCode), null, null, null,null, null); | 
							$res = define_course_keys(generate_course_code($wantedCode), null, null, null,null, null); | 
				
			||||||
		$this->assertTrue($res); | 
							$this->assertTrue($res); | 
				
			||||||
 | 
					 | 
				
			||||||
	} | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
	function TestPrepareCourseRepository(){ | 
						public function TestDeleteCourse(){				 | 
				
			||||||
		$courseRepository = ''; | 
							$code = 'COD16';				 | 
				
			||||||
		$courseId = ''; | 
							$res = CourseManager::delete_course($code);			 | 
				
			||||||
 | 
							$path = api_get_path(SYS_PATH).'archive';		 | 
				
			||||||
 | 
							if ($handle = opendir($path)) { | 
				
			||||||
 | 
								while (false !== ($file = readdir($handle))) {				 | 
				
			||||||
 | 
									if (strpos($file,$code)!==false) {										 | 
				
			||||||
 | 
										if (is_dir($path.'/'.$file)) {						 | 
				
			||||||
 | 
											rmdirr($path.'/'.$file);						 | 
				
			||||||
 | 
										}				 | 
				
			||||||
 | 
									}				 | 
				
			||||||
 | 
								} | 
				
			||||||
 | 
								closedir($handle); | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
					/*  // 26 excepciones | 
				
			||||||
 | 
						function TestPrepareCourseRepository(){  | 
				
			||||||
 | 
							umask(0); | 
				
			||||||
 | 
							$perm = '0777'; | 
				
			||||||
 | 
							$courseRepository = 'C16'; | 
				
			||||||
 | 
							$courseId = 'COD16'; | 
				
			||||||
		$res = prepare_course_repository($courseRepository, $courseId); | 
							$res = prepare_course_repository($courseRepository, $courseId); | 
				
			||||||
 | 
							$res1 = CourseManager::delete_course('C16'); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							 | 
				
			||||||
		$this->assertTrue($res===0); | 
							$this->assertTrue($res===0); | 
				
			||||||
	} | 
						}  | 
				
			||||||
 | 
					// Problemas con este archivo - falta analizar esta función | 
				
			||||||
	/** | 
					 | 
				
			||||||
	 * Function not implemented with test, because the functionality | 
					 | 
				
			||||||
	 * is very complex. | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	/* | 
					 | 
				
			||||||
	function TestUpdateDbCourse(){ | 
						function TestUpdateDbCourse(){ | 
				
			||||||
		global $_configuration; | 
							global $_configuration; | 
				
			||||||
		$dbcourse = array('courseDbName'=> 'curso'); | 
							$dbcourse = array('courseDbName'=> 'COD16'); | 
				
			||||||
		$res = update_Db_course($dbcourse['courseDbName']); | 
							$res = update_Db_course($dbcourse['courseDbName']); | 
				
			||||||
		$this->assertFalse($res===0); | 
							$this->assertTrue($res===0); | 
				
			||||||
 | 
							//var_dump($res); | 
				
			||||||
	}*/ | 
						} | 
				
			||||||
 | 
					*/ | 
				
			||||||
 | 
					
 | 
				
			||||||
	function TestBrowseFolders(){ | 
						function TestBrowseFolders(){ | 
				
			||||||
		$browse = array('path'=>'','file'=>'','media'=>''); | 
							$browse = array('path'=>'','file'=>'','media'=>''); | 
				
			||||||
		$res = browse_folders($browse['path'], $browse['files'],$browse['media']); | 
							$res = browse_folders($browse['path'], $browse['files'],$browse['media']); | 
				
			||||||
		$this->assertFalse($res); | 
							$this->assertFalse($res); | 
				
			||||||
 | 
					 | 
				
			||||||
	} | 
						} | 
				
			||||||
 | 
						/* | 
				
			||||||
 | 
						// 1 excepcion | 
				
			||||||
	function TestSortPictures(){ | 
						function TestSortPictures(){ | 
				
			||||||
		$files ='121212'; | 
							$picture = array('files'=>'science.jpg', 'type'=>'jpg'); | 
				
			||||||
		$type='asasasasa'; | 
							$res = sort_pictures($picture['file'],$picture['type']); | 
				
			||||||
		$res = sort_pictures($files, $type); | 
							$this->assertTrue(is_array($res)); | 
				
			||||||
		$this->assertFalse($res); | 
							//var_dump($res); | 
				
			||||||
 | 
					 | 
				
			||||||
	} | 
						} | 
				
			||||||
 | 
						*/ | 
				
			||||||
 | 
						/* | 
				
			||||||
	function TestFillCourseRepository(){ | 
						function TestFillCourseRepository(){ | 
				
			||||||
		$courseRepository = '1212sder'; | 
							$courseRepository = 'COD16'; | 
				
			||||||
		$res = fill_course_repository($courseRepository); | 
							$res = fill_course_repository($courseRepository); | 
				
			||||||
		$this->assertTrue($res); | 
							$this->assertTrue($res); | 
				
			||||||
 | 
					 | 
				
			||||||
	} | 
						} | 
				
			||||||
 | 
					*/ | 
				
			||||||
	function TestLang2db(){ | 
						function TestLang2db(){ | 
				
			||||||
		$string = 'dsdzxcwqd'; | 
							$string = 'dsdzxcwqd'; | 
				
			||||||
		$res = lang2db($string); | 
							$res = lang2db($string); | 
				
			||||||
		$this->assertTrue($res); | 
							$this->assertTrue($res); | 
				
			||||||
 | 
					 | 
				
			||||||
	} | 
						} | 
				
			||||||
 | 
					
 | 
				
			||||||
	function TestFillDbCourse(){ | 
						function TestFillDbCourse(){ | 
				
			||||||
		global $_configuration, $clarolineRepositoryWeb, $_user; | 
							global $_configuration, $clarolineRepositoryWeb, $_user; | 
				
			||||||
 | 
							$courseDbName = $_configuration['table_prefix'].$courseDbName.$_configuration['db_glue']; | 
				
			||||||
 | 
							$courseRepository = (api_get_path(SYS_COURSE_PATH).$courseRepository . "/dropbox/.htaccess"); | 
				
			||||||
 | 
							$language = 'english'; | 
				
			||||||
 | 
							$language_interface = $language; | 
				
			||||||
 | 
							$default_document_array = array(); | 
				
			||||||
 | 
							$sys_course_path = api_get_path(SYS_COURSE_PATH); | 
				
			||||||
		$courseDbName = $_configuration['db_prefix'].$courseDbName.$_configuration['db_glue']; | 
							$courseDbName = $_configuration['db_prefix'].$courseDbName.$_configuration['db_glue']; | 
				
			||||||
		$courseRepository = 'sdffsdf'; | 
							$courseRepository = 'sdffsdf'; | 
				
			||||||
		$language = 'english'; | 
							$language = 'english'; | 
				
			||||||
		$default_document_array ='1212121'; | 
							$default_document_array ='1212121'; | 
				
			||||||
		$res = fill_Db_course($courseDbName, $courseRepository, $language,$default_document_array); | 
							$res = fill_Db_course($courseDbName, $courseRepository, $language,array()); | 
				
			||||||
		$this->assertTrue($res === 0); | 
							$this->assertTrue($res === 0); | 
				
			||||||
 | 
					 | 
				
			||||||
	} | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						 | 
				
			||||||
	function TestString2Binary(){ | 
						function TestString2Binary(){ | 
				
			||||||
		$variable = true; | 
							$variable = true; | 
				
			||||||
		$res = string2binary($variable); | 
							$res = string2binary($variable); | 
				
			||||||
		$this->assertTrue($res); | 
							$this->assertTrue($res); | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	} | 
						} | 
				
			||||||
 | 
					
 | 
				
			||||||
	function TestCheckArchive(){ | 
						function TestCheckArchive(){ | 
				
			||||||
		$pathToArchive =''; | 
							$pathToArchive =''; | 
				
			||||||
		$res = checkArchive($pathToArchive); | 
							$res = checkArchive($pathToArchive); | 
				
			||||||
		$this->assertTrue($res === TRUE); | 
							$this->assertTrue($res === TRUE); | 
				
			||||||
 | 
					 | 
				
			||||||
	} | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
	/** | 
						 | 
				
			||||||
	 * Fatal Error at the call to undefined function printVar() Line 2404 in the | 
					/*	 // 1 excepcion de permisos | 
				
			||||||
	 * add_course.lib.inc.php | 
					 | 
				
			||||||
	 */ | 
					 | 
				
			||||||
	/* | 
					 | 
				
			||||||
	function TestReadPropertiesInArchive(){ | 
						function TestReadPropertiesInArchive(){ | 
				
			||||||
		$archive='archive'; | 
							ob_start(); | 
				
			||||||
 | 
							$archive='/archive.ini'; | 
				
			||||||
		$uid = api_get_user_id(); | 
							$uid = api_get_user_id(); | 
				
			||||||
		printVar(dirname($archive), "Zip : "); | 
							printVar(dirname($archive), "Zip : "); | 
				
			||||||
 | 
							$perm = '777'; | 
				
			||||||
		$res = readPropertiesInArchive($archive, $isCompressed = TRUE); | 
							$res = readPropertiesInArchive($archive, $isCompressed = TRUE); | 
				
			||||||
		$this->assertTrue($res); | 
							if(is_array($res)){ | 
				
			||||||
 | 
						 		$this->assertTrue(is_array($res)); | 
				
			||||||
 | 
						 	}else{  | 
				
			||||||
	 	ob_start(); | 
						 		$this->assertNull($res); | 
				
			||||||
	 	//readPropertiesInArchive($archive, $isCompressed = TRUE); | 
						 	} | 
				
			||||||
		$res = ob_get_contents(readPropertiesInArchive); | 
						 	ob_end_clean(); | 
				
			||||||
		ob_end_clean(); | 
							//var_dump($res); | 
				
			||||||
		$this->assertFalse($res); | 
					 | 
				
			||||||
		} | 
							} | 
				
			||||||
		*/ | 
					*/ | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
} | 
					} | 
				
			||||||
 | 
				
			|||||||
					Loading…
					
					
				
		Reference in new issue