dropbox_class.inc.test.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <?php
  2. class TestDropbox extends UnitTestCase {
  3. public $ddropboxwork;
  4. public $ddropboxsentwork;
  5. public $dperson;
  6. public function TestDropbox() {
  7. $this->UnitTestCase('');
  8. }
  9. public function setUp() {
  10. global $dropbox_cnf;
  11. $dropbox_cnf['tbl_post'] = Database::get_course_table(TABLE_DROPBOX_POST);
  12. $dropbox_cnf['tbl_file'] = Database::get_course_table(TABLE_DROPBOX_FILE);
  13. $dropbox_cnf['tbl_person'] = Database::get_course_table(TABLE_DROPBOX_PERSON);
  14. $dropbox_cnf['tbl_intro'] = Database::get_course_table(TABLE_TOOL_INTRO);
  15. $dropbox_cnf['tbl_user'] = Database::get_main_table(TABLE_MAIN_USER);
  16. $dropbox_cnf['tbl_course_user'] = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  17. $dropbox_cnf['tbl_category'] = Database::get_course_table(TABLE_DROPBOX_CATEGORY);
  18. $dropbox_cnf['tbl_feedback'] = Database::get_course_table(TABLE_DROPBOX_FEEDBACK);
  19. $this->ddropboxwork = new Dropbox_Work(1);
  20. $this->ddropboxsentwork = new Dropbox_SentWork(1);
  21. $this->dperson = new Dropbox_Person(1, 1, 1);
  22. }
  23. public function tearDown() {
  24. $this-> ddropboxwork = null;
  25. $this-> ddropboxsentwork = null;
  26. $this-> dperson = null;
  27. }
  28. //Class Dropbox_Work
  29. /**
  30. * Constructor calls private functions to create a new work or retreive an existing work from DB
  31. * depending on the number of parameters
  32. *
  33. * @param unknown_type $arg1
  34. * @param unknown_type $arg2
  35. * @param unknown_type $arg3
  36. * @param unknown_type $arg4
  37. * @param unknown_type $arg5
  38. * @param unknown_type $arg6
  39. * @return Dropbox_Work
  40. */
  41. function testDropbox_Work() {
  42. $arg1=1;
  43. $resu= $this->ddropboxwork->Dropbox_Work($arg1, $arg2=null, $arg3=null, $arg4=null, $arg5=null, $arg6=null);
  44. $this->assertTrue(is_null($resu));
  45. //var_dump($resu);
  46. }
  47. /**
  48. * private function creating a new work object
  49. *
  50. * @param unknown_type $uploader_id
  51. * @param unknown_type $title
  52. * @param unknown_type $description
  53. * @param unknown_type $author
  54. * @param unknown_type $filename
  55. * @param unknown_type $filesize
  56. *
  57. * @todo $author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
  58. * As a consequence this parameter can be removed
  59. */
  60. function testCreateNewWork() {
  61. global $dropbox_cnf;
  62. $uploader_id=1;
  63. $title='test';
  64. $description = 'testing';
  65. $author= 'test';
  66. $filename='test.txt';
  67. $filesize=125;
  68. $resu= $this->ddropboxwork->_createNewWork($uploader_id, $title, $description, $author, $filename, $filesize);
  69. $this->assertTrue(is_null($resu));
  70. //var_dump($resu);
  71. }
  72. /**
  73. * private function creating existing object by retreiving info from db
  74. *
  75. * @param unknown_type $id
  76. */
  77. function testCreateExistingWork() {
  78. global $dropbox_cnf;
  79. $dropbox_cnf['tbl_file'] = Database::get_course_table(TABLE_DROPBOX_FILE);
  80. $dropbox_cnf['tbl_feedback'] = Database::get_course_table(TABLE_DROPBOX_FEEDBACK);
  81. $id = 1;
  82. $resu= $this->ddropboxwork->_createExistingWork($id);
  83. $this->assertTrue(is_null($resu));
  84. //var_dump($resu);
  85. }
  86. //Class Dropbox_SentWork
  87. /**
  88. * Constructor calls private functions to create a new work or retreive an existing work from DB
  89. * depending on the number of parameters
  90. *
  91. * @param unknown_type $arg1
  92. * @param unknown_type $arg2
  93. * @param unknown_type $arg3
  94. * @param unknown_type $arg4
  95. * @param unknown_type $arg5
  96. * @param unknown_type $arg6
  97. * @param unknown_type $arg7
  98. * @return Dropbox_SentWork
  99. */
  100. function testDropbox_SentWork() {
  101. $arg1 = 1;
  102. $resu= $this->ddropboxsentwork->Dropbox_SentWork($arg1, $arg2=null, $arg3=null, $arg4=null, $arg5=null, $arg6=null, $arg7=null);
  103. $this->assertTrue(is_null($resu));
  104. }
  105. /**
  106. * private function creating a new SentWork object
  107. *
  108. * @param unknown_type $uploader_id
  109. * @param unknown_type $title
  110. * @param unknown_type $description
  111. * @param unknown_type $author
  112. * @param unknown_type $filename
  113. * @param unknown_type $filesize
  114. * @param unknown_type $recipient_ids
  115. */
  116. function testCreateNewSentWork() {
  117. $recipient_ids = array(1,2);
  118. $uploader_id=1;
  119. $title='test';
  120. $description = 'testing';
  121. $author= 'test';
  122. $filename='test.txt';
  123. $filesize=125;
  124. $resu= $this->ddropboxsentwork->_createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids);
  125. $this->assertTrue(is_null($resu));
  126. }
  127. /**
  128. * private function creating existing object by retreiving info from db
  129. *
  130. * @param unknown_type $id
  131. */
  132. function testCreateExistingSentWork() {
  133. $id = 1;
  134. $resu= $this->ddropboxsentwork->_createExistingSentWork($id);
  135. $this->assertTrue(is_null($resu));
  136. }
  137. //Class Dropbox_SentWork
  138. /**
  139. * Constructor for recreating the Dropbox_Person object
  140. *
  141. * @param unknown_type $userId
  142. * @param unknown_type $isCourseAdmin
  143. * @param unknown_type $isCourseTutor
  144. * @return Dropbox_Person
  145. */
  146. function testDropbox_Person() {
  147. $userId = 1;
  148. $isCourseAdmin = 1;
  149. $isCourseTutor = 1;
  150. $resu= $this->dperson->Dropbox_Person($userId, $isCourseAdmin, $isCourseTutor);
  151. $this->assertTrue(is_null($resu));
  152. }
  153. /**
  154. * This private method is used by the usort function in the
  155. * orderSentWork and orderReceivedWork methods.
  156. * It compares 2 work-objects by 1 of the properties of that object, dictated by the
  157. * private property _orderBy
  158. *
  159. * @param unknown_type $a
  160. * @param unknown_type $b
  161. * @return -1, 0 or 1 dependent of the result of the comparison.
  162. */
  163. function testCmpWork() {
  164. $a = 1;
  165. $b = 1;
  166. $resu= $this->dperson->_cmpWork($a, $b);
  167. if(!is_numeric($resu)) {
  168. $this->assertTrue(is_null($resu));
  169. }
  170. }
  171. /**
  172. * method that sorts the objects in the sentWork array, dependent on the $sort parameter.
  173. * $sort can be lastDate, firstDate, title, size, ...
  174. *
  175. * @param unknown_type $sort
  176. */
  177. function testorderSentWork() {
  178. $sort = 1;
  179. $resu= $this->dperson->orderSentWork($sort);
  180. if(!is_numeric($resu)) {
  181. $this->assertTrue(is_null($resu));
  182. }
  183. }
  184. /**
  185. * method that sorts the objects in the receivedWork array, dependent on the $sort parameter.
  186. * $sort can be lastDate, firstDate, title, size, ...
  187. * @param unknown_type $sort
  188. */
  189. function testorderReceivedWork() {
  190. $sort = 1;
  191. $resu= $this->dperson->orderReceivedWork($sort);
  192. if(!is_numeric($resu)) {
  193. $this->assertTrue(is_null($resu));
  194. }
  195. }
  196. /**
  197. * Updates feedback for received work of this person with id=$id
  198. *
  199. * @param unknown_type $id
  200. * @param unknown_type $text
  201. */
  202. function testupdateFeedback() {
  203. $id = 1;
  204. $text = 'test';
  205. $resu= $this->dperson->updateFeedback($id, $text);
  206. if(!is_bool($resu)) {
  207. $this->assertTrue(is_null($resu));
  208. }
  209. }
  210. /**
  211. * Filter the received work
  212. * @param string $type
  213. * @param string $value
  214. */
  215. function testfilter_received_work() {
  216. $type = 1;
  217. $value = 1;
  218. $resu= $this->dperson->filter_received_work($type,$value);
  219. if(!is_bool($resu)) {
  220. $this->assertTrue(is_null($resu));
  221. }
  222. }
  223. /**
  224. * Deletes all the received work of this person
  225. *
  226. */
  227. function testdeleteAllReceivedWork() {
  228. $resu= $this->dperson->deleteAllReceivedWork();
  229. if(!is_numeric($resu)) {
  230. $this->assertTrue(is_null($resu));
  231. }
  232. }
  233. /**
  234. * Deletes all the received categories and work of this person
  235. */
  236. function testdeleteReceivedWorkFolder() {
  237. $id = 1;
  238. $resu= $this->dperson->deleteReceivedWorkFolder($id);
  239. if(!is_bool($resu)) {
  240. $this->assertTrue(is_null($resu));
  241. }
  242. }
  243. /**
  244. * Deletes a received dropbox file of this person with id=$id
  245. *
  246. * @param integer $id
  247. */
  248. function testdeleteReceivedWork() {
  249. $id = 1;
  250. $resu= $this->dperson->deleteReceivedWork($id);
  251. if(!is_bool($resu)) {
  252. $this->assertTrue(is_null($resu));
  253. }
  254. }
  255. /**
  256. * Deletes all the sent dropbox files of this person
  257. */
  258. function testdeleteAllSentWork() {
  259. $resu= $this->dperson->deleteAllSentWork();
  260. if(!is_bool($resu)) {
  261. $this->assertTrue(is_null($resu));
  262. }
  263. }
  264. /**
  265. * Deletes a sent dropbox file of this person with id=$id
  266. *
  267. * @param unknown_type $id
  268. */
  269. function testdeleteSentWork() {
  270. $id = 1;
  271. $resu= $this->dperson->deleteSentWork($id);
  272. if(!is_bool($resu)) {
  273. $this->assertTrue(is_null($resu));
  274. }
  275. }
  276. }
  277. ?>