sessionmanager.lib.test.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. require_once(api_get_path(LIBRARY_PATH).'sessionmanager.lib.php');
  3. class TestSessionManager extends UnitTestCase {
  4. public function TestSessionManager(){
  5. $this->UnitTestCase('Sessions manager library - main/inc/lib/sessionmanager.lib.test.php');
  6. }
  7. function testadd_courses_to_session() {
  8. $id_session='';
  9. $course_list='';
  10. ob_start();
  11. $res=SessionManager::add_courses_to_session($id_session,$course_list);
  12. if(!empty($res)) {
  13. $this->assertTrue(is_null($res));
  14. } else {
  15. $this->assertTrue(is_bool($res));
  16. }
  17. ob_end_clean();
  18. //var_dump($res);
  19. }
  20. function testcreate_session() {
  21. global $_user;
  22. $sname='';
  23. $start='';
  24. $end='';
  25. $coachStart='';
  26. $coachEnd='';
  27. $nolimit='';
  28. $coach_username='';
  29. $id_session_category='';
  30. $id_visibility='';
  31. $id_session=Database::insert_id();
  32. ob_start();
  33. $res=SessionManager::create_session(
  34. $sname,
  35. $start,
  36. $end,
  37. $coachStart,
  38. $coachEnd,
  39. $nolimit,
  40. $coach_username,
  41. $id_session_category,
  42. $id_visibility
  43. );
  44. $this->assertTrue(is_numeric($id_session));
  45. $this->assertTrue(is_string($res));
  46. ob_end_clean();
  47. //var_dump($id_session);
  48. }
  49. function testcreate_session_extra_field() {
  50. $fieldvarname='';
  51. $fieldtype='';
  52. $fieldtitle='';
  53. ob_start();
  54. $res=SessionManager::create_session_extra_field($fieldvarname, $fieldtype, $fieldtitle);
  55. $this->assertTrue(is_numeric($res));
  56. ob_end_clean();
  57. //var_dump($res);
  58. }
  59. /*
  60. //Esta prueba muestra pantallaso, lo dejo comentado
  61. function testdelete_session() {
  62. $idsesion = new MockDatabase();
  63. $idse = new Mockapi_failure();
  64. global $_user;
  65. $id_checked='';
  66. $this->sessionmanager = new SessionManager();
  67. $res=SessionManager::delete($id_checked);
  68. $idsesion->expectOnce(Database :: get_main_table(TABLE_MAIN_SESSION));
  69. $this->assertTrue(is_object($idsesion));
  70. $this->assertTrue(is_null($res));
  71. var_dump($res);
  72. }
  73. */
  74. function testedit_session() {
  75. global $_user;
  76. $id=1;
  77. $name='';
  78. $start='';
  79. $end='';
  80. $coachStart='';
  81. $coachEnd='';
  82. $nolimit='';
  83. $id_coach='';
  84. $id_session_category='';
  85. $id_visibility='';
  86. $res=SessionManager::edit_session(
  87. $id,
  88. $name,
  89. $start,
  90. $end,
  91. $coachStart,
  92. $coachEnd,
  93. $nolimit,
  94. $id_coach,
  95. $id_session_category,
  96. $id_visibility
  97. );
  98. $this->assertTrue(is_numeric($id));
  99. $this->assertTrue(is_string($res));
  100. //var_dump($id);
  101. }
  102. function testget_session_by_name() {
  103. $session_name='';
  104. $res=SessionManager::get_session_by_name($session_name);
  105. if(!is_bool($res)) $this->assertTrue(is_array($res));
  106. //var_dump($res);
  107. }
  108. function testrelation_session_course_exist() {
  109. $session_id=1;
  110. $course_id='';
  111. $res=SessionManager::relation_session_course_exist($session_id, $course_id);
  112. if(!is_numeric($res)) $this->assertTrue(is_bool($res));
  113. //var_dump($res);
  114. }
  115. function testsuscribe_users_to_session() {
  116. $id_session='';
  117. $user_list='';
  118. $res=SessionManager::suscribe_users_to_session($id_session,$user_list,$empty_users=true);
  119. if(!is_null($res)) $this->assertTrue(is_bool($res));
  120. //var_dump($res);
  121. }
  122. function testupdate_session_extra_field_value() {
  123. $session_id='';
  124. $fname='';
  125. $fvalue='';
  126. $res=SessionManager::update_session_extra_field_value($session_id,$fname,$fvalue='');
  127. $this->assertTrue(is_bool($res));
  128. }
  129. }
  130. ?>