fileManage.lib.test.php 4.3 KB

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