123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437 |
- <?php
- require_once(api_get_path(SYS_CODE_PATH).'work/work.lib.php');
- require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
- class TestWork extends UnitTestCase {
-
-
- function testcreate_unexisting_work_directory() {
- $path_name = api_get_path(SYS_COURSE_PATH);
- $base_work_dir=$path_name.'testing/';
- $desired_dir_name= $path_name.'testing';
- $res=create_unexisting_work_directory($base_work_dir,$desired_dir_name);
- $this->assertTrue(is_bool($res));
- }
-
-
-
- function testbuild_work_directory_selector() {
- $folders=array();
- $curdirpath='';
- $group_dir='';
- $res=build_work_directory_selector($folders,$curdirpath,$group_dir='');
- $this->assertTrue(is_string($res));
-
- }
-
- function testbuild_work_move_to_selector() {
- $folders=array();
- $curdirpath='';
- $move_file='';
- $group_dir='';
- $res=build_work_move_to_selector($folders,$curdirpath,$move_file,$group_dir='');
- $this->assertTrue(is_string($res));
-
- }
- function testconvert_date_to_array() {
- $date=date('d/m/Y',time());
- $group=array();
- $res=convert_date_to_array($date,$group);
- $this->assertTrue(is_array($res));
-
- }
-
- function testconvert_date_to_number() {
- $default='2008-10-06 12:45:00';
- $res=convert_date_to_number($default);
- $this->assertTrue(is_numeric($res));
-
- }
-
- function testcount_dir() {
- $path_name = api_get_path(SYS_COURSE_PATH);
- $path_dir=$path_name;
- $recurse=0;
- ob_start();
- $res=count_dir($path_dir, $recurse);
- $this->assertTrue(is_array($res));
- ob_end_clean();
-
- }
-
- function testcreate_group_date_select() {
- $res=create_group_date_select($prefix='');
- $this->assertTrue(is_array($res));
-
- }
-
- function testdirectory_to_array() {
- $path_name = api_get_path(SYS_PATH);
- $directory= $path_name;
- $res=directory_to_array($directory);
- $this->assertTrue(is_array($res));
-
- }
-
- function testdisplay_action_links() {
- $cur_dir_path='';
- $always_show_tool_options=1;
- $always_show_upload_form=1;
- ob_start();
- $res=display_action_links($cur_dir_path, $always_show_tool_options, $always_show_upload_form);
- $this->assertTrue(is_null($res));
- ob_end_clean();
-
- }
-
- function testdisplay_default_visibility_form() {
- $uploadvisibledisabled='';
- ob_start();
- $res=display_default_visibility_form($uploadvisibledisabled);
- $this->assertTrue(is_null($res));
- ob_end_clean();
-
- }
-
- function testdisplay_student_publications_list() {
- global $charset,$timeNoSecFormat,$dateFormatShort,$gradebook,$dateFormatLong;
- $work_dir='';
- $sub_course_dir='';
- $currentCourseRepositoryWeb='';
- $link_target_parameter='';
- $origin='learnpath';
- $add_in_where_query='';
- ob_start();
- $res=display_student_publications_list($work_dir,$sub_course_dir,$currentCourseRepositoryWeb, $link_target_parameter, $dateFormatLong, $origin,$add_in_where_query='');
- $this->assertTrue(is_null($res));
- ob_end_clean();
-
- }
-
- function testdisplay_tool_options() {
- global $charset, $group_properties,$gradebook,$base_work_dir;
- $uploadvisibledisabled='';
- $origin='';
- $cur_dir_path='';
- $cur_dir_path_url='';
- ob_start();
- $res=display_tool_options($uploadvisibledisabled, $origin,$base_work_dir,$cur_dir_path,$cur_dir_path_url);
- $this->assertTrue(is_null($res));
- ob_end_clean();
-
- }
-
- function testdisplay_user_link() {
- global $_otherusers;
- $user_id=1;
- $name='';
- $res=display_user_link($user_id, $name='');
- $this->assertTrue(is_string($res));
-
- }
-
- function testget_date_from_group() {
- $group='';
- $res=get_date_from_group($group);
- $this->assertTrue(is_string($res));
-
- }
-
- function testget_parent_directories() {
- $my_cur_dir_path='';
- $res=get_parent_directories($my_cur_dir_path);
- $this->assertTrue(is_array($res));
-
- }
-
- function testget_subdirs_list() {
- $path_name = api_get_path(SYS_PATH);
- $basedir = $path_name.'/';
- $dh = opendir($basedir);
- $entry = readdir($dh);
- $dirs_list[] = $entry;
- $res=get_subdirs_list($basedir='',$recurse=0);
- $this->assertTrue(is_numeric($res));
- $this->assertTrue(is_array($dirs_list));
-
-
- }
-
- function testget_work_id() {
- global $cidReq;
- $path_name = api_get_path(SYS_PATH);
- $path=$path_name.$cidReq;
- $res=get_work_id($path);
- $this->assertTrue(is_bool($res));
-
- }
-
- function testget_work_path() {
- $id=1;
- $res=get_work_path($id);
- $this->assertTrue(is_numeric($res));
-
- }
-
- function testinsert_all_directory_in_course_table() {
- $path_name = api_get_path(SYS_COURSE_PATH);
- $base_work_dir=$path_name.'work/testing';
- $dir_to_array =directory_to_array($base_work_dir,true);
- $res=insert_all_directory_in_course_table($base_work_dir);
- $this->assertTrue(is_null($res));
-
- }
-
- function testis_subdir_of() {
- $path_name = api_get_path(SYS_COURSE_PATH);
- $subdir=$path_name.'work/testing';
- $basedir=$path_name;
- $res=is_subdir_of($subdir,$basedir);
- $this->assertTrue(is_numeric($res));
-
- }
-
- function testto_javascript_work() {
- $res=to_javascript_work();
- $this->assertTrue(is_string($res));
-
- }
-
- function testtwo_digits() {
- $number=1;
- $res=two_digits($number);
- $this->assertTrue(is_numeric($res));
-
- }
-
- function testupdate_dir_name() {
- global $base_work_dir;
- $path='';
- $new_name='';
- $res=update_dir_name($path,$new_name);
- $this->assertTrue(is_null($res));
-
- }
-
- function testupdate_work_url() {
- $id=1;
- $path_name = api_get_path(SYS_COURSE_PATH);
- $new_path=$path_name.'work/testing';
- $res=update_work_url($id,$new_path);
- $this->assertTrue(is_numeric($res));
-
- }
-
-
- function testdel_dir() {
- global $cidReq;
- $path_name = api_get_path(SYS_PATH);
- $base_work_dir=$path_name.$cidReq.'work/testing';
- $dir= $path_name.'testing/';
- $id=-1;
- $res=del_dir($base_work_dir,$dir,$id);
- $this->assertTrue(is_numeric($res));
-
- }
-
-
-
- public function testDeleteCourse() {
- $code = 'COURSEX';
- $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);
- }
- session_destroy();
- }
- }
- ?>
|