events.lib.inc.test.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. require_once(api_get_path(LIBRARY_PATH).'events.lib.inc.php');
  3. class TestEvents extends UnitTestCase {
  4. public function __construct(){
  5. $this->UnitTestCase('Events library - main/inc/events.lib.inc.test.php');
  6. }
  7. function testCreateEventExerciceEmptyExoId() {
  8. /*global $_user, $_cid, $_configuration;
  9. $exo_id='';
  10. $res=create_event_exercice($exo_id);
  11. $this->assertFalse($res);*/
  12. //var_dump($res);
  13. }
  14. function testCreateEventExerciceUnexistingExoId() {
  15. global $_user, $_cid, $_configuration;
  16. $exo_id=3589534; //unexisting exe ID
  17. $res=create_event_exercice($exo_id);
  18. $this->assertFalse($res);
  19. //var_dump($res);
  20. }
  21. function testEventAccessCourse() {
  22. global $_configuration;
  23. global $_user;
  24. global $_cid;
  25. global $TABLETRACK_ACCESS;
  26. global $TABLETRACK_LASTACCESS;
  27. $res=Event::accessCourse();
  28. $this->assertTrue(is_numeric($res));
  29. //var_dump($res);
  30. }
  31. function testEventAccessTool() {
  32. global $_configuration;
  33. global $_cid;
  34. global $TABLETRACK_ACCESS;
  35. global $_configuration;
  36. global $_course;
  37. global $TABLETRACK_LASTACCESS;
  38. $tool = '';
  39. $id_session = 0;
  40. $res=Event::event_access_tool($tool, $id_session);
  41. $this->assertTrue(is_numeric($res));
  42. //var_dump($res);
  43. }
  44. function testEventDownload() {
  45. global $_configuration;
  46. global $_user;
  47. global $_cid;
  48. global $TABLETRACK_DOWNLOADS;
  49. $doc_url= '';
  50. $res=Event::event_download($doc_url);
  51. $this->assertTrue(is_numeric($res));
  52. //var_dump($res);
  53. }
  54. function testEventLink() {
  55. global $_configuration;
  56. global $_user;
  57. global $_cid;
  58. global $TABLETRACK_LINKS;
  59. $link_id='';
  60. $res=Event::event_link($link_id);
  61. $this->assertTrue(is_numeric($res));
  62. //var_dump($res);
  63. }
  64. function testEventLogin() {
  65. global $_configuration;
  66. global $_user;
  67. global $TABLETRACK_LOGIN;
  68. $res=Event::event_login(1);
  69. $this->assertNull($res);
  70. //var_dump($res);
  71. }
  72. function testEventOpen() {
  73. global $_configuration;
  74. global $TABLETRACK_OPEN;
  75. $res=event_open();
  76. $this->assertTrue(is_numeric($res));
  77. //var_dump($res);
  78. }
  79. function testEventSystem() {
  80. global $_configuration;
  81. global $_user;
  82. global $TABLETRACK_DEFAULT;
  83. $event_type = 'bla';
  84. $event_value_type = 'blo';
  85. $event_value = 'bli';
  86. $res=Event::addEvent($event_type, $event_value_type, $event_value);
  87. $this->assertTrue(is_bool($res));
  88. //var_dump($res);
  89. }
  90. function testEventUpload() {
  91. global $_configuration;
  92. global $_user;
  93. global $_cid;
  94. global $TABLETRACK_UPLOADS;
  95. $doc_id='';
  96. $res=Event::event_upload($doc_id);
  97. $this->assertTrue(is_numeric($res));
  98. //var_dump($res);
  99. }
  100. function testExerciseAttempt() {
  101. $score = Database::escape_string($score);
  102. $answer = Database::escape_string($answer);
  103. $quesId = Database::escape_string($quesId);
  104. $exeId = Database::escape_string($exeId);
  105. $j = Database::escape_string($j);
  106. global $_configuration, $_user, $_cid;
  107. $res=Event::exercise_attempt($score,$answer,$quesId,$exeId,$j);
  108. $this->assertTrue(is_bool($res));
  109. //var_dump($res);
  110. }
  111. function testExerciseAttemptHotspot() {
  112. global $_configuration, $_user, $_cid;
  113. $exe_id='';
  114. $question_id='';
  115. $answer_id='';
  116. $correct='';
  117. $coords='';
  118. $res=Event::exercise_attempt_hotspot($exe_id, $question_id, $answer_id, $correct, $coords);
  119. $this->assertTrue(is_bool($res));
  120. //var_dump($res);
  121. }
  122. function testUpdateEventExercice() {
  123. $exeid='';
  124. $exo_id='';
  125. $score='';
  126. $weighting='';
  127. $session_id='';
  128. $duration='';
  129. $question_list = array();
  130. $res=Event::update_event_exercice($exeid,$exo_id, $score, $weighting,$session_id,$learnpath_id=0,$learnpath_item_id=0, $duration, $question_list);
  131. $this->assertTrue(is_bool($res));
  132. //var_dump($res);
  133. }
  134. }