userInfoLib.test.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. require_once(api_get_path(SYS_CODE_PATH).'user/userInfoLib.php');
  3. require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
  4. class TestUserInfoLib extends UnitTestCase {
  5. public function __construct() {
  6. $this->UnitTestCase('User info library - main/user/userInfoLib.test.php');
  7. }
  8. /**
  9. * clean the content of a bloc for information category
  10. */
  11. function testcleanout_cat_content(){
  12. global $TBL_USERINFO_CONTENT;
  13. $user_id=1;
  14. $definition_id=1;
  15. $res=cleanout_cat_content($user_id, $definition_id);
  16. $this->assertTrue(($res));
  17. //var_dump($res);
  18. }
  19. /**
  20. * create a new category definition for the user information
  21. */
  22. function testcreate_cat_def() {
  23. global $TBL_USERINFO_DEF;
  24. $res=create_cat_def($title="test", $comment="comment test", $nbline="5");
  25. $this->assertTrue(($res));
  26. //var_dump($res);
  27. }
  28. /**
  29. * Edit a bloc for information category
  30. */
  31. function testedit_cat_content() {
  32. global $TBL_USERINFO_CONTENT;
  33. $definition_id=1;
  34. $user_id=1;
  35. $res=edit_cat_content($definition_id, $user_id, $content ="", $user_ip="");
  36. $this->assertTrue(is_bool($res));
  37. //var_dump($res);
  38. }
  39. /**
  40. * modify the definition of a user information category
  41. */
  42. function testedit_cat_def() {
  43. $id=1;
  44. $title='test';
  45. $comment='comment test';
  46. $nbline=2;
  47. $res=edit_cat_def($id, $title, $comment, $nbline);
  48. $this->assertTrue(is_bool($res));
  49. //var_dump($res);
  50. }
  51. /**
  52. * fill a bloc for information category
  53. */
  54. function testfill_new_cat_content() {
  55. $definition_id='';
  56. $user_id=1;
  57. $res=fill_new_cat_content($definition_id, $user_id, $content="", $user_ip="");
  58. $this->assertTrue(is_bool($res));
  59. //var_dump($res);
  60. }
  61. /**
  62. * get the user content of a categories plus the categories definition
  63. */
  64. function testget_cat_content() {
  65. $userId=1;
  66. $catId=1;
  67. $res=get_cat_content($userId, $catId);
  68. $this->assertTrue(is_bool($res));
  69. //var_dump($res);
  70. }
  71. function testget_cat_def() {
  72. $catId=1;
  73. $res=get_cat_def($catId);
  74. $this->assertTrue(is_bool($res));
  75. //var_dump($res);
  76. }
  77. function testget_cat_def_list() {
  78. $res=get_cat_def_list();
  79. $this->assertTrue(is_bool($res));
  80. //var_dump($res);
  81. }
  82. function testget_course_user_info() {
  83. $user_id=1;
  84. $res=get_course_user_info($user_id);
  85. $this->assertTrue(is_bool($res));
  86. //var_dump($res);
  87. }
  88. function testget_main_user_info() {
  89. $user_id=1;
  90. $courseCode='TEST';
  91. $res=get_main_user_info($user_id,$courseCode);
  92. if(!is_bool($res))$this->assertTrue(is_array($res));
  93. //var_dump($res);
  94. }
  95. function testhtmlize() {
  96. $phrase='test';
  97. $res=htmlize($phrase);
  98. $this->assertTrue(is_string($res));
  99. //var_dump($res);
  100. }
  101. function testmove_cat_rank() {
  102. $id=1;
  103. $direction='up';
  104. $res=move_cat_rank($id, $direction);
  105. $this->assertTrue(is_bool($res));
  106. //var_dump($res);
  107. }
  108. /*
  109. function testmove_cat_rank_by_rank() {
  110. $rank=5;
  111. $direction='up';
  112. $res=move_cat_rank_by_rank($rank, $direction);
  113. $this->assertTrue(is_bool($res));
  114. //var_dump($res);
  115. }
  116. */
  117. /**
  118. * remove a category from the category list
  119. * @param - int $id - id of the category
  120. * or "ALL" for all category
  121. * @param - boolean $force - FALSE (default) : prevents removal if users have
  122. * already fill this category
  123. * TRUE : bypass user content existence check
  124. * @param - int $nbline - lines number for the field the user will fill.
  125. * @return - bollean - TRUE if succeed, ELSE otherwise
  126. */
  127. function testremove_cat_def() {
  128. $id=1;
  129. $res=remove_cat_def($id, $force = false);
  130. if(!is_null($res))$this->assertTrue(is_bool($res));
  131. //var_dump($res);
  132. }
  133. /**
  134. * @author Hugues Peeters - peeters@ipm.ucl.ac.be
  135. * @param int $user_id
  136. * @param string $course_code
  137. * @param array $properties - should contain 'role', 'status', 'tutor_id'
  138. * @return boolean true if succeed false otherwise
  139. */
  140. function testupdate_user_course_properties() {
  141. $user_id=1;
  142. $course_code='test';
  143. $properties=array();
  144. $res=update_user_course_properties($user_id, $course_code, $properties);
  145. $this->assertTrue(is_bool($res));
  146. //var_dump($res);
  147. }
  148. /**
  149. * This functon only is added to the end of the test and the end of the files in the all test.
  150. */
  151. /*public function testDeleteCourse() {
  152. global $cidReq;
  153. $resu = CourseManager::delete_course($cidReq);
  154. }*/
  155. }
  156. ?>