fileManager.lib.test.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 Display Manager');
  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->assertTrue(is_null($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 ='documents';
  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='';
  81. $destination='';
  82. $res = copyDirTo($origDirPath, $destination, $move=true);
  83. $this->assertTrue($res===null);
  84. $this->assertNull($res);
  85. }
  86. public function testFormDirList(){
  87. $sourceType='';
  88. $sourceComponent='';
  89. $command='';
  90. $baseWorkDir='';
  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='/var/www/path/';
  112. $res = $this->fmanager->list_all_directories($path);
  113. $this->assertFalse($res);
  114. $this->assertTrue(is_null($res));
  115. //var_dump($res);
  116. }
  117. public function testListAllFiles(){
  118. $dirArray='documents';
  119. $res = $this->fmanager->list_all_files($dirArray);
  120. $this->assertFalse($res);
  121. $this->assertTrue(is_null($res));
  122. $this->assertTrue($res ===null);
  123. //var_dump($res);
  124. }
  125. public function testCompatLoadFile(){
  126. $file_name='images';
  127. $res = $this->fmanager->compat_load_file($file_name);
  128. $this->assertFalse($res);
  129. $this->assertTrue(is_bool($res));
  130. //var_dump($res);
  131. }
  132. public function testSetDefaultSettings(){
  133. $upload_path='/var/www/path/ruta';
  134. $filename='doc';
  135. $glued_table='xxx';
  136. $res = $this->fmanager->set_default_settings($upload_path, $filename, $filetype="file", $glued_table, $default_visibility='v');
  137. $this->assertTrue(is_null($res));
  138. //var_dump($res);
  139. }
  140. }
  141. ?>