urlmanager.lib.test.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?php
  2. require_once(api_get_path(LIBRARY_PATH).'urlmanager.lib.php');
  3. class TestUrlManager extends UnitTestCase {
  4. public function __construct() {
  5. $this->UnitTestCase('URL manager library - main/inc/lib/urlmanager.lib.test.php');
  6. }
  7. function testadd() {
  8. $url='';
  9. $description='';
  10. $active='';
  11. $res=UrlManager::add($url, $description, $active);
  12. $this->assertTrue(is_bool($res));
  13. //var_dump($res);
  14. }
  15. function testadd_course_to_url() {
  16. $course_code=1;
  17. $res=UrlManager::add_course_to_url($course_code, $url_id=1);
  18. $this->assertTrue(is_bool($res));
  19. //var_dump($res);
  20. }
  21. function testadd_courses_to_urls() {
  22. $url_list='';
  23. $course_list='';
  24. $res=UrlManager::add_courses_to_urls($course_list,$url_list);
  25. $this->assertTrue(is_array($res));
  26. //var_dump($res);
  27. }
  28. function testadd_user_to_url() {
  29. $user_id=1;
  30. $url_id=1;
  31. $res=UrlManager::add_user_to_url($user_id, $url_id);
  32. $this->assertTrue(is_bool($res));
  33. //var_dump($res);
  34. }
  35. function testadd_users_to_urls() {
  36. $user_list='';
  37. $url_list='';
  38. $res=UrlManager::add_users_to_urls($user_list, $url_list);
  39. $this->assertTrue(is_array($res));
  40. //var_dump($res);
  41. }
  42. function testdelete() {
  43. $id='';
  44. $res=UrlManager::delete($id);
  45. $this->assertTrue(is_bool($res));
  46. //var_dump($res);
  47. }
  48. function testdelete_url_rel_course() {
  49. $course_code='';
  50. $url_id='';
  51. $res=UrlManager::delete_url_rel_course($course_code, $url_id);
  52. $this->assertTrue(is_bool($res));
  53. //var_dump($res);
  54. }
  55. function testdelete_url_rel_user() {
  56. $user_id='';
  57. $url_id='';
  58. $res=UrlManager::delete_url_rel_user($user_id, $url_id);
  59. $this->assertTrue(is_bool($res));
  60. //var_dump($res);
  61. }
  62. function testget_access_url_from_user() {
  63. $user_id='';
  64. $res=UrlManager::get_access_url_from_user($user_id);
  65. $this->assertTrue(is_array($res));
  66. //var_dump($res);
  67. }
  68. function testget_url_data() {
  69. $res=UrlManager::get_url_data();
  70. $this->assertTrue(is_array($res));
  71. //var_dump($res);
  72. }
  73. function testget_url_data_from_id() {
  74. $url_id=1;
  75. $resu=UrlManager::get_url_data_from_id($url_id);
  76. $this->assertTrue(is_array($resu));
  77. //var_dump($resu);
  78. }
  79. function testget_url_id() {
  80. $url='';
  81. $resu=UrlManager::get_url_id($url);
  82. $this->assertTrue(is_string($resu));
  83. //var_dump($resu);
  84. }
  85. function testget_url_rel_course_data() {
  86. $resu=UrlManager::get_url_rel_course_data($access_url_id='');
  87. $this->assertTrue(is_array($resu));
  88. //var_dump($resu);
  89. }
  90. function testget_url_rel_session_data() {
  91. $resu=UrlManager::get_url_rel_session_data($access_url_id='');
  92. $this->assertTrue(is_array($resu));
  93. //var_dump($resu);
  94. }
  95. function testget_url_rel_user_data() {
  96. $resu=UrlManager::get_url_rel_user_data($access_url_id='');
  97. $this->assertTrue(is_array($resu));
  98. //var_dump($resu);
  99. }
  100. function testrelation_url_course_exist() {
  101. $course_id = 'COURSETEST';
  102. $url_id=1;
  103. $resu=UrlManager::relation_url_course_exist($course_id, $url_id);
  104. if(!is_numeric($resu)){
  105. $this->assertTrue(is_bool($resu));
  106. }
  107. //var_dump($resu);
  108. }
  109. function testrelation_url_user_exist() {
  110. $user_id=1;
  111. $url_id=1;
  112. $res=UrlManager::relation_url_user_exist($user_id, $url_id);
  113. if(!is_numeric($res)){
  114. $this->assertTrue(is_bool($res));
  115. }
  116. //var_dump($res);
  117. }
  118. function testset_url_status() {
  119. $status='';
  120. $url_id='';
  121. $res=UrlManager::set_url_status($status, $url_id);
  122. if(!is_bool($res)) $this->assertTrue(is_null($res));
  123. //var_dump($res);
  124. }
  125. function testupdate() {
  126. $url_id='';
  127. $url='';
  128. $description='';
  129. $active='';
  130. $res=UrlManager::update($url_id, $url, $description, $active);
  131. if(!is_null($res))$this->assertTrue(is_bool($res));
  132. //var_dump($res);
  133. }
  134. function testupdate_urls_rel_course() {
  135. $course_list=array();
  136. $access_url_id=1;
  137. $res=UrlManager::update_urls_rel_course($course_list,$access_url_id);
  138. if(!is_null($res)) $this->assertTrue(is_array($res));
  139. //var_dump($res);
  140. }
  141. function testupdate_urls_rel_user() {
  142. $user_list=array();
  143. $access_url_id=1;
  144. $res=UrlManager::update_urls_rel_user($user_list,$access_url_id);
  145. $this->assertTrue(is_null($res));
  146. //var_dump($res);
  147. }
  148. function testurl_count() {
  149. $res=UrlManager::url_count();
  150. $this->assertTrue(is_numeric($res));
  151. //var_dump($res);
  152. }
  153. function testurl_exist() {
  154. $url='';
  155. $res=UrlManager::url_exist($url);
  156. $this->assertTrue(is_numeric($res));
  157. //var_dump($res);
  158. }
  159. function testurl_id_exist() {
  160. $url='';
  161. $res=UrlManager::url_id_exist($url);
  162. $this->assertTrue(is_numeric($res));
  163. //var_dump($res);
  164. }
  165. }
  166. ?>