fileManage.lib.test.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. //require_once(api_get_path(LIBRARY_PATH).'classManager.lib.php');
  3. class TestFileManager extends UnitTestCase {
  4. public $fmanager;
  5. public function TestFileManager(){
  6. $this->UnitTestCase ('File Manager library - main/inc/lib/fileManage.lib.test.php');
  7. }
  8. public function setUp(){
  9. $this->fmanager = new FileManager();
  10. }
  11. public function tearDown(){
  12. $this->fmanager = null;
  13. }
  14. //todo public function testUpdatedbInfo
  15. //todo public function testCheckNameExist
  16. //todo public function testMyDelete
  17. //todo public function testRemoveDir
  18. //todo public function testMyRename
  19. //todo public function testMove
  20. //todo public function testCopyDirTo
  21. //todo public function testIndexDir
  22. //todo public function testIndexAndSortDir
  23. //todo public function testFormDirList
  24. //todo public function testMkpath
  25. //todo public function testGetextension
  26. //todo public function testDirsize
  27. //todo public function testListAllDirectories
  28. //todo public function testListAllFiles
  29. //todo public function testCompatLoadFile
  30. //todo public function testSetDefaultSettings
  31. //todo public function testMkdirs
  32. public function testUpdatedbInfo(){
  33. $action ='';
  34. $oldPath ='';
  35. $res = update_db_info($action, $oldPath, $newPath="");
  36. $this->assertNull($res);
  37. //var_dump($res);
  38. }
  39. public function testCheckNameExist(){
  40. $filePath ='';
  41. $res = check_name_exist($filePath);
  42. $this->assertFalse($res);
  43. $this->assertTrue(is_bool($res));
  44. $this->assertTrue($res === false);
  45. //var_dump($res);
  46. }
  47. public function testMyDelete(){
  48. $file='';
  49. $res = my_delete($file);
  50. $this->assertFalse($res);
  51. $this->assertTrue(is_bool($res));
  52. $this->assertTrue($res===false);
  53. //var_dump($res);
  54. }
  55. public function testRemoveDir(){
  56. $dir='';
  57. $res = removeDir($dir);
  58. $this->assertTrue(is_bool($res));
  59. $this->assertFalse($res === true);
  60. //var_dump($res);
  61. }
  62. public function testMyRename(){
  63. $filePath ='document/';
  64. $newFileName='';
  65. $res = my_rename($filePath, $newFileName);
  66. $this->assertTrue(is_bool($res));
  67. $this->assertTrue($res === false);
  68. //var_dump($res);
  69. }
  70. public function testMove(){
  71. $source ='';
  72. $target ='';
  73. $res = move($source, $target);
  74. $this->assertTrue(is_bool($res));
  75. $this->assertTrue($res === false);
  76. $this->assertFalse($res);
  77. //var_dump($res);
  78. }
  79. public function testCopyDirTo(){
  80. $origDirPath=api_get_path(SYS_COURSE_PATH).'document/audio';
  81. $destination=api_get_path(SYS_COURSE_PATH).'document/flash/audio';
  82. $res = copyDirTo($origDirPath, $destination, $move = false);
  83. $this->assertTrue($res===null);
  84. $this->assertNull($res);
  85. }
  86. public function testFormDirList(){
  87. $sourceType = '';
  88. $sourceComponent = '';
  89. $command = '';
  90. $baseWorkDir = api_get_path(SYS_COURSE_PATH).'document/';
  91. $res = form_dir_list($sourceType, $sourceComponent, $command, $baseWorkDir);
  92. $this->assertTrue($res);
  93. $this->assertTrue(is_string($res));
  94. //var_dump($res);
  95. }
  96. public function testGetextension(){
  97. $filename='documents';
  98. $res =getextension($filename);
  99. $this->assertTrue($res);
  100. $this->assertTrue(is_array($res));
  101. }
  102. public function testDirsize(){
  103. $root='';
  104. $res =dirsize($root,$recursive=true);
  105. $this->assertFalse($res);
  106. $this->assertTrue(is_numeric($res));
  107. $this->assertTrue($res ===0);
  108. //var_dump($res);
  109. }
  110. public function testListAllDirectories(){
  111. $path=api_get_path(SYS_COURSE_PATH).'document/';
  112. $res = $this->fmanager->list_all_directories($path);
  113. if(!is_null($res)) {
  114. $this->assertTrue($res);
  115. $this->assertTrue(is_array($res));
  116. }
  117. //var_dump($res);
  118. }
  119. public function testListAllFiles(){
  120. $dirArray = array('COURSETEST, document, images');
  121. $res = $this->fmanager->list_all_files($dirArray);
  122. $this->assertFalse($res);
  123. $this->assertTrue(is_array($res));
  124. $this->assertTrue($res === array());
  125. //var_dump($res);
  126. }
  127. public function testCompatLoadFile(){
  128. $file_name='README.txt';
  129. $res = $this->fmanager->compat_load_file($file_name);
  130. $this->assertTrue(is_string($res));
  131. //var_dump($res);
  132. }
  133. public function testSetDefaultSettings(){
  134. global $_course, $_configuration;
  135. $upload_path=api_get_path(SYS_COURSE_PATH);
  136. $filename='index.html';
  137. $glue_table = $_course['dbName'].'.document';
  138. $res = $this->fmanager->set_default_settings($upload_path, $filename, $filetype="file", $glue_table, $default_visibility='v');
  139. $this->assertNull($res);
  140. //var_dump($res);
  141. }
  142. }
  143. ?>