commit
8b54edf958
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,184 @@ |
||||
<?php |
||||
require_once(api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php'); |
||||
require_once(api_get_path(SYS_CODE_PATH).'newscorm/scorm.class.php'); |
||||
|
||||
class TestScorm extends UnitTestCase { |
||||
/* |
||||
function testScorm() { |
||||
//ob_start(); |
||||
$course_code = 'COURSETEST'; |
||||
$resource_id = 1; |
||||
$user_id = 1; |
||||
$obj = new scorm($course_code, $resource_id, $user_id); |
||||
$res = $obj->scorm($course_code=null,$resource_id=null,$user_id=null); |
||||
$this->assertTrue(is_null($res)); |
||||
//ob_end_clean(); |
||||
//var_dump($res); |
||||
}*/ |
||||
|
||||
function testOpen() { |
||||
//ob_start(); |
||||
$id = 1; |
||||
$res = scorm::open($id); |
||||
$this->assertTrue(is_null($res)); |
||||
//ob_end_clean(); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
function testParseManifest() { |
||||
//ob_start(); |
||||
$course_code = 'COURSETEST'; |
||||
$resource_id = 1; |
||||
$user_id = 1; |
||||
$obj = new scorm($course_code, $resource_id, $user_id); |
||||
$res = $obj->parse_manifest($file=''); |
||||
$this->assertTrue(is_null($res)); |
||||
//ob_end_clean(); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
function testImportManifest() { |
||||
//ob_start(); |
||||
$course_code = 'COURSETEST'; |
||||
$resource_id = 1; |
||||
$user_id = 1; |
||||
$obj = new scorm($course_code, $resource_id, $user_id); |
||||
$res = $obj->import_manifest($course_code = 'COURSETEST'); |
||||
$this->assertTrue(is_null($res)); |
||||
//ob_end_clean(); |
||||
//var_dump($res); |
||||
} |
||||
/* |
||||
function testImportLocalPackage() { |
||||
//ob_start(); |
||||
$course_code = 'COURSETEST'; |
||||
$resource_id = 1; |
||||
$user_id = 1; |
||||
$obj = new scorm($course_code, $resource_id, $user_id); |
||||
$res = $obj->import_local_package($file_path,$current_dir=''); |
||||
$this->assertTrue(is_string($res)); |
||||
//ob_end_clean(); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
function testImportPackage() { |
||||
//ob_start(); |
||||
$course_code = 'COURSETEST'; |
||||
$resource_id = 1; |
||||
$user_id = 1; |
||||
$obj = new scorm($course_code, $resource_id, $user_id); |
||||
$res = $obj->import_package($zip_file_info,$current_dir = ''); |
||||
$this->assertTrue(is_string($res)); |
||||
//ob_end_clean(); |
||||
//var_dump($res); |
||||
}*/ |
||||
|
||||
function testSetProximity() { |
||||
//ob_start(); |
||||
$course_code = 'COURSETEST'; |
||||
$resource_id = 1; |
||||
$user_id = 1; |
||||
$obj = new scorm($course_code, $resource_id, $user_id); |
||||
$res = $obj->set_proximity($proxy=''); |
||||
$this->assertTrue(is_bool($res)); |
||||
//ob_end_clean(); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
function testSetTheme() { |
||||
//ob_start(); |
||||
$course_code = 'COURSETEST'; |
||||
$resource_id = 1; |
||||
$user_id = 1; |
||||
$obj = new scorm($course_code, $resource_id, $user_id); |
||||
$res = $obj->set_theme($theme='Chamilo'); |
||||
$this->assertTrue(is_bool($res)); |
||||
//ob_end_clean(); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
function testSetPreviewImage() { |
||||
//ob_start(); |
||||
$course_code = 'COURSETEST'; |
||||
$resource_id = 1; |
||||
$user_id = 1; |
||||
$obj = new scorm($course_code, $resource_id, $user_id); |
||||
$res = $obj->set_preview_image($preview_image=''); |
||||
$this->assertTrue(is_bool($res)); |
||||
//ob_end_clean(); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
function testSetAuthor() { |
||||
//ob_start(); |
||||
$course_code = 'COURSETEST'; |
||||
$resource_id = 1; |
||||
$user_id = 1; |
||||
$obj = new scorm($course_code, $resource_id, $user_id); |
||||
$res = $obj->set_author($author=''); |
||||
$this->assertTrue(is_bool($res)); |
||||
//ob_end_clean(); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
function testSetMaker() { |
||||
//ob_start(); |
||||
$course_code = 'COURSETEST'; |
||||
$resource_id = 1; |
||||
$user_id = 1; |
||||
$obj = new scorm($course_code, $resource_id, $user_id); |
||||
$res = $obj->set_maker($maker=''); |
||||
$this->assertTrue(is_bool($res)); |
||||
//ob_end_clean(); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
function testExportZip() { |
||||
//ob_start(); |
||||
$course_code = 'COURSETEST'; |
||||
$resource_id = 1; |
||||
$user_id = 1; |
||||
$obj = new scorm($course_code, $resource_id, $user_id); |
||||
$res = $obj->export_zip($lp_id=null); |
||||
$this->assertTrue(is_bool($res)); |
||||
//ob_end_clean(); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
function testGetResPath() { |
||||
//ob_start(); |
||||
$res = scorm::get_res_path($id=1); |
||||
$this->assertTrue(is_string($res)); |
||||
//ob_end_clean(); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
function testGetResType() { |
||||
//ob_start(); |
||||
$res = scorm::get_res_type($id = 1); |
||||
$this->assertTrue(is_string($res)); |
||||
//ob_end_clean(); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
function testGetTitle() { |
||||
//ob_start(); |
||||
$res = scorm::get_title(); |
||||
$this->assertTrue(is_string($res)); |
||||
//ob_end_clean(); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
function testReimportManifest() { |
||||
ob_start(); |
||||
$course_code = 'COURSETEST'; |
||||
$resource_id = 1; |
||||
$user_id = 1; |
||||
$obj = new scorm($course_code, $resource_id, $user_id); |
||||
$res = $obj->reimport_manifest($course = 'COURSETEST',$lp_id=null,$imsmanifest_path=''); |
||||
$this->assertTrue(is_bool($res)); |
||||
ob_end_clean(); |
||||
//var_dump($res); |
||||
} |
||||
} |
||||
?> |
@ -0,0 +1,197 @@ |
||||
<?php |
||||
// $Id: setup.inc.php 2010-02-17 12:07:00Z aportugal $ |
||||
|
||||
/* For licensing terms, see /chamilo_license.txt */ |
||||
/** |
||||
============================================================================== |
||||
* This is the settings file load than need some functions |
||||
* |
||||
* It load: |
||||
* - require_once |
||||
* - constructs |
||||
* - creation course |
||||
* - session |
||||
* - api_allow_edit |
||||
* - api_session |
||||
* |
||||
* |
||||
* @todo rewrite code to separate display, logic, database code |
||||
* @package chamilo.main |
||||
============================================================================== |
||||
*/ |
||||
|
||||
/** |
||||
* @todo shouldn't these settings be moved to the test_suite.php. |
||||
* if these are really configuration then we can make require_once in each tests. |
||||
* @todo use this file to load the setup in each file test. |
||||
* @todo check for duplication of require with test_suite.php |
||||
*/ |
||||
/* |
||||
============================================================================== |
||||
INIT SECTION |
||||
============================================================================== |
||||
*/ |
||||
ini_set('memory_limit','256M'); |
||||
ini_set('max_execution_time','0'); |
||||
|
||||
/* |
||||
----------------------------------------------------------- |
||||
Included libraries |
||||
----------------------------------------------------------- |
||||
*/ |
||||
$maindir = dirname(__FILE__).'/../main/'; |
||||
$incdir = dirname(__FILE__).'/../main/inc/'; |
||||
$libdir = dirname(__FILE__).'/../main/inc/lib/'; |
||||
|
||||
/**This global.inc file need be loaded once time*/ |
||||
//require_once $incdir.'global.inc.php'; |
||||
|
||||
/**Files inside '/../main' */ |
||||
require_once $maindir.'permissions/permissions_functions.inc.php'; |
||||
require_once $maindir.'admin/calendar.lib.php'; |
||||
require_once $maindir.'admin/statistics/statistics.lib.php'; |
||||
require_once $maindir.'dropbox/dropbox_class.inc.php'; |
||||
require_once $maindir.'dropbox/dropbox_functions.inc.php'; |
||||
require_once $maindir.'survey/survey.lib.php'; |
||||
require_once $maindir.'exercice/export/scorm/scorm_classes.php'; |
||||
require_once $maindir.'exercice/export/qti2/qti2_classes.php'; |
||||
require_once $maindir.'exercice/export/exercise_import.inc.php'; |
||||
require_once $maindir.'exercice/exercise_result.class.php'; |
||||
require_once $maindir.'exercice/answer.class.php'; |
||||
require_once $maindir.'exercice/exercise.class.php'; |
||||
require_once $maindir.'exercice/fill_blanks.class.php'; |
||||
require_once $maindir.'exercice/freeanswer.class.php'; |
||||
require_once $maindir.'forum/forumfunction.inc.php'; |
||||
|
||||
/**Files inside '/../main/lib/' */ |
||||
require_once $libdir.'urlmanager.lib.php'; |
||||
require_once $libdir.'fileDisplay.lib.php'; |
||||
require_once $libdir.'groupmanager.lib.php'; |
||||
require_once $libdir.'course.lib.php'; |
||||
require_once $libdir.'usermanager.lib.php'; |
||||
require_once $libdir.'social.lib.php'; |
||||
require_once $libdir.'xht.lib.php'; |
||||
require_once $libdir.'xmd.lib.php'; |
||||
require_once $libdir.'formvalidator/FormValidator.class.php'; |
||||
require_once $libdir.'exercise_show_functions.lib.php'; |
||||
require_once $libdir.'fileManage.lib.php'; |
||||
|
||||
/**This files need be inside a buffering to clean the objects*/ |
||||
ob_start(); |
||||
require_once $libdir.'main_api.lib.php'; |
||||
require_once $libdir.'course_document.lib.php'; |
||||
require_once $libdir.'banner.lib.php'; |
||||
require_once $libdir.'add_course.lib.inc.php'; |
||||
require_once $incdir.'tool_navigation_menu.inc.php'; |
||||
require_once $incdir.'banner.inc.php'; |
||||
require_once $libdir.'geometry.lib.php'; |
||||
ob_end_clean(); |
||||
|
||||
/**Problem with this file to test objects*/ |
||||
//require_once $maindir.'exercice/exercise.lib.php'; |
||||
|
||||
/* |
||||
----------------------------------------------------------- |
||||
Table definitions |
||||
----------------------------------------------------------- |
||||
*/ |
||||
$table_course = Database::get_main_table(TABLE_MAIN_COURSE); |
||||
$course_table = Database::get_main_table(TABLE_MAIN_COURSE); |
||||
$course_cat_table = Database::get_main_table(TABLE_MAIN_CATEGORY); |
||||
|
||||
/* |
||||
============================================================================== |
||||
MAIN CODE |
||||
============================================================================== |
||||
*/ |
||||
global $_configuration, $_user, $_course, $cidReq; |
||||
$cidReq = 'COURSETEST'; |
||||
|
||||
/* |
||||
----------------------------------------------------------- |
||||
Check if the course exists |
||||
----------------------------------------------------------- |
||||
*/ |
||||
$sql = "SELECT code FROM $table_course WHERE code = '$cidReq' "; |
||||
$rs = Database::query($sql, __FILE__, __LINE__); |
||||
$row = Database::fetch_row($rs); |
||||
|
||||
/* |
||||
----------------------------------------------------------- |
||||
Create the course COURSETEST |
||||
----------------------------------------------------------- |
||||
*/ |
||||
if (empty($row[0])) { |
||||
// create a course |
||||
$course_datos = array( |
||||
'wanted_code'=> $cidReq, |
||||
'title'=>$cidReq, |
||||
'tutor_name'=>'John Doe', |
||||
'category_code'=>'LANG', |
||||
'course_language'=>'spanish', |
||||
'course_admin_id'=>'001', |
||||
'db_prefix'=> $_configuration['db_prefix'], |
||||
'firstExpirationDelay'=>'999' |
||||
); |
||||
$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']); |
||||
} |
||||
|
||||
|
||||
$sql = "SELECT course.*, course_category.code faCode, course_category.name faName |
||||
FROM $course_table |
||||
LEFT JOIN $course_cat_table |
||||
ON course.category_code = course_category.code |
||||
WHERE course.code = '$cidReq'"; |
||||
|
||||
$result = Database::query($sql,__FILE__,__LINE__); |
||||
|
||||
/* |
||||
----------------------------------------------------------- |
||||
Create the session |
||||
----------------------------------------------------------- |
||||
*/ |
||||
if (Database::num_rows($result)>0) { |
||||
$cData = Database::fetch_array($result); |
||||
$_cid = $cData['code' ]; |
||||
$_course = array(); |
||||
$_course['id' ] = $cData['code' ]; //auto-assigned integer |
||||
$_course['name' ] = $cData['title' ]; |
||||
$_course['official_code'] = $cData['visual_code' ]; // use in echo |
||||
$_course['sysCode' ] = $cData['code' ]; // use as key in db |
||||
$_course['path' ] = $cData['directory' ]; // use as key in path |
||||
$_course['dbName' ] = $cData['db_name' ]; // use as key in db list |
||||
$_course['dbNameGlu' ] = $_configuration['table_prefix'] . $cData['db_name'] . $_configuration['db_glue']; // use in all queries |
||||
$_course['titular' ] = $cData['tutor_name' ]; |
||||
$_course['language' ] = $cData['course_language' ]; |
||||
$_course['extLink' ]['url' ] = $cData['department_url' ]; |
||||
$_course['extLink' ]['name'] = $cData['department_name' ]; |
||||
$_course['categoryCode'] = $cData['faCode' ]; |
||||
$_course['categoryName'] = $cData['faName' ]; |
||||
$_course['visibility' ] = $cData['visibility' ]; |
||||
$_course['subscribe_allowed'] = $cData['subscribe' ]; |
||||
$_course['unubscribe_allowed'] = $cData['unsubscribe' ]; |
||||
|
||||
api_session_register('_cid'); |
||||
api_session_register('_course'); |
||||
} |
||||
|
||||
/* |
||||
----------------------------------------------------------- |
||||
Load the session |
||||
----------------------------------------------------------- |
||||
*/ |
||||
$_SESSION['_user']['user_id'] = 1; |
||||
$_SESSION['is_courseAdmin'] = 1; |
||||
$_SESSION['show'] = showall; |
||||
|
||||
/* |
||||
----------------------------------------------------------- |
||||
Load the user |
||||
----------------------------------------------------------- |
||||
*/ |
||||
$_user['user_id'] = $_SESSION['_user']['user_id']; |
||||
|
||||
|
@ -0,0 +1,165 @@ |
||||
<?php |
||||
// $Id: teardown.inc.php 2010-02-17 14:20:00Z aportugal $ |
||||
|
||||
/* For licensing terms, see /chamilo_license.txt */ |
||||
/** |
||||
============================================================================== |
||||
* This is the settings file destroy than need some functions to finish the test |
||||
* |
||||
* It destroy: |
||||
* - require_once |
||||
* - constructs |
||||
* - creation course |
||||
* - session |
||||
* - api_allow_edit |
||||
* - api_session |
||||
* |
||||
* |
||||
* @todo rewrite code to separate display, logic, database code |
||||
* @package chamilo.main |
||||
============================================================================== |
||||
*/ |
||||
|
||||
/** |
||||
* @todo shouldn't these settings be moved to the test_suite.php. |
||||
* if these are really configuration then we can make require_once in each tests. |
||||
* @todo use this file to destroy the setup in each file test. |
||||
* @todo check for duplication of require with test_suite.php |
||||
*/ |
||||
|
||||
/* |
||||
----------------------------------------------------------- |
||||
Included libraries |
||||
----------------------------------------------------------- |
||||
*/ |
||||
require_once(api_get_path(LIBRARY_PATH).'course.lib.php'); |
||||
|
||||
/* |
||||
============================================================================== |
||||
MAIN CODE |
||||
============================================================================== |
||||
*/ |
||||
$code = 'COURSETEST'; |
||||
$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); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$dirname = api_get_path(SYS_LANG_PATH); |
||||
$perm_dir = substr(sprintf('%o', fileperms($dirname)), -4); |
||||
if ($perm_dir != '0777') { |
||||
$msg = "Error"; |
||||
$this->assertTrue(is_string($msg)); |
||||
} else { |
||||
$path = $dirname.'upload'; |
||||
$filemode = '0777'; |
||||
$res = api_chmod_R($path, $filemode); |
||||
unlink($path); |
||||
$this->assertTrue($res || IS_WINDOWS_OS); // We know, it does not work for Windows. |
||||
} |
||||
/* |
||||
function testApiIsAllowed(){ |
||||
global $_course, $_user; |
||||
$tool= 'full'; |
||||
$action = 'delete'; |
||||
$res=api_is_allowed($tool, $action, $task_id=0); |
||||
if(!is_bool($res)){ |
||||
$this->assertTrue(is_null($res)); |
||||
} |
||||
$this->assertTrue($action); |
||||
$this->assertTrue($_user['user_id']); |
||||
} |
||||
|
||||
|
||||
function testApiNotAllowed(){ |
||||
ob_start(); |
||||
//api_not_allowed($print_headers = false); |
||||
$res = ob_get_contents(); |
||||
$this->assertEqual($res,''); |
||||
ob_end_clean(); |
||||
} |
||||
|
||||
function testApiIsAllowedToCreateCourse() { |
||||
$res=api_is_allowed_to_create_course(); |
||||
if(!is_bool($res)){ |
||||
$this->assertTrue(is_null($res)); |
||||
} |
||||
} |
||||
|
||||
function testApiIsCoach(){ |
||||
global $_user; |
||||
global $sessionIsCoach; |
||||
$_user['user_id']=2; |
||||
$sessionIsCoach=Database::store_result($result=false); |
||||
$res=api_is_coach(); |
||||
$this->assertTrue(is_bool($res)); |
||||
//var_dump($res); |
||||
$this->assertTrue($_user['user_id']); |
||||
$this->assertTrue(is_array($sessionIsCoach)); |
||||
//var_dump($sessionIsCoach); |
||||
} |
||||
|
||||
function testApiIsSessionAdmin(){ |
||||
global $_user; |
||||
$_user['status']=true; |
||||
$res=api_is_session_admin(); |
||||
$this->assertTrue(is_bool($res)); |
||||
$this->assertTrue(is_array($_user)); |
||||
//var_dump($_user); |
||||
|
||||
} |
||||
|
||||
|
||||
function testApiIsCourseCoach() { |
||||
$res=api_is_course_coach(); |
||||
if(!is_bool($res)){ |
||||
$this->assertTrue(is_null($res)); |
||||
} |
||||
} |
||||
|
||||
function testApiIsSessionAdmin(){ |
||||
global $_user; |
||||
$_user['status']=true; |
||||
$res=api_is_session_admin(); |
||||
$this->assertTrue(is_bool($res)); |
||||
$this->assertTrue(is_array($_user)); |
||||
//var_dump($_user); |
||||
|
||||
} |
||||
|
||||
function testApiNotAllowed(){ |
||||
ob_start(); |
||||
//api_not_allowed($print_headers = false); |
||||
$res = ob_get_contents(); |
||||
$this->assertEqual($res,''); |
||||
ob_end_clean(); |
||||
} |
||||
|
||||
function testApiSessionDestroy(){ |
||||
if (!headers_sent()) { |
||||
$res=api_session_destroy(); |
||||
} |
||||
$this->assertTrue(is_null($res)); |
||||
//var_dump($res); |
||||
} |
||||
|
||||
function testApiSessionStart(){ |
||||
if (!headers_sent()) { |
||||
$res = api_session_start($already_sintalled=true); |
||||
} |
||||
$this->assertTrue(is_null($res)); |
||||
//var_dump($res); |
||||
} |
||||
*/ |
Loading…
Reference in new issue