123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?php
- require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php';
- require_once api_get_path(LIBRARY_PATH).'course.lib.php';
- class TestAddCourse extends UnitTestCase {
- function TestAddCourse() {
- $this->UnitTestCase('Courses creation - main/inc/lib/add_course.lib.inc.test.php');
- }
- function testRegisterCourse() {
- global $_configuration;
- $course = array(
- 'courseSysCode'=> 'testcourse',
- 'courseScreenCode' =>'testcourse',
- 'courseRepository' =>'testcourse',
- 'courseDbName' => $_configuration['db_prefix'].'testcourse',
- 'titular' =>'John Doe',
- 'category' =>'Lang',
- 'title' =>'test course',
- 'course_language' =>'english',
- 'uidCreator'=> '1',
- );
- $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(){
- global $charset;
- $course_title = 'testcourse';
- $res = generate_course_code($course_title);
- $this->assertTrue($res);
- }
- function TestDefineCourseKeys(){
- global $prefixAntiNumber, $_configuration;
- $wantedCode = generate_course_code($wantedCode);
- $res = define_course_keys(generate_course_code($wantedCode), null, null, null,null, null);
- $this->assertTrue($res);
- }
-
- function TestBrowseFolders(){
- $browse = array('path'=>'','file'=>'','media'=>'');
- $res = browse_folders($browse['path'], $browse['files'],$browse['media']);
- $this->assertFalse($res);
- }
-
-
- function TestLang2db(){
- $string = 'test';
- $res = lang2db($string);
- $this->assertTrue($res);
- }
- function TestFillDbCourse(){
- global $_configuration, $_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'];
- $courseRepository = 'testcourse';
- $language = 'english';
- $default_document_array ='testdocument';
- $res = fill_db_course($courseDbName, $courseRepository, $language);
- $this->assertTrue($res === 0);
- }
- function TestString2Binary(){
- $variable = true;
- $res = string2binary($variable);
- $this->assertTrue($res);
- }
- public function TestDeleteCourse(){
- $code = 'testcourse';
- $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);
- }
- }
- }
|