surveymanager.lib.test.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <?php
  2. require_once api_get_path(LIBRARY_PATH).'surveymanager.lib.php';
  3. //This class is deprecated
  4. /*
  5. class TestSurveyManager extends UnitTestCase {
  6. public function TestSurveyManager(){
  7. $this->UnitTestCase('Surveys library - main/inc/lib/surveymanager.lib.test.php');
  8. }
  9. function testcreate_survey() {
  10. $surveycode='';
  11. $surveytitle='';
  12. $surveysubtitle='';
  13. $author='';
  14. $survey_language='';
  15. $availablefrom='';
  16. $availabletill='';
  17. $isshare='';
  18. $surveytemplate='';
  19. $surveyintroduction='';
  20. $surveythanks='';
  21. $table_survey='';
  22. $table_group='';
  23. $res=SurveyManager::create_survey($surveycode,$surveytitle, $surveysubtitle, $author, $survey_language, $availablefrom, $availabletill,$isshare, $surveytemplate, $surveyintroduction, $surveythanks, $table_survey, $table_group);
  24. $this->assertTrue(is_numeric($res));
  25. //var_dump($res);
  26. }
  27. function testcreate_survey_attach() {
  28. $surveycode='';
  29. $surveytitle='';
  30. $surveysubtitle='';
  31. $author='';
  32. $survey_language='';
  33. $availablefrom='';
  34. $availabletill='';
  35. $isshare='';
  36. $surveytemplate='';
  37. $surveyintroduction='';
  38. $surveythanks='';
  39. $table_survey='';
  40. $table_group='';
  41. $res=SurveyManager::create_survey_attach($surveycode,$surveytitle, $surveysubtitle, $author, $survey_language, $availablefrom, $availabletill,$isshare, $surveytemplate, $surveyintroduction, $surveythanks, $table_survey, $table_group);
  42. $this->assertTrue(is_numeric($res));
  43. //var_dump($res);
  44. }
  45. function testattach_survey() {
  46. $surveyid='';
  47. $newsurveyid='';
  48. $db_name='';
  49. $curr_dbname='';
  50. $res=SurveyManager::attach_survey($surveyid,$newsurveyid,$db_name,$curr_dbname);
  51. $this->assertTrue(is_null($res));
  52. //var_dump($res);
  53. }
  54. function testcreate_course_survey_rel() {
  55. $cidReq='';
  56. $survey_id='';
  57. $table_course='';
  58. $table_course_survey_rel='';
  59. $res=SurveyManager::create_course_survey_rel($cidReq,$survey_id,$table_course,$table_course_survey_rel);
  60. $this->assertTrue(is_null($res));
  61. //var_dump($res);
  62. }
  63. function testdisplay_imported_group() {
  64. $sid='';
  65. $table_group='';
  66. $table_question='';
  67. ob_start();
  68. $res=SurveyManager::display_imported_group($sid,$table_group,$table_question);
  69. $this->assertTrue(is_null($res));
  70. ob_end_clean();
  71. //var_dump($res);
  72. }
  73. function testget_all_datas() {
  74. global $_course;
  75. $id='';
  76. $res=SurveyManager::get_all_datas($id);
  77. $this->assertTrue(is_bool($res));
  78. //var_dump($res);
  79. }
  80. function testget_author() {
  81. $db_name='';
  82. $survey_id='';
  83. $res=SurveyManager::get_author($db_name,$survey_id);
  84. $this->assertTrue(is_null($res));
  85. //var_dump($res);
  86. }
  87. function testget_data() {
  88. $id='';
  89. $field='';
  90. $res=SurveyManager::get_data($id, $field);
  91. $this->assertTrue(is_null($res));
  92. //var_dump($res);
  93. }
  94. function testget_groupname() {
  95. $db_name='';
  96. $gid='0011';
  97. $res=SurveyManager::get_groupname($db_name,$gid);
  98. if(!is_null($res))$this->assertTrue(is_bool($res));
  99. //var_dump($res);
  100. }
  101. function testget_question_type() {
  102. $questionid='';
  103. $res=SurveyManager::get_question_type($questionid);
  104. $this->assertTrue(is_null($res));
  105. //var_dump($res);
  106. }
  107. function testget_status() {
  108. global $_user;
  109. $table_user = Database::get_main_table(TABLE_MAIN_USER);
  110. $sqlm = "SELECT status FROM $table_user WHERE user_id = '".Database::escape_string($_user['user_id'])."'";
  111. $resm = Database::query($sqlm);
  112. $objm=@Database::fetch_object($resm);
  113. $ss = $objm->status ;
  114. $res=SurveyManager::get_status();
  115. if(!$res = null ){
  116. $this->assertTrue(is_null($res));
  117. }else{
  118. $this->assertTrue(is_string($res));
  119. }
  120. //var_dump($res);
  121. }
  122. function testget_survey_author() {
  123. $user_table = Database :: get_main_table(TABLE_MAIN_USER);
  124. $authorid = Database::escape_string($authorid);
  125. $sql_query = "SELECT * FROM $user_table WHERE user_id='$authorid'";
  126. $res = Database::query($sql_query);
  127. $firstname=@Database::result($res,0,'firstname');
  128. $res=SurveyManager::get_survey_author($authorid);
  129. $this->assertTrue(is_null($firstname));
  130. $this->assertNull($res);
  131. //var_dump($firstname);
  132. }
  133. function testget_survey_code() {
  134. $table_survey='';
  135. $survey_code='';
  136. $res=SurveyManager::get_survey_code($table_survey,$survey_code);
  137. $this->assertTrue(is_null($res));
  138. //var_dump($res);
  139. }
  140. function testget_survey_list() {
  141. ob_start();
  142. $res=SurveyManager::get_survey_list();
  143. $this->assertTrue(is_null($res));
  144. ob_end_clean();
  145. //var_dump($res);
  146. }
  147. function testget_surveyid() {
  148. $db_name='';
  149. $group_id='';
  150. $res=SurveyManager::get_surveyid($db_name,$group_id);
  151. $this->assertTrue(is_null($res));
  152. //var_dump($res);
  153. }
  154. function testget_surveyname() {
  155. $db_name='';
  156. $sid='';
  157. $res=SurveyManager::get_surveyname($db_name,$sid);
  158. $this->assertTrue(is_null($res));
  159. //var_dump($res);
  160. }
  161. function testget_surveyname_display() {
  162. $sid='';
  163. $res=SurveyManager::get_surveyname_display($sid);
  164. $this->assertTrue(is_null($res));
  165. //var_dump($res);
  166. }
  167. function testimport_questions() {
  168. $import_type='';
  169. $ids='';
  170. $res=SurveyManager::import_questions($import_type, $ids);
  171. $this->assertTrue(is_null($res));
  172. //var_dump($res);
  173. }
  174. function testinsert_into_group() {
  175. $survey_id='';
  176. $group_title='';
  177. $introduction='';
  178. $tb='';
  179. $res=SurveyManager::insert_into_group($survey_id,$group_title,$introduction,$tb);
  180. $this->assertTrue(is_numeric($res));
  181. //var_dump($res);
  182. }
  183. function testno_of_question() {
  184. $db_name='';
  185. $gid='';
  186. $res=SurveyManager::no_of_question($db_name,$gid);
  187. $this->assertTrue(is_bool($res));
  188. //var_dump($res);
  189. }
  190. function testpick_author() {
  191. $survey_id='';
  192. $res=SurveyManager::pick_author($survey_id);
  193. $this->assertTrue(is_null($res));
  194. //var_dump($res);
  195. }
  196. function testpick_surveyname() {
  197. $sid='';
  198. $res=SurveyManager::pick_surveyname($sid);
  199. $this->assertTrue(is_null($res));
  200. //var_dump($res);
  201. }
  202. function testselect_group_list() {
  203. $survey_id='';
  204. $seleced_groupid='';
  205. $extra_script='';
  206. $res=SurveyManager::select_group_list($survey_id, $seleced_groupid='', $extra_script='');
  207. $this->assertTrue(is_bool($res));
  208. //var_dump($res);
  209. }
  210. function testupdate_group() {
  211. $groupid='';
  212. $surveyid='';
  213. $groupnamme='';
  214. $introduction='';
  215. $curr_dbname='';
  216. $res=SurveyManager::update_group($groupid,$surveyid,$groupnamme,$introduction,$curr_dbname);
  217. $this->assertTrue(is_null($res));
  218. //var_dump($res);
  219. }
  220. function testupdate_question() {
  221. $qid='';
  222. $qtype='';
  223. $caption='';
  224. $alignment='';
  225. $answers='';
  226. $open_ans='';
  227. $curr_dbname='';
  228. $res=SurveyManager::update_question($qid,$qtype,$caption,$alignment,$answers,$open_ans,$curr_dbname);
  229. $this->assertTrue(is_numeric($res));
  230. //var_dump($res);
  231. }
  232. function testupdate_survey() {
  233. $surveyid='';
  234. $surveycode='';
  235. $surveytitle='';
  236. $surveysubtitle='';
  237. $author='';
  238. $survey_language='';
  239. $availablefrom='';
  240. $availabletill='';
  241. $isshare='';
  242. $surveytemplate='';
  243. $surveyintroduction='';
  244. $surveythanks='';
  245. $cidReq='';
  246. $table_course='';
  247. $res=SurveyManager::update_survey($surveyid,$surveycode,$surveytitle, $surveysubtitle, $author, $survey_language, $availablefrom, $availabletill,$isshare, $surveytemplate, $surveyintroduction, $surveythanks, $cidReq,$table_course);
  248. $this->assertTrue(is_null($res));
  249. //var_dump($res);
  250. }
  251. function testdelete_group() {
  252. $group_id='';
  253. $res=SurveyManager::delete_group($group_id);
  254. $this->assertTrue(is_null($res));
  255. //var_dump($res);
  256. }
  257. function testdelete_survey() {
  258. $survey_id='';
  259. $res=SurveyManager::delete_survey($survey_id);
  260. $this->assertTrue(is_bool($res));
  261. //var_dump($res);
  262. }
  263. }
  264. */
  265. class TestSurveyTree extends UnitTestCase {
  266. var $surveylist;
  267. var $plainsurveylist;
  268. var $numbersurveys;
  269. public function TestSurveTree(){
  270. $this->UnitTestCase('Survey trees library - main/inc/lib/surveymanager.lib.test.php');
  271. }
  272. function testgetParentId() {
  273. $id='';
  274. $res=SurveyTree::getParentId($id);
  275. $this->assertTrue(is_numeric($res));
  276. //var_dump($res);
  277. }
  278. function testcreateList() {
  279. $list=array();
  280. $res=SurveyTree::createList($list);
  281. $this->assertTrue(is_array($res));
  282. //var_dump($res);
  283. }
  284. }
  285. ?>