[svn r21739] Changed to specific functions

skala
Arthur Portugal 16 years ago
parent c6c426d6ff
commit ebdff275b5
  1. 354
      tests/main/inc/lib/main_api.lib.test.php

@ -124,7 +124,6 @@ class TestMainApi extends UnitTestCase {
$res = ob_get_contents(); $res = ob_get_contents();
$this->assertTrue(is_string($res)); $this->assertTrue(is_string($res));
ob_end_clean(); ob_end_clean();
} }
function testApiProtectAdminScriptReturnsFalseWhenOutOfCourseContext(){ function testApiProtectAdminScriptReturnsFalseWhenOutOfCourseContext(){
@ -133,7 +132,6 @@ class TestMainApi extends UnitTestCase {
$res = ob_get_contents(); $res = ob_get_contents();
$this->assertTrue(is_string($res)); $this->assertTrue(is_string($res));
ob_end_clean(); ob_end_clean();
} }
function testApiBlockAnonymousUsersReturnTrueWhenUserIsAnonymous(){ function testApiBlockAnonymousUsersReturnTrueWhenUserIsAnonymous(){
@ -142,37 +140,34 @@ class TestMainApi extends UnitTestCase {
$res = ob_get_contents(); $res = ob_get_contents();
$this->assertTrue(is_string($res)); $this->assertTrue(is_string($res));
ob_end_clean(); ob_end_clean();
} }
function testApiGetNavigator(){ function testApiGetNavigator(){
$res=api_get_navigator(); $res=api_get_navigator();
$this->assertTrue($res); $this->assertTrue($res);
} }
function testApiIsSelfRegistrationAllowed(){ function testApiIsSelfRegistrationAllowed(){
$res = api_is_self_registration_allowed(); $res = api_is_self_registration_allowed();
$this->assertFalse($res); $this->assertTrue(is_bool($res));
//var_dump($res);
} }
function testApiGetPath($path_type){ function testApiGetPath($path_type){
$res=api_get_path(); $res=api_get_path();
$this->assertFalse($res); $this->assertTrue(is_null($res));
//var_dump($res);
} }
function testApiGetUserId(){ function testApiGetUserId(){
$res= api_get_user_id(); $res= api_get_user_id();
$this->assertPattern('/\d/',$res); $this->assertPattern('/\d/',$res);
} }
function testApiGetUserCoursesReturnTrueWhenOutOfCoursesContext(){ function testApiGetUserCoursesReturnTrueWhenOutOfCoursesContext(){
$res = api_get_user_courses(); $res = api_get_user_courses();
$this->assertFalse($res); $this->assertTrue(is_array($res));
//var_dump($res);
} }
function testApiGetUserInfoReturnFalseWhenOutOfUserInfoContext(){ function testApiGetUserInfoReturnFalseWhenOutOfUserInfoContext(){
@ -183,38 +178,34 @@ class TestMainApi extends UnitTestCase {
function testApiGetUserInfoUsernameReturnTrueWhenOutOfUserInfoUsernameContext(){ function testApiGetUserInfoUsernameReturnTrueWhenOutOfUserInfoUsernameContext(){
$res=api_get_user_info_from_username(); $res=api_get_user_info_from_username();
$this->assertFalse($res); $this->assertTrue(is_bool($res));
//var_dump($res);
} }
function testApiGetCourseIdReturnFalseWhenOutOfCourseIdContext(){ function testApiGetCourseIdReturnFalseWhenOutOfCourseIdContext(){
$res =api_get_course_id(); $res =api_get_course_id();
$this->assertTrue($res); $this->assertTrue($res);
} }
function testApiGetCoursePathReturnFalseWhenOutOfCoursePathContext(){ function testApiGetCoursePathReturnFalseWhenOutOfCoursePathContext(){
$res = api_get_course_path(); $res = api_get_course_path();
$this->assertFalse($res); $this->assertTrue(is_null($res));
//var_dump($res);
} }
function testApiGetCourseSettingReturnFalseWhenOutOfCourseSeetingContext(){ function testApiGetCourseSettingReturnFalseWhenOutOfCourseSeetingContext(){
$res = api_get_course_setting(); $res = api_get_course_setting();
$this->assertTrue($res); $this->assertTrue($res);
} }
function testApiGetAnonymousId(){ function testApiGetAnonymousId(){
$res = api_get_anonymous_id(); $res = api_get_anonymous_id();
$this->assertTrue(is_numeric($res)); $this->assertTrue(is_numeric($res));
} }
function testApiGetCidreq(){ function testApiGetCidreq(){
$res=api_get_cidreq(); $res=api_get_cidreq();
$this->assertTrue($res); $this->assertTrue($res);
} }
function testApiGetCourseInfo(){ function testApiGetCourseInfo(){
@ -222,164 +213,153 @@ class TestMainApi extends UnitTestCase {
$res=api_get_course_info(); $res=api_get_course_info();
$this->assertTrue($res); $this->assertTrue($res);
ob_end_clean(); ob_end_clean();
} }
function testApiSqlQuery(){ function testApiSqlQuery(){
ob_start(); ob_start();
$res = api_sql_query(); $res = api_sql_query();
$this->assertFalse($res); $this->assertTrue(is_bool($res));
ob_end_clean(); ob_end_clean();
//var_dump($res);
} }
function testApiStoreResult(){ function testApiStoreResult(){
$res = api_store_result(); $res = api_store_result();
$this->assertFalse($res); $this->assertTrue(is_array($res));
//var_dump($res);
} }
function testApiSessionStart(){ function testApiSessionStart(){
$res = api_session_start($already_sintalled=true); $res = api_session_start($already_sintalled=true);
$this->assertFalse($res); $this->assertTrue(is_null($res));
//var_dump($res);
} }
function testApiSessionRegister(){ function testApiSessionRegister(){
/*$$variable[session_register]=false; $$variable[session_register]=false;
global $$variable;
$res=api_session_register($$variable); $res=api_session_register($$variable);
$this->assertFalse($res); $this->assertTrue(is_null($res));
$this->assertFalse($variable[session_register]); $this->assertTrue(is_null($variable[session_register]));
*/ //var_dump($variable);
$a = 'value';
api_session_register('value');
$this->assertNotEqual($_SESSION['value'],$a);
$this->assertFalse($_SESSION['value'],$a);
} }
function testApiSessionUnregister(){ function testApiSessionUnregister(){
$variable=strval($variable); $variable=strval($variable);
$res=api_session_unregister($variable); $res=api_session_unregister($variable);
$this->assertFalse($res); $this->assertTrue(is_null($res));
$this->assertFalse(isset($GLOBALS[$variable])); $this->assertTrue(is_null($_SESSION[$variable]=null));
$this->assertFalse($_SESSION[$variable]=null);
} }
function testApiSessionClear(){ function testApiSessionClear(){
$res=api_session_clear(); $res=api_session_clear();
$this->assertFalse($res); $this->assertTrue(is_null($res));
//var_dump($res);
} }
function testApiSessionDestroy(){ function testApiSessionDestroy(){
$res=api_session_destroy(); $res=api_session_destroy();
$this->assertFalse($res); $this->assertTrue(is_null($res));
//var_dump($res);
} }
function testApiAddUrlParam(){ function testApiAddUrlParam(){
global $url , $param ; global $url , $param ;
$res=api_add_url_param($url, $param, $filter_xss=true); $res=api_add_url_param($url, $param, $filter_xss=true);
$this->assertFalse($res); $this->assertTrue(is_null($res));
//var_dump($res);
} }
function testApiGeneratePassword(){ function testApiGeneratePassword(){
$res = api_generate_password(); $res = api_generate_password();
$this->assertTrue($res); $this->assertTrue(is_string($res));
//var_dump($res);
} }
function testApiCheckPassword(){ function testApiCheckPassword(){
$lengthPass=strlen(5); $lengthPass=strlen(5);
$password= $lengthPass; $password= $lengthPass;
$res = api_check_password($password); $res = api_check_password($password);
$this->assertFalse($res); $this->assertTrue(is_bool($res));
//var_dump($res);
} }
function testApiClearAnonymous(){ function testApiClearAnonymous(){
global $_user; global $_user;
$_user['user_id'] = 1; $_user['user_id'] = 1;
$res = api_clear_anonymous($db_check=false); $res = api_clear_anonymous($db_check=false);
$this->assertFalse($res); $this->assertTrue(is_bool($res));
//var_dump($res);
$this->assertTrue(isset($_user['user_id'] )); $this->assertTrue(isset($_user['user_id'] ));
} }
function testApiTruncStr(){ function testApiTruncStr(){
$res= api_trunc_str(); $res= api_trunc_str();
$this->assertFalse($res); $this->assertTrue(is_null($res));
//var_dump($res);
} }
function testDomesticate(){ function testDomesticate(){
$input= 'dome'; $input= 'dome';
$res = domesticate($input); $res = domesticate($input);
$this->assertTrue($res); $this->assertTrue($res);
} }
function testGetStatusFromCode(){ function testGetStatusFromCode(){
$status_code = 1; $status_code = 1;
$res=get_status_from_code($status_code); $res=get_status_from_code($status_code);
$this->assertTrue($res); $this->assertTrue($res);
} }
function testApiSetFailure(){ function testApiSetFailure(){
global $api_failureList; global $api_failureList;
$failureType=true; $failureType=true;
$res = api_set_failure($failureType); $res = api_set_failure($failureType);
$this->assertFalse($res); $this->assertTrue(is_bool($res));
$this->assertTrue($api_failureList); $this->assertTrue($api_failureList);
} }
function testApiSetAnonymous(){ function testApiSetAnonymous(){
$res = api_set_anonymous(); $res = api_set_anonymous();
$this->assertTrue(is_bool($res)); $this->assertTrue(is_bool($res));
} }
function testApiGetLastFailure(){ function testApiGetLastFailure(){
$res= api_Get_last_failure(); $res= api_Get_last_failure();
$this->assertTrue($res); $this->assertTrue($res);
} }
function testApiGetSessionId(){ function testApiGetSessionId(){
$res = api_get_session_id(); $res = api_get_session_id();
$this->assertFalse($res); $this->assertTrue(is_numeric($res));
//var_dump($res);
} }
function testApiGetSessionName(){ function testApiGetSessionName(){
$session_id['sesion_id']=1; $session_id['sesion_id']=1;
$res = api_get_session_name($session_id); $res = api_get_session_name($session_id);
$this->assertFalse($res); $this->assertTrue(is_null($res));
//var_dump($res);
} }
function testAPiGetSetting(){ function testAPiGetSetting(){
global $variable, $_setting; global $variable, $_setting;
$res=api_get_setting($variable, $key= NULL); $res=api_get_setting($variable, $key= NULL);
$this->assertFalse($res); $this->assertTrue(is_null($res));
//var_dump($res);
} }
function testApiGetSelf(){ function testApiGetSelf(){
$res = api_get_self(); $res = api_get_self();
$this->assertTrue($res); $this->assertTrue(is_string($res));
//var_dump($res);
} }
function testGetLang(){ function testGetLang(){
global $language_interface, $language_interface_initial_value, $language_file,$variable; global $language_interface, $language_interface_initial_value, $language_file,$variable;
$res = get_lang($variable, $notrans = 'DLTT', $language = null); $res = get_lang($variable, $notrans = 'DLTT', $language = null);
$this->assertFalse($res); $this->assertTrue(is_string($res));
//var_dump($res);
} }
function testGetLangToSystemEncoding(){ function testGetLangToSystemEncoding(){
@ -390,18 +370,18 @@ class TestMainApi extends UnitTestCase {
$res = ob_get_contents(); $res = ob_get_contents();
$this->assertNotEqual($res,''); $this->assertNotEqual($res,'');
ob_end_clean(); ob_end_clean();
}/* }
function testApiGetInterfaceLanguage(){ function testApiGetInterfaceLanguage(){
global $language_interface; global $language_interface;
$language_interface=false; $language_interface=false;
ob_start(); ob_start();
$res = api_get_interface_language(); $res = api_get_interface_language();
//$res = ob_get_contents(); $res = ob_get_contents();
$this->assertFalse($res); $this->assertTrue(is_string($res));
//$this->aasertNotEqual($res,'');
$this->assertTrue(isset($language_interface)); $this->assertTrue(isset($language_interface));
ob_end_clean();
//var_dump($res);
} }
function testApiIsPlatformAdmin(){ function testApiIsPlatformAdmin(){
@ -410,28 +390,30 @@ class TestMainApi extends UnitTestCase {
$_user['status']=true; $_user['status']=true;
$allow_sessions_admins=true; $allow_sessions_admins=true;
$res= api_is_platform_admin($allow_sessions_admins=true); $res= api_is_platform_admin($allow_sessions_admins=true);
$this->assertTrue($res); $this->assertTrue(is_bool($res));
$this->assertTrue($_SESSION['is_platformAdmin']=true); $this->assertTrue($_SESSION['is_platformAdmin']=true);
$this->assertTrue(isset($_user['status'])); $this->assertTrue(isset($_user['status']));
ob_end_clean(); ob_end_clean();
//var_dump($res);
} }
function testApiIsAllowedToCreateCourse(){ function testApiIsAllowedToCreateCourse(){
$res=api_is_allowed_to_create_course(); $res=api_is_allowed_to_create_course();
$this->assertFalse($res); $this->assertTrue(is_null($res));
//var_dump($res);
} }
function testApiIsCourseAdmin(){ function testApiIsCourseAdmin(){
$res=api_is_course_admin(); $res=api_is_course_admin();
$this->assertFalse($res); $this->assertTrue(is_null($res));
//var_dump($res);
} }
function testApiIsCourseCoach(){ function testApiIsCourseCoach(){
$res=api_is_course_coach(); $res=api_is_course_coach();
$this->assertFalse($res); $this->assertTrue(is_null($res));
//var_dump($res);
} }
function testApiIsCoach(){ function testApiIsCoach(){
@ -440,20 +422,22 @@ class TestMainApi extends UnitTestCase {
$_user['user_id']=2; $_user['user_id']=2;
$sessionIsCoach=api_store_result($result=false); $sessionIsCoach=api_store_result($result=false);
$res=api_is_coach(); $res=api_is_coach();
$this->assertFalse($res); $this->assertTrue(is_bool($res));
//var_dump($res);
$this->assertTrue($_user['user_id']); $this->assertTrue($_user['user_id']);
$this->assertFalse($sessionIsCoach); $this->assertTrue(is_array($sessionIsCoach));
//var_dump($sessionIsCoach);
} }
function testApiIsSessionAdmin(){ function testApiIsSessionAdmin(){
global $_user; global $_user;
$_user['status']=true; $_user['status']=true;
$res=api_is_session_admin(); $res=api_is_session_admin();
$this->assertTrue($res); $this->assertTrue(is_bool($res));
$this->assertTrue($_user); $this->assertTrue(is_array($_user));
//var_dump($_user);
}/* }
function testApiDisplayToolTitle(){ function testApiDisplayToolTitle(){
$tit=true; $tit=true;
@ -482,9 +466,7 @@ class TestMainApi extends UnitTestCase {
api_display_array($info_array); api_display_array($info_array);
$res = ob_get_contents(); $res = ob_get_contents();
$this->assertNotEqual($res,''); $this->assertNotEqual($res,'');
//$this->assertPattern('/<div class="normal-message">.*<\/div>/',$res);
ob_end_clean(); ob_end_clean();
} }
function testApiDisplayDebugInfo(){ function testApiDisplayDebugInfo(){
@ -494,8 +476,6 @@ class TestMainApi extends UnitTestCase {
$res = ob_get_contents(); $res = ob_get_contents();
$this->assertNotEqual($res,''); $this->assertNotEqual($res,'');
ob_end_clean(); ob_end_clean();
//$this->assertPattern('/<i>Debug info<\/i>.*//*',$res); //falta agregar ** //despues del punto
} }
/** /**
@ -507,9 +487,7 @@ class TestMainApi extends UnitTestCase {
$is_courseAdmin=false; $is_courseAdmin=false;
$res=api_is_allowed_to_edit($tutor=false,$scoach=false); $res=api_is_allowed_to_edit($tutor=false,$scoach=false);
$this->assertTrue(is_bool($res)); $this->assertTrue(is_bool($res));
$this->assertTrue(isset($is_courseAdmin)); $this->assertTrue(isset($is_courseAdmin));
//$this->assertTrue($is_courseAdmin);
} }
function testApiIsAllowed(){ function testApiIsAllowed(){
@ -520,24 +498,23 @@ class TestMainApi extends UnitTestCase {
$tool= 'full'; $tool= 'full';
$action = 'delete'; $action = 'delete';
$res=api_is_allowed($tool, $action, $task_id=0); $res=api_is_allowed($tool, $action, $task_id=0);
$this->assertFalse($res); $this->assertTrue(is_null($res));
$this->assertTrue($action); $this->assertTrue($action);
$this->assertTrue($_user['user_id']); $this->assertTrue($_user['user_id']);
$this->assertFalse($_course['code']);
ob_end_clean(); ob_end_clean();
//var_dump($res);
} }
function testApiIsAnonymous(){ function testApiIsAnonymous(){
global $_user, $use_anonymous; global $_user, $use_anonymous;
$_user['is_anonymous']=False; $_user['is_anonymous']=False;
$res=api_is_anonymous($user_id=null, $db_check=false); $res=api_is_anonymous($user_id=null, $db_check=false);
$this->assertFalse($res); $this->assertTrue(is_bool($res));
$this->assertFalse(isset($user_id)); $this->assertFalse(isset($user_id));
$this->assertTrue(isset($_user['is_anonymous'])); $this->assertTrue(isset($_user['is_anonymous']));
$this->assertFalse($use_anonymous); $this->assertTrue(is_null($use_anonymous));
$this->assertFalse($db_check); $this->assertTrue(is_bool($db_check));
//var_dump($db_check);
} }
/** /**
@ -550,7 +527,6 @@ class TestMainApi extends UnitTestCase {
$res = ob_get_contents(); $res = ob_get_contents();
$this->assertEqual($res,''); $this->assertEqual($res,'');
ob_end_clean(); ob_end_clean();
} }
function testConvertMysqlDate(){ function testConvertMysqlDate(){
@ -561,14 +537,12 @@ class TestMainApi extends UnitTestCase {
$this->assertTrue($res); $this->assertTrue($res);
$this->assertFalse($result); $this->assertFalse($result);
$this->assertFalse($myrow); $this->assertFalse($myrow);
} }
function testApiGetDatetime(){ function testApiGetDatetime(){
$res=api_get_datetime($time=null); $res=api_get_datetime($time=null);
$this->assertTrue($res); $this->assertTrue($res);
$this->assertFalse(isset($time)); $this->assertFalse(isset($time));
} }
function testApiGetItemVisibility(){ function testApiGetItemVisibility(){
@ -579,14 +553,12 @@ class TestMainApi extends UnitTestCase {
$res =api_get_item_visibility($_course,$tool,$id); $res =api_get_item_visibility($_course,$tool,$id);
$this->assertTrue($res); $this->assertTrue($res);
$this->assertFalse(isset($_course['dbName'])); $this->assertFalse(isset($_course['dbName']));
} }
function testApiItemPropertyUpdate(){ function testApiItemPropertyUpdate(){
global $_course, $tool, $item_id, $lastedit_type, $user_id; global $_course, $tool, $item_id, $lastedit_type, $user_id;
$res=api_item_property_update($_course, $tool, $item_id, $lastedit_type, $user_id, $to_group_id = 0, $to_user_id = NULL, $start_visible = 0, $end_visible = 0); $res=api_item_property_update($_course, $tool, $item_id, $lastedit_type, $user_id, $to_group_id = 0, $to_user_id = NULL, $start_visible = 0, $end_visible = 0);
$this-> assertTrue($res); $this-> assertTrue($res);
} }
function testApiGetLanguagesCombo(){ function testApiGetLanguagesCombo(){
@ -596,7 +568,6 @@ class TestMainApi extends UnitTestCase {
$this->assertTrue($res); $this->assertTrue($res);
$this->assertTrue($platformLanguage); $this->assertTrue($platformLanguage);
$this->assertTrue($language_list['name']); $this->assertTrue($language_list['name']);
} }
function testApiDisplayLanguageForm(){ function testApiDisplayLanguageForm(){
@ -605,7 +576,6 @@ class TestMainApi extends UnitTestCase {
$res = ob_get_contents(); $res = ob_get_contents();
$this->assertNotEqual($res,''); $this->assertNotEqual($res,'');
ob_end_clean(); ob_end_clean();
} }
function testApiGetLanguages(){ function testApiGetLanguages(){
@ -614,16 +584,16 @@ class TestMainApi extends UnitTestCase {
$res= api_get_languages(); $res= api_get_languages();
$this->assertTrue($res); $this->assertTrue($res);
$this->assertFalse($row); $this->assertFalse($row);
} }
function testApiGetLanguageIsocode(){ function testApiGetLanguageIsocode(){
$query='';
$sql= true; $sql= true;
$var=api_sql_query($sql,_FILE_,_LINE_); $var=api_sql_query($sql,_FILE_,_LINE_);
$res=api_get_language_isocode(); $res=api_get_language_isocode($query);
$this->assertTrue(is_string($res)); $this->assertTrue(is_string($query));
$this->assertTrue(isset($var)); $this->assertTrue(isset($var));
//var_dump($query);
} }
function testApiGetThemes(){ function testApiGetThemes(){
@ -631,7 +601,6 @@ class TestMainApi extends UnitTestCase {
$res=api_get_themes(); $res=api_get_themes();
$this->assertTrue($res); $this->assertTrue($res);
$this->assertTrue($cssdir); $this->assertTrue($cssdir);
} }
function testApiDispHtmlArea(){ function testApiDispHtmlArea(){
@ -649,33 +618,31 @@ class TestMainApi extends UnitTestCase {
global $_configuration, $_course, $fck_attribute; global $_configuration, $_course, $fck_attribute;
$res=api_return_html_area($name, $content='', $height='', $width='100%', $optAttrib=''); $res=api_return_html_area($name, $content='', $height='', $width='100%', $optAttrib='');
$this->assertTrue($res); $this->assertTrue($res);
} }
function testApiSendMail(){ function testApiSendMail(){
$to= 'ricardo.rodriguez@dokeos.com'; $to= 'test@dokeos.com';
$subject='Hola'; $subject='Hola';
$message="prueba de envio"; $message="prueba de envio";
$send_mail=mail(); $send_mail=mail();
$res=api_send_mail($to, $subject, $message, $additional_headers = null, $additional_parameters = null); $res=api_send_mail($to, $subject, $message, $additional_headers = null, $additional_parameters = null);
$this->assertTrue($res); $this->assertTrue(is_bool($res));
$this->assertFalse($send_mail); $this->assertTrue(is_null($send_mail));
//var_dump($res);
//var_dump($send_mail);
} }
function testApiMaxSortValue(){ function testApiMaxSortValue(){
$user=array('user_course_category'=>21, 'user_id'=>1); $user=array('user_course_category'=>1, 'user_id'=>1);
$res= api_max_sort_value($user['user_course_category'],$user['user_id']); $res= api_max_sort_value($user['user_course_category'],$user['user_id']);
$this->assertFalse($res); $this->assertFalse($res);
$this->assertTrue($user); $this->assertTrue($user);
} }
function testString2Boolean(){ function testString2Boolean(){
global $string; global $string;
$res=string_2_boolean($string); $res=string_2_boolean($string);
$this->assertFalse($res); $this->assertFalse($res);
} }
function testApiNumberOfPlugins(){ function testApiNumberOfPlugins(){
@ -685,7 +652,6 @@ class TestMainApi extends UnitTestCase {
$res=api_number_of_plugins($location); $res=api_number_of_plugins($location);
$this->assertFalse($res); $this->assertFalse($res);
$this->assertTrue($_plugins[$location]); $this->assertTrue($_plugins[$location]);
} }
function testApiPlugin(){ function testApiPlugin(){
@ -695,46 +661,48 @@ class TestMainApi extends UnitTestCase {
$res1 = api_plugin($location); $res1 = api_plugin($location);
$this->assertFalse($res1); $this->assertFalse($res1);
$this->assertTrue($_plugins[$location]); $this->assertTrue($_plugins[$location]);
} }
function testApiIsPluginInstalled(){ function testApiIsPluginInstalled(){
$plugin_name = false; $plugin_name = false;
$plugin_list = true; $plugin_list = true;
$res = api_is_plugin_installed($plugin_list, $plugin_name); $res = api_is_plugin_installed($plugin_list, $plugin_name);
$this->assertFalse($res); $this->assertTrue(is_bool($res));
//var_dump($res);
} }
function testApiParseTex(){ function testApiParseTex(){
global $textext; global $textext;
$res = api_parse_tex($textext); $res = api_parse_tex($textext);
$this->assertFalse($res); $this->assertTrue(is_string($res));
//var_dump($res);
} }
function testApiTimeToHms(){ function testApiTimeToHms(){
$seconds = -1; $seconds = -1;
$res = api_time_to_hms($seconds); ob_start();
$this-> assertTrue($res); api_time_to_hms($seconds);
$res = ob_get_contents();
$this-> assertTrue(is_string($res));
ob_end_clean();
//var_dump($res);
} }
function testCopyr(){ function testCopyr(){
$source = api_get_path(SYS_CODE_PATH).'app_share/DokeosAppShare.exe'; $source = api_get_path(SYS_CODE_PATH).'app_share/DokeosAppShare.exe';
$dest = ''; $dest = '';
$res = copyr($source, $dest, $exclude=array(), $copied_files=array()); $res = copyr($source, $dest, $exclude=array(), $copied_files=array());
$this->assertFalse($res); $this->assertTrue(is_null($res));
//var_dump($res);
} }
function testApiChmod_R(){ function testApiChmod_R(){
$path = $_GET['path']; $path = $_GET['path'];
$filemode = ''; $filemode = '';
$res = api_chmod_R($path, $filemode); $res = api_chmod_R($path, $filemode);
$this->assertFalse($res); $this->assertTrue(is_bool($res));
$this->assertFalse($path); $this->assertTrue(is_null($path));
//var_dump($path);
} }
function testApiGetVersion(){ function testApiGetVersion(){
@ -742,7 +710,6 @@ class TestMainApi extends UnitTestCase {
$res = api_get_version(); $res = api_get_version();
$this->assertFalse(isset($_configuration)); $this->assertFalse(isset($_configuration));
$this->assertTrue($res); $this->assertTrue($res);
} }
function testApiStatusExists(){ function testApiStatusExists(){
@ -751,11 +718,11 @@ class TestMainApi extends UnitTestCase {
$status_asked[$_status_list1]= null; $status_asked[$_status_list1]= null;
$status_asked[$_status_list2]= true; $status_asked[$_status_list2]= true;
$res = api_status_exists($status_asked); $res = api_status_exists($status_asked);
$this->assertFalse($res); $this->assertTrue(is_bool($res));
$this->assertNotNull(isset($status_asked[$_status_list])); $this->assertNotNull(isset($status_asked[$_status_list]));
$this->assertNotNull(isset($status_asked[$_status_list1])); $this->assertNotNull(isset($status_asked[$_status_list1]));
$this->assertNotNull(isset($status_asked[$_status_list2])); $this->assertNotNull(isset($status_asked[$_status_list2]));
//var_dump($res);
} }
function testApiStatusKey(){ function testApiStatusKey(){
@ -765,14 +732,14 @@ class TestMainApi extends UnitTestCase {
$res = api_status_key($status); $res = api_status_key($status);
$this->assertNotNull(isset($status[$_status_list])); $this->assertNotNull(isset($status[$_status_list]));
$this->assertNotNull(isset($status[$_status_list1])); $this->assertNotNull(isset($status[$_status_list1]));
$this->assertFalse($res); $this->assertTrue(is_bool($res));
//var_dump($res);
} }
function testApiGetStatusLangvars(){ function testApiGetStatusLangvars(){
$res = api_get_status_langvars(); $res = api_get_status_langvars();
$this->assertTrue($res); $this->assertTrue(is_array($res));
//var_dump($res);
} }
function testApiSetSetting(){ function testApiSetSetting(){
@ -780,66 +747,67 @@ class TestMainApi extends UnitTestCase {
$var = 0; $var = 0;
$value = 2; $value = 2;
$res = api_set_setting($var,$value,$subvar=null,$cat=null,$access_url=1); $res = api_set_setting($var,$value,$subvar=null,$cat=null,$access_url=1);
$this->assertFalse($res); $this->assertTrue(is_bool($res));
ob_end_clean(); ob_end_clean();
//var_dump($res);
} }
function testApiSetSettingsCategory(){ function testApiSetSettingsCategory(){
$category = $_GET['category']; $category = $_GET['category'];
$res = api_set_settings_category($category,$value=null,$access_url=1); $res = api_set_settings_category($category,$value=null,$access_url=1);
$this->assertFalse($category); $this->assertTrue(is_null($category));
$this->assertFalse($res); $this->assertTrue(is_bool($res));
//var_dump($res);
//var_dump($category);
} }
function testApiGetAccessUrls(){ function testApiGetAccessUrls(){
$res = api_get_access_urls($from=0,$to=1000000,$order='url',$direction='ASC'); $res = api_get_access_urls($from=0,$to=1000000,$order='url',$direction='ASC');
$this->assertTrue($res); $this->assertTrue(is_array($res));
//var_dump($res);
} }
function testApiGetAccessUrl(){ function testApiGetAccessUrl(){
global $_configuration; global $_configuration;
$id[$_configuration]=1; $id[$_configuration]=1;
$res = api_get_access_url($id); $res = api_get_access_url($id);
$this->assertFalse($res); $this->assertTrue(is_bool($res));
$this->assertFalse($id[$_configuration]); $this->assertFalse($id[$_configuration]);
//var_dump($res);
} }
function testApiAddAccessUrl(){ function testApiAddAccessUrl(){
$u=1; $u = Database::escape_string($u);
$d='fail'; $d = Database::escape_string($d);
$res = api_add_access_url($u,$d='',$a=1); $res = api_add_access_url($u,$d='',$a=1);
$this->assertTrue($res); $this->assertTrue(is_numeric($res));
var_dump($res);
} }
function testApiGetSettings(){ function testApiGetSettings(){
$res = api_get_settings($cat=null,$ordering='list',$access_url=1,$url_changeable=0); $res = api_get_settings($cat=null,$ordering='list',$access_url=1,$url_changeable=0);
$this->assertTrue($res); $this->assertTrue(is_array($res));
//var_dump($res);
} }
function testApiGetSettingsCategories(){ function testApiGetSettingsCategories(){
$res = api_get_settings_categories($exceptions=array(),$access_url=1); $res = api_get_settings_categories($exceptions=array(),$access_url=1);
$this->assertTrue($res); $this->assertTrue(is_array($res));
//var_dump($res);
} }
function testApiDeleteSetting(){ function testApiDeleteSetting(){
$v = false; $v = false;
$res = api_delete_setting($v, $s=NULL, $a=1); $res = api_delete_setting($v, $s=NULL, $a=1);
$this->assertFalse($res); $this->assertTrue(is_bool($res));
//var_dump($res);
} }
function testApiDeleteCategorySettings(){ function testApiDeleteCategorySettings(){
$c= false; $c= false;
$res = api_delete_category_settings($c,$a=1); $res = api_delete_category_settings($c,$a=1);
$this->assertFalse($res); $this->assertTrue(is_bool($res));
//var_dump($res);
} }
function testApiAddSetting(){ function testApiAddSetting(){
@ -854,14 +822,14 @@ class TestMainApi extends UnitTestCase {
$v=0; $v=0;
$va=array('val'=>10, 'var'=>'name'); $va=array('val'=>10, 'var'=>'name');
$res= api_add_setting($va['val'],$va['var'],null,null,null,null,null,null,null,null,null); $res= api_add_setting($va['val'],$va['var'],null,null,null,null,null,null,null,null,null);
$this->assertFalse($res); $this->assertTrue(is_bool($res));
//var_dump($res);
} }
function testApiIsCourseVisibleForUser(){ function testApiIsCourseVisibleForUser(){
$res = api_is_course_visible_for_user($userid=null, $cid=null); $res = api_is_course_visible_for_user($userid=null, $cid=null);
$this->assertFalse($res); $this->assertTrue(is_bool($res));
//var_dump($res);
} }
function testApiIsElementInTheSession(){ function testApiIsElementInTheSession(){
@ -869,9 +837,10 @@ class TestMainApi extends UnitTestCase {
$_tool['tool'] = 'TOOL_SURVEY'; $_tool['tool'] = 'TOOL_SURVEY';
$_id['element_id']=3; $_id['element_id']=3;
$res = api_is_element_in_the_session($_tool['tool'], $_id['element_id'], $session_id=null); $res = api_is_element_in_the_session($_tool['tool'], $_id['element_id'], $session_id=null);
$this->assertFalse($res); $this->assertTrue(is_bool($res));
$this->assertTrue((isset($_tool['tool'],$_id['element_id']))); $this->assertTrue((isset($_tool['tool'],$_id['element_id'])));
ob_end_clean(); ob_end_clean();
//var_dump($res);
} }
function testReplaceDangerousChar(){ function testReplaceDangerousChar(){
@ -880,62 +849,56 @@ class TestMainApi extends UnitTestCase {
/*Keep C1 controls for UTF-8 streams **/ '-----_---_'), 0, 250)); /*Keep C1 controls for UTF-8 streams **/ '-----_---_'), 0, 250));
$res = replace_dangerous_char($filename, $strict = 'loose'); $res = replace_dangerous_char($filename, $strict = 'loose');
$this->assertEqual($res,$filename, $message = 'no se pudo'); $this->assertEqual($res,$filename, $message = 'no se pudo');
} }
function testApiRequestUri(){ function testApiRequestUri(){
$res = api_request_uri(); $res = api_request_uri();
$this->assertTrue($res); $this->assertTrue($res);
} }
function testApiCreateIncludePathSetting(){ function testApiCreateIncludePathSetting(){
$res=api_create_include_path_setting(); $res=api_create_include_path_setting();
$this->assertTrue($res); $this->assertTrue($res);
} }
function testApiGetCurrentAccessUrlId(){ function testApiGetCurrentAccessUrlId(){
$res=api_get_current_access_url_id(); $res=api_get_current_access_url_id();
$this->assertTrue($res); $this->assertTrue($res);
} }
function testApiGetAccessUrlFromUser(){ function testApiGetAccessUrlFromUser(){
$user_id=1; $user_id=1;
$res= api_get_access_url_from_user($user_id); $res= api_get_access_url_from_user($user_id);
$this->assertFalse($res); $this->assertTrue(is_array($res));
//var_dump($res);
} }
function testApiGetStatusOfUserInCourse(){ function testApiGetStatusOfUserInCourse(){
$id = array( $id = array(
'course_code'=>'211', 'course_code'=>'TEST',
'user_id'=>'112'); 'user_id'=>'1');
$res=api_get_status_of_user_in_course($id['course_code'],$id['user_id']); $res=api_get_status_of_user_in_course($id['course_code'],$id['user_id']);
$this->assertFalse($res); $this->assertTrue(is_null($res));
//$this->assertPattern('/\d/',$res); //var_dump($res);
} }
function testApiIsInCourse(){ function testApiIsInCourse(){
$_SESSION['_course']['sysCode']=0; $_SESSION['_course']['sysCode']=0;
$res=api_is_in_course($course_code=null); $res=api_is_in_course($course_code=null);
$this->assertTrue($res); $this->assertTrue(is_bool($res));
$this->assertTrue(isset($_SESSION['_course']['sysCode'])); $this->assertTrue(isset($_SESSION['_course']['sysCode']));
//var_dump($res);
} }
function testApiIsInGroup(){ function testApiIsInGroup(){
$res=api_is_in_group($group_id=null, $course_code=null); $res=api_is_in_group($group_id=null, $course_code=null);
$this->assertFalse($res); $this->assertTrue(is_bool($res));
//var_dump($res);
} }
function testApiIsXmlHttpRequest(){ function testApiIsXmlHttpRequest(){
$res=api_is_xml_http_request(); $res=api_is_xml_http_request();
$this->assertTrue(isset($res)); $this->assertTrue(isset($res));
} }
function testApiGetEncryptedPassword(){ function testApiGetEncryptedPassword(){
@ -944,7 +907,6 @@ class TestMainApi extends UnitTestCase {
$res=api_get_encrypted_password($pass['password'],null); $res=api_get_encrypted_password($pass['password'],null);
$this->assertTrue($res); $this->assertTrue($res);
$this->assertPattern('/\d/',$res); $this->assertPattern('/\d/',$res);
} }
function testApiIsValidSecretKey(){ function testApiIsValidSecretKey(){
@ -957,7 +919,6 @@ class TestMainApi extends UnitTestCase {
$this->assertFalse($res); $this->assertFalse($res);
$this->assertTrue($key); $this->assertTrue($key);
$this->assertEqual($key['original_key_secret'],$key['security_key'], $message ='%s'); $this->assertEqual($key['original_key_secret'],$key['security_key'], $message ='%s');
} }
function testApiIsUserOfCourse(){ function testApiIsUserOfCourse(){
@ -969,48 +930,47 @@ class TestMainApi extends UnitTestCase {
$this->assertFalse($res); $this->assertFalse($res);
$this->assertFalse($tbl_course_rel_user); $this->assertFalse($tbl_course_rel_user);
$this->assertTrue($sql); $this->assertTrue($sql);
} }
function testApiIsWindowsOs(){ function testApiIsWindowsOs(){
$res= api_is_windows_os(); $res= api_is_windows_os();
$this->assertFalse($res); $this->assertTrue(is_bool($res));
//var_dump($res);
} }
function testApiUrlToLocalPath(){ function testApiUrlToLocalPath(){
global $url; global $url;
$cond= preg_match(false); $cond= preg_match(false);
$res= api_url_to_local_path($url); $res= api_url_to_local_path($url);
$this->assertFalse($res); $this->assertTrue(is_null($res));
$this->assertFalse($cond); $this->assertFalse($cond);
//var_dump($res);
} }
function testApiResizeImage(){ function testApiResizeImage(){
//global $image, $target_width, $target_height; //global $image, $target_width, $target_height;
$resize = array('image' =>'image.jpg', 'target_width'=>100, 'target_height'=>100); $resize = array('image' =>'image.jpg', 'target_width'=>100, 'target_height'=>100);
$res = api_resize_image($resize['image'],$resize['target_width'],$resize['target_height']); $res = api_resize_image($resize['image'],$resize['target_width'],$resize['target_height']);
$this->assertTrue($res); $this->assertTrue(is_array($res));
$this->assertWithinMargin($first = 10, $second=20,$margin=200, $message = 'no se pudo redimensionar imagen'); $this->assertWithinMargin($first = 10, $second=20,$margin=200, $message = 'no se pudo redimensionar imagen');
//var_dump($res);
} }
function testApiCalculateImageSize(){ function testApiCalculateImageSize(){
global $image_width, $image_height, $target_width, $target_height; global $image_width, $image_height, $target_width, $target_height;
$result = array($image_width, $image_height); $result = array($image_width, $image_height);
$res = api_calculate_image_size($image_width, $image_height, $target_width, $target_height); $res = api_calculate_image_size($image_width, $image_height, $target_width, $target_height);
$this->assertTrue($res); $this->assertTrue(is_array($res));
$this->assertTrue($result); $this->assertTrue($result);
//var_dump($res);
} }
function testApiGetToolsLists(){ function testApiGetToolsLists(){
$tool_list = 'false'; $tool_list = 'false';
$res = api_get_tools_lists($my_tool =null); $res = api_get_tools_lists($my_tool =null);
$this->assertTrue($res); $this->assertTrue(is_array($res));
$this->assertTrue($tool_list); $this->assertTrue($tool_list);
//var_dump($res);
} }
} }
?> ?>

Loading…
Cancel
Save