123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868 |
- <?php //$id:$
- class TestMainApi extends UnitTestCase {
-
- function TestMainApi() {
- $this->UnitTestCase('Main API tests');
- }
- // todo function testApiProtectCourseScriptReturnsFalse()
- // todo function testApiProtectAdminScriptReturnsFalse()
- // todo function testApiBlockAnonymousUsers()
- // todo function testApiGetNavigatorReturnArray($name,$version)
- // todo function testApiIsSelfRegistrationAllowedReturnTrue()
- // todo function testApiGetPathReturnString()
- // todo function testApiGetUserIdReturnInteger()
- // todo function testApiGetUserCoursesReturnArray()
- // todo function testApiGetUserInfoReturnArray($user_id)
- // todo function testApiGetUserInfoFromUsernameReturnArray($username)
- // todo function testApiGetCourseIdReturnInteger()
- // todo function testApiGetCoursePath()
- // todo function testApiGetCourseSetting()
- // todo function testApiGetAnonymousIdReturnInt()
- // todo function testApiGetCidreq()
- // todo function testApiGetCourseInfoReturnString()
- // todo function testApiSqlQuery()
- // todo function testApiStoreResultReturnArray()
- // todo function testApiSessionStartReturnTrue()
- // todo function testApiSessionRegister()
- // todo function testApiSessionUnregister()
- // todo function testApiSessionClearReturnArray()
- // todo function testApiSessionDestroyReturnArray()
- // todo function testApiAdd_UrlParamReturnString()
- // todo function testApiGeneratePasswordReurnPassword()
- // todo function testApiCheckPasswordReturnTrue()
- // todo function testApiClearAnonymousReturnFalse()
- // todo function testApiTruncStr()
- // todo function testDomesticate
- // todo function testGetStatusFromCodeReturnString()
- // todo function testApiSetFailureReturnFalse()
- // todo function testApiSetAnonymousReturnTrue()
- // todo function testGetLastFailureRetunrString()
- // todo function testApiGetSessionIdReturnInt()
- // todo function testApiGetSessionNameReturnString()
- // todo function testApiGetSelfReturnRightValue()
- // todo function testGetLangReturnRightValue()
- // todo function testApiGetInterfaceLanguageReturnString()
- // todo function testApiIsPlatformAdminReturnTrue()
- // todo function testApiIsAllowedToCreateCourseReturnTrue()
- // todo function testApiIsCourseAdminRetunTrue()
- // todo function testApiIsCourseCoachReturnTrue()
- // todo function testApiIsCourseTutorReturnTrue()
- // todo function testApiIsCoachReturnTrue()
- // todo function testApiIsSessionAdminReturnTrue()
- // todo function testApiDisplayToolTitle($titleElement)
- // todo function testApiDisplayToolViewOption()
- // todo function testApiDisplayArray()
- // todo function testApiDisplayDebugInfo()
- // todo function testApiIsAllowedToEdit()
- // todo function testApiIsAllowed()
- // todo function testApiIsAnonymous()
- // todo function testApiNotAllowed()
- // todo function testConvertMysqlDate()
- // todo function testApiGetDatetime()
- // todo function testApiGetItemVisibility()
- // todo function testApiItemPropertyUpdate()
- // todo function testApiGetLanguagesCombo()
- // todo function testApiDisplayLanguageForm()
- // todo function testApiGetLanguages()
- // todo function testApiGetLanguageIsocode()
- // todo function testApiGetThemesReturnArray()
- // todo function testApiDispHtmlArea()
- // todo function testApiReturnHtmlArea()
- // todo function testApiSendMail()
- // todo function testApiMaxSortValue()
- // todo function testString2Boolean()
- // todo function testApiNumberOfPlugins()
- // todo function testApiPlugin()
- // todo function testApiIsPluginInstalled()
- // todo function testApiParseTex()
- // todo function testApiTimeToHms()
- // todo function testCopyr()
- // todo function testApiChmodR()
- // todo function testApiGetVersionReturnString()
- // todo function testApiStatusExistsReturnTrue()
- // todo function testApiStatusKeyReturnTrue()
- // todo function testApiStatusLangvarsReturnArray()
- // todo function testApiSetSetting()
- // todo function testApiSetSettingsCategoryReturnTrue()
- // todo function testApiGetAccessUrlsReturnArray()
- // todo function testApiGetAccessUrlReturnArray()
- // todo function testApiAddAccessUrlReturnInt()
- // todo function testApiGetSettingsReturnArray()
- // todo function testApiGetSettingsCategoriesReturnArray()
- // todo function testApiDeleteSettingReturnTrue()
- // todo function testApiDeleteCategorySettingsReturnTrue()
- // todo function testApiAddSettingReturnTrue()
- // todo function testApiIsCourseVisibleForUserReturnBooleanValue()
- // todo function testApiIsElementInTheSessionReturnBooleanValue()
- // todo function testReplaceDangerousChar()
- // todo function testApiRequestUri()
- // todo function testApiCreateIncludePathSetting()
- // todo function testApiGetCurrentAccessUrlIdReturnInt()
- // todo function testApiAccessUrlFromUserReturnInt()
- // todo function testApiGetStatusOfUserInCourseReturnInteger()
- // todo function testApiIsInCourseReturnBooleanValue()
- // todo function testApiIsInGroupReturnBooleanValue()
- // todo function testApiIsXmlHttpRequest()
- // todo function testApiGetEncryptedPassword()
- // todo function testApiIsValidSecretKeyReturnBooleanValue()
- // todo function testApiIsUserOfCourseReturnBooleanValue()
- // todo function testApiIsWnidowsOsReturnBooleanValue()
- // todo function testApiUrlToLocalPathReturnString()
- // todo function testApiResizeImage()
- // todo function testApiCalculateImageSizeReturnArray()
-
- /**
- * Test out of a course context
- */
-
- function testApiProtectCourseScriptReturnsFalseWhenOutOfCourseContext(){
- $res= api_protect_course_script();
- $this->assertTrue($res);
-
- }
-
- function testApiGetSettingReturnsTrueWhenIsRightValue(){
- $res=api_get_setting();
- $this->assertFalse($res);
-
- }
-
- /**
- /* Test out of a Admin context
- */
-
- function testApiProtectAdminScriptReturnsFalseWhenOutOfCourseContext(){
- $res= api_protect_admin_script();
- $this->assertTrue($res);
-
- }
-
- function testApiBlockAnonymousUsersReturnTrueWhenUserIsAnonymous(){
- $res=api_block_anonymous_users();
- $this->assertTrue($res);
-
- }
-
- function testApiGetNavigator(){
- $res=api_get_navigator();
- $this->assertTrue($res);
-
- }
-
- function testApiIsSelfRegistrationAllowed(){
- $res = api_is_self_registration_allowed();
- $this->assertFalse($res);
-
- }
-
- function testApiGetPath($path_type){
- $res=api_get_path();
- $this->assertFalse($res);
-
- }
-
- function testApiGetUserId(){
- $res= api_get_user_id();
- $this->assertPattern('/\d/',$res);
-
- }
- function testApiGetUserCoursesReturnTrueWhenOutOfCoursesContext(){
- $res = api_get_user_courses();
- $this->assertFalse($res);
-
- }
-
- function testApiGetUserInfoReturnFalseWhenOutOfUserInfoContext(){
- $res = api_get_user_info();
- $this->assertTrue($res);
-
- }
-
- function testApiGetUserInfoUsernameReturnTrueWhenOutOfUserInfoUsernameContext(){
- $res=api_get_user_info_from_username();
- $this->assertFalse($res);
-
- }
-
- function testApiGetCourseIdReturnFalseWhenOutOfCourseIdContext(){
- $res =api_get_course_id();
- $this->assertTrue($res);
-
- }
- function testApiGetCoursePathReturnFalseWhenOutOfCoursePathContext(){
- $res = api_get_course_path();
- $this->assertFalse($res);
-
- }
-
- function testApiGetCourseSettingReturnFalseWhenOutOfCourseSeetingContext(){
- $res = api_get_course_setting();
- $this->assertTrue($res);
-
- }
-
- function testApiGetAnonymousId(){
- $res = api_get_anonymous_id();
- $this->assertTrue($res);
-
- }
-
- function testApiGetCidreq(){
- $res=api_get_cidreq();
- $this->assertTrue($res);
-
- }
-
- function testApiGetCourseInfo(){
- $res=api_get_course_info();
- $this->assertTrue($res);
-
- }
-
- function testApiSqlQuery(){
- $res = api_sql_query();
- $this->assertFalse($res);
-
- }
-
- function testApiStoreResult(){
- $res = api_store_result();
- $this->assertFalse($res);
-
- }
-
- function testApiSessionStart(){
- $res = api_session_start($already_sintalled=true);
- $this->assertFalse($res);
-
- }
-
- function testApiSessionRegister(){
- $$variable[session_register]=false;
- $res=api_session_register($$variable);
- $this->assertFalse($res);
- $this->assertFalse($variable[session_register]);
-
- }
-
- function testApiSessionUnregister(){
- $variable=strval($variable);
- $res=api_session_unregister($variable);
- $this->assertFalse($res);
- $this->assertFalse(isset($GLOBALS[$variable]));
- $this->assertFalse($_SESSION[$variable]=null);
-
- }
-
- function testApiSessionClear(){
- $res=api_session_clear();
- $this->assertFalse($res);
-
- }
-
- function testApiSessionDestroy(){
- $res=api_session_destroy();
- $this->assertFalse($res);
-
- }
-
- function testApiAddUrlParam(){
- global $url , $param ;
- $res=api_add_url_param($url, $param, $filter_xss=true);
- $this->assertFalse($res);
-
- }
-
- function testApiGeneratePassword(){
- $res = api_generate_password();
- $this->assertTrue($res);
-
- }
-
- function testApiCheckPassword(){
- $lengthPass=strlen(5);
- $password= $lengthPass;
- $res = api_check_password($password);
- return $this->assertFalse($res);
-
- }
-
- function testApiClearAnonymous(){
- global $_user;
- $_user['user_id'] = 1;
- $res = api_clear_anonymous($db_check=false);
- $this->assertFalse($res);
- $this->assertTrue(isset($_user['user_id'] ));
-
- }
-
- function testApiTruncStr(){
- $res= api_trunc_str();
- return $this->assertFalse($res);
-
- }
-
- function testDomesticate(){
- $input= 'dome';
- $res = domesticate($input);
- return $this->assertTrue($res);
-
- }
-
- function testGetStatusFromCode(){
- $status_code = 1;
- $res=get_status_from_code($status_code);
- return $this->assertTrue($res);
-
- }
-
- function testApiSetFailure(){
- global $api_failureList;
- $failureType=true;
- $res = api_set_failure($failureType);
- $this->assertFalse($res);
- $this->assertTrue($api_failureList);
-
- }
-
- function testApiSetAnonymous(){
- $res = api_set_anonymous();
- return $this->assertFalse($res);
-
- }
-
- function testApiGetLastFailure(){
- $res= api_Get_last_failure();
- $this->assertTrue($res);
-
- }
-
- function testApiGetSessionId(){
- $res = api_get_session_id();
- return $this->assertFalse($res);
-
- }
-
- function testApiGetSessionName(){
- $session_id['sesion_id']=1;
- $res = api_get_session_name($session_id);
- $this->assertFalse($res);
-
- }
-
- function testAPiGetSetting(){
- global $variable;
- $res=api_get_setting($variable, $key= NULL);
- return $this->assertFalse($res);
-
- }
-
- function testApiGetSelf(){
- $res = api_get_self();
- return $this->assertTrue($res);
-
- }
-
- /**
- * function still unproved
-
- function testGetLang(){
- global $language_interface, $language_interface_initial_value, $language_file,$variable;
- static $cache=array();
- $language=$language_interface;
- $cache[$language]=array(false=> array(), true=>array());
- $res = get_lang($variable, $notrans = 'DLTT', $language = null);
-
-
- }
- /**
- * function still unproved
-
- function testGetLangToSystemEncoding(){
- $language;
- $res=&get_lang_to_system_encoding(& $string, $language);
-
-
- }*/
-
- function testApiGetInterfaceLanguage(){
- global $language_interface;
- $language_interface=false;
- $res=api_get_interface_language();
- $this->assertFalse($res);
- $this->assertTrue(isset($language_interface));
-
- }
-
- function testApiIsPlatformAdmin(){
- global $_user;
- $_user['status']=true;
- $allow_sessions_admins=true;
- $res= api_is_platform_admin($allow_sessions_admins=true);
- $this->assertTrue($res);
- $this->assertTrue($_SESSION['is_platformAdmin']=true);
- $this->assertTrue(isset($_user['status']));
-
- }
-
- function testApiIsAllowedToCreateCourse(){
- $res=api_is_allowed_to_create_course();
- $this->assertFalse($res);
-
- }
-
- function testApiIsCourseAdmin(){
- $res=api_is_course_admin();
- $this->assertFalse($res);
-
- }
-
- function testApiIsCourseCoach(){
- $res=api_is_course_coach();
- $this->assertFalse($res);
-
- }
-
- function testApiIsCoach(){
- global $_user;
- global $sessionIsCoach;
- $_user['user_id']=2;
- $sessionIsCoach=api_store_result($result=false);
- $res=api_is_coach();
- $this->assertFalse($res);
- $this->assertTrue($_user['user_id']);
- $this->assertFalse($sessionIsCoach);
-
- }
-
- function testApiIsSessionAdmin(){
- global $_user;
- $_user['status']=true;
- $res=api_is_session_admin();
- $this->assertTrue($res);
- $this->assertTrue($_user);
-
- }
-
- function testApiDisplayToolTitle(){
- $tit=true;
- $titleElement['mainTitle']=$tit;
- ob_start();
- api_display_tool_title($titleElement);
- $res = ob_get_contents();
- ob_end_clean();
- $this->assertEqual($res,'<h3>1</h3>');
- $this->assertTrue(isset($titleElement));
- $this->assertTrue($titleElement['mainTitle']);
- $this->assertPattern('/<h3>1<\/h3>/', $res);
- }/**
- untested
-
-
- function testApiDisplayToolViewOption(){
-
- $res=api_display_tool_view_option();
-
- }*/
-
-
- function testApiDisplayArray(){
- global $info_array;
- ob_start();
- api_display_array($info_array);
- $res = ob_get_contents();
- ob_end_clean();
- $this->assertNotEqual($res,'');
- $this->assertPattern('/<div class="normal-message">.*<\/div>/',$res);
- }
-
- function testApiDisplayDebugInfo(){
- $message = "mensaje de error"; // siempre que puedas, te conviene probar con valores creados al azar
- ob_start();
- api_display_debug_info($message);
- $res = ob_get_contents();
- ob_end_clean();
- $this->assertNotEqual($res,'');
- $this->assertPattern('/<i>Debug info<\/i>.*/',$res);
- }
-
- /**
- function is_allowed_to_edit() is deprecated and have been instead by
- * api_is_allowed_to_edit()
- */
-
- function testApiIsAllowedToEdit(){
- $is_courseAdmin=false;
- $res=api_is_allowed_to_edit($tutor=false,$scoach=false);
- $this->assertTrue($res);
- $this->assertTrue(isset($is_courseAdmin));
- //$this->assertTrue($is_courseAdmin);
-
- }
-
- function testApiIsAllowed(){
- global $_course;
- global $_user;
- $_user['user_id']=1;
- $_course['code']=0;
- $tool= true;
- $action= api_get_setting();
- $res=api_is_allowed($task_id=0);
- $this->assertFalse($res);
- $this->assertFalse($action);
- $this->assertTrue($_user['user_id']);
- $this->assertFalse($_course['code']);
-
- }
-
- function testApiIsAnonymous(){
- global $_user, $use_anonymous;
- $_user['is_anonymous']=False;
- $res=api_is_anonymous($user_id=null, $db_check=false);
- $this->assertFalse($res);
- $this->assertFalse(isset($user_id));
- $this->assertTrue(isset($_user['is_anonymous']));
- $this->assertFalse($use_anonymous);
- $this->assertFalse($db_check);
-
- }
-
-
- /**
- * test was stopped because of errors in the interpretation of
- * the role, find out more details.
-
-
- function testApiNotAllowed(){
- $res=api_not_allowed($sprint_headers=false);
- $this->assertFalse($res);
- }*/
-
-
- function testConvertMysqlDate(){
- $result=false;
- $myrow = Database::fetch_array($result);
- $last_post_datetime = $myrow['end_date'];
-
- $res=convert_mysql_date($last_post_datetime);
- $this->assertTrue($res);
- $this->assertFalse($result);
- $this->assertFalse($myrow);
-
- }
-
- function testApiGetDatetime(){
- $res=api_get_datetime($time=null);
- $this->assertTrue($res);
- $this->assertFalse(isset($time));
-
- }
-
- function testApiGetItemVisibility(){
- $_course= -1;
- $tool = Database::escape_string($tool);
- $id=Database::escape_string($id);
- $_course['dbName']=false;
- $res =api_get_item_visibility($_course,$tool,$id);
- $this->assertTrue($res);
- $this->assertFalse(isset($_course['dbName']));
-
- }/*
-
- * function very complex and analized test is empty
- *
- function testApiItemPropertyUpdate(){
- $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);
-
- }
-
- function testApiGetLanguagesCombo(){
- $platformLanguage = api_get_setting('platformLanguage');
- $language_list = api_get_languages();
- $res=api_get_languages_combo($name="language");
- $this->assertTrue($res);
- $this->assertTrue($platformLanguage);
- $this->assertTrue($language_list['name']);
-
- }
-
- function testApiDisplayLanguageForm(){
-
- $res=api_display_language_form($hide_if_no_choice=false);
- $this->assertFalse($res);
-
- }
-
- function testApiGetLanguages(){
- $result=true;
- $row = mysql_fetch_array($result);
- $res= api_get_languages();
- $this->assertTrue($res);
- $this->assertFalse($row);
-
- }
- function testApiGetLanguageIsocode(){
- $sql= true;
- $var=api_sql_query($sql,_FILE_,_LINE_);
- $res=api_get_language_isocode();
- $this->assertFalse($res);
- $this->assertTrue(isset($var));
-
- }
- */
- function testApiGetThemes(){
- $cssdir= api_get_path(SYS_PATH).'main/css/';
- $res=api_get_themes();
- $this->assertTrue($res);
- $this->assertTrue($cssdir);
-
- }
- function testApiDispHtmlArea(){
- $name = 'name';
- global $_configuration, $_course, $fck_attribute;
- ob_start();
- api_disp_html_area($name, $content ='', $height='', $width='100%', $optAttrib='');
- $res = ob_get_contents();
- ob_end_clean();
- $this->assertNotEqual($res,'');
-
- }
-
- function testApiReturnHtmlArea(){
- $name = true;
- global $_configuration, $_course, $fck_attribute;
- $res=api_return_html_area($name, $content='', $height='', $width='100%', $optAttrib='');
- $this->assertTrue($res);
-
- }
-
- function testApiSendMail(){
- $to= 'ricardo.rodriguez@dokeos.com';
- $subject='Hola';
- $message="prueba de envio";
- $send_mail=mail();
- $res=api_send_mail($to, $subject, $message, $additional_headers = null, $additional_parameters = null);
- $this->assertTrue($res);
- $this->assertFalse($send_mail);
-
- }
-
- function testApiMaxSortValue(){
- $user=array('user_course_category'=>21, 'user_id'=>1);
- $res= api_max_sort_value($user['user_course_category'],$user['user_id']);
- $this->assertFalse($res);
- $this->assertTrue($user);
-
- }
-
- function testString2Boolean(){
- global $string;
- $res=string_2_boolean($string);
- $this->assertFalse($res);
-
- }
-
- function testApiNumberOfPlugins(){
- global $_plugins;
- $location=2;
- $_plugins[$location]=1;
- $res=api_number_of_plugins($location);
- $this->assertFalse($res);
- $this->assertTrue($_plugins[$location]);
-
- }
-
- function testApiPlugin(){
- global $_plugins;
- $location=2;
- $_plugins[$location]=1;
- $res1 = api_plugin($location);
- $this->assertFalse($res1);
- $this->assertTrue($_plugins[$location]);
-
- }
- function testApiDeleteSetting(){
-
- }
-
- function testApiDeleteCategorySettings(){
- $c= false;
- $res = api_delete_category_settings($c,$a=1);
- $this->assertFalse($res);
- }
-
- function testApiAddSetting(){
- $sk=null;
- $type='textfield';
- $c=null;
- $title='';
- $com='';
- $sc=null;
- $skt=null;
- $a=1;
- $v=0;
- $va=array('val'=>10, 'var'=>'name');
- $res= api_add_setting($va['val'],$va['var'],null,null,null,null,null,null,null,null,null);
- $this->assertFalse($res);
- }
-
- function testApiIsCourseVisibleForUser(){
- $res = api_is_course_visible_for_user($userid=null, $cid=null);
- $this->assertFalse($res);
-
- }
-
- function testApiIsElementInTheSession(){
- $_tool['tool'] = 'TOOL_SURVEY';
- $_id['element_id']=3;
- $res = api_is_element_in_the_session($_tool['tool'], $_id['element_id'], $session_id=null);
- $this->assertFalse($res);
- $this->assertTrue((isset($_tool['tool'],$_id['element_id'])));
- }
-
- function testReplaceDangerousChar(){
- $filename =ereg_replace("\.+$", "", substr(strtr(ereg_replace(
- "[^!-~\x80-\xFF]", "_", trim($filename)), '\/:*?"<>|\'',
- /* Keep C1 controls for UTF-8 streams */ '-----_---_'), 0, 250));
- $res = replace_dangerous_char($filename, $strict = 'loose');
- $this->assertEqual($res,$filename, $message = 'no se pudo');
- }
-
- function testApiRequestUri(){
- $res = api_request_uri();
- $this->assertTrue($res);
- }
-
- function testApiCreateIncludePathSetting(){
-
- $res=api_create_include_path_setting();
- $this->assertTrue($res);
- }
-
- function testApiGetCurrentAccessUrlId(){
-
- $res=api_get_current_access_url_id();
- $this->assertTrue($res);
-
- }
-
- function testApiGetAccessUrlFromUser(){
- $user_id=1;
- $res= api_get_access_url_from_user($user_id);
- $this->assertFalse($res);
-
- }
-
- function testApiGetStatusOfUserInCourse(){
- $id = array(
- 'course_code'=>'211',
- 'user_id'=>'112');
- $res=api_get_status_of_user_in_course($id['course_code'],$id['user_id']);
- $this->assertFalse($res);
- //$this->assertPattern('/\d/',$res);
- }
- function testApiIsInCourse(){
- $_SESSION['_course']['sysCode']=0;
- $res=api_is_in_course($course_code=null);
- $this->assertTrue($res);
- $this->assertTrue(isset($_SESSION['_course']['sysCode']));
- }
-
- function testApiIsInGroup(){
-
- $res=api_is_in_group($group_id=null, $course_code=null);
- $this->assertFalse($res);
- }
-
-
- function testApiIsXmlHttpRequest(){
- $res=api_is_xml_http_request();
- $this->assertTrue(isset($res));
- }
-
- function testApiGetEncryptedPassword(){
- global $userPasswordCrypted;
- $pass= array ('password'=> '2222');
- $res=api_get_encrypted_password($pass['password'],null);
- $this->assertTrue($res);
- $this->assertPattern('/\d/',$res);
-
- }
-
- function testApiIsValidSecretKey(){
- global $_configuration;
- //$_configuration['key']=true;
- $key = array(
- 'original_key_secret'=>'2121212',
- 'security_key'=>'2121212');
- $res = api_is_valid_secret_key($key['original_key_secret'],$key['security_key']);
- $this->assertTrue($_configuration);
- $this->assertFalse($res);
- $this->assertTrue($key);
- $this->assertEqual($key['original_key_secret'],$key['security_key'], $message ='%s');
-
- }
-
- function testApiIsUserOfCourse(){
- $course_id = 1;
- $user_id = 1;
- $tbl_course_rel_user =false;
- $sql='SELECT user_id FROM '.$tbl_course_rel_user.' WHERE course_code="'.Database::escape_string($course_id).'" AND user_id="'.Database::escape_string($user_id).'"';
- $res= api_is_user_of_course($course_id, $user_id);
- $this->assertFalse($res);
- $this->assertFalse($tbl_course_rel_user);
- $this->assertTrue($sql);
-
- }
-
- function testApiIsWindowsOs(){
- $res= api_is_windows_os();
- $this->assertFalse($res);
- }
-
- function testApiUrlToLocalPath(){
- global $url;
- $cond= preg_match(false);
- $res= api_url_to_local_path($url);
- $this->assertFalse($res);
- $this->assertFalse($cond);
- }
-
- function testApiResizeImage(){
- //global $image, $target_width, $target_height;
- $resize = array('image' =>'image.jpg', 'target_width'=>100, 'target_height'=>100);
- $res = api_resize_image($resize['image'],$resize['target_width'],$resize['target_height']);
- $this->assertTrue($res);
- $this->assertWithinMargin($first = 10, $second=20,$margin=200, $message = 'no se pudo redimensionar imagen');
-
- }
-
- function testApiCalculateImageSize(){
- global $image_width, $image_height, $target_width, $target_height;
- $result = array($image_width, $image_height);
- $res = api_calculate_image_size($image_width, $image_height, $target_width, $target_height);
- $this->assertTrue($res);
- $this->assertTrue($result);
-
- }
-
- function testApiGetToolsLists(){
- $tool_list = 'false';
- $res = api_get_tools_lists($my_tool =null);
- $this->assertTrue($res);
- $this->assertTrue($tool_list);
- }
- }
- ?>
|