learnpathItem.class.test.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. <?php
  2. require_once(api_get_path(SYS_CODE_PATH).'newscorm/learnpathItem.class.php');
  3. require_once(api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php');
  4. class TestLearnpathItem extends UnitTestCase {
  5. public function TestScorm() {
  6. $this->UnitTestCase('Test Scorm');
  7. }
  8. public function __construct() {
  9. // The constructor acts like a global setUp for the class
  10. require_once api_get_path(SYS_TEST_PATH).'setup.inc.php';
  11. }
  12. public function testAddLp() {
  13. //ob_start();
  14. $course = 'COURSETEST';
  15. $name = 'Leccion';
  16. $description = 'Leccion';
  17. $learnpath = 'guess';
  18. $origin = 'zip';
  19. $zipname = '';
  20. $res = learnpath::add_lp($course, $name, $description, $learnpath, $origin, $zipname);
  21. $this->assertTrue(is_null($res));
  22. //ob_end_clean();
  23. //var_dump($res);
  24. }
  25. public function testAddChild() {
  26. //ob_start();
  27. $res = learnpathItem::add_child($item = 1);
  28. $this->assertTrue(is_null($res));
  29. //ob_end_clean();
  30. //var_dump($res);
  31. }
  32. public function testAddInteraction() {
  33. //ob_start();
  34. $res = learnpathItem::add_interaction($index = 1,$params = array());
  35. $this->assertTrue(is_null($res));
  36. //ob_end_clean();
  37. //var_dump($res);
  38. }
  39. public function testAddObjective() {
  40. //ob_start();
  41. $res = learnpathItem::add_objective($index = 1,$params = array());
  42. $this->assertTrue(is_null($res));
  43. //ob_end_clean();
  44. //var_dump($res);
  45. }
  46. /*
  47. public function testClose() {
  48. //ob_start();
  49. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  50. $res = $obj->close();
  51. $this->assertTrue(is_bool($res));
  52. //ob_end_clean();
  53. //var_dump($res);
  54. }
  55. public function testDelete() {
  56. //ob_start();
  57. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  58. $res = $obj->delete();
  59. $this->assertTrue(is_bool($res));
  60. //ob_end_clean();
  61. //var_dump($res);
  62. }
  63. */
  64. public function testDropChild() {
  65. //ob_start();
  66. $res = learnpathItem::drop_child($item = 1);
  67. $this->assertTrue(is_null($res));
  68. //ob_end_clean();
  69. //var_dump($res);
  70. }
  71. public function testGetAttemptId() {
  72. //ob_start();
  73. $res = learnpathItem::get_attempt_id();
  74. $this->assertTrue(is_numeric($res));
  75. //ob_end_clean();
  76. //var_dump($res);
  77. }
  78. public function testGetChildren() {
  79. //ob_start();
  80. $res = learnpathItem::get_children();
  81. $this->assertTrue(is_array($res));
  82. //ob_end_clean();
  83. //var_dump($res);
  84. }
  85. public function testGetCoreExit() {
  86. //ob_start();
  87. $res = learnpathItem::get_core_exit();
  88. $this->assertTrue(is_null($res));
  89. //ob_end_clean();
  90. //var_dump($res);
  91. }
  92. public function testGetCurrentStartTime() {
  93. //ob_start();
  94. $res = learnpathItem::get_current_start_time();
  95. $this->assertTrue(is_numeric($res));
  96. //ob_end_clean();
  97. //var_dump($res);
  98. }
  99. public function testGetDescription() {
  100. //ob_start();
  101. $res = learnpathItem::get_description();
  102. $this->assertTrue(is_string($res));
  103. //ob_end_clean();
  104. //var_dump($res);
  105. }
  106. public function testGetFilePath() {
  107. //ob_start();
  108. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  109. $res = $obj->get_file_path($path_to_scorm_dir='');
  110. $this->assertTrue(is_string($res));
  111. //ob_end_clean();
  112. //var_dump($res);
  113. }
  114. public function testGetId() {
  115. //ob_start();
  116. $res = learnpathItem::get_id();
  117. $this->assertTrue(is_numeric($res));
  118. //ob_end_clean();
  119. //var_dump($res);
  120. }
  121. /*
  122. public function testLoadInteractions() {
  123. //ob_start();
  124. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  125. $res = $obj->load_interactions();
  126. $this->assertTrue(is_null($res));
  127. //ob_end_clean();
  128. //var_dump($res);
  129. }
  130. */
  131. public function testGetInteractionsCount() {
  132. //ob_start();
  133. $res = learnpathItem::get_interactions_count($checkdb=false);
  134. $this->assertTrue(is_numeric($res));
  135. //ob_end_clean();
  136. //var_dump($res);
  137. }
  138. public function testGetInteractionsJsArray() {
  139. //ob_start();
  140. $res = learnpathItem::get_interactions_js_array($checkdb=false);
  141. $this->assertTrue(is_string($res));
  142. //ob_end_clean();
  143. //var_dump($res);
  144. }
  145. public function testGetObjectivesCount() {
  146. //ob_start();
  147. $res = learnpathItem::get_objectives_count();
  148. $this->assertTrue(is_numeric($res));
  149. //ob_end_clean();
  150. //var_dump($res);
  151. }
  152. public function testGetLaunchData() {
  153. //ob_start();
  154. $res = learnpathItem::get_launch_data();
  155. $this->assertTrue(is_string($res));
  156. //ob_end_clean();
  157. //var_dump($res);
  158. }
  159. public function testGetLessonLocation() {
  160. //ob_start();
  161. $res = learnpathItem::get_lesson_location();
  162. $this->assertTrue(is_string($res));
  163. //ob_end_clean();
  164. //var_dump($res);
  165. }
  166. public function testGetLessonMode() {
  167. //ob_start();
  168. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  169. $res = $obj->get_lesson_mode();
  170. $this->assertTrue(is_string($res));
  171. //ob_end_clean();
  172. //var_dump($res);
  173. }
  174. public function testGetLevel() {
  175. //ob_start();
  176. $res = learnpathItem::get_level();
  177. $this->assertTrue(is_numeric($res));
  178. //ob_end_clean();
  179. //var_dump($res);
  180. }
  181. public function testGetMasteryScore() {
  182. //ob_start();
  183. $res = learnpathItem::get_mastery_score();
  184. $this->assertTrue(is_numeric($res));
  185. //ob_end_clean();
  186. //var_dump($res);
  187. }
  188. public function testGetMax() {
  189. //ob_start();
  190. $res = learnpathItem::get_max();
  191. $this->assertTrue(is_numeric($res));
  192. //ob_end_clean();
  193. //var_dump($res);
  194. }
  195. public function testGetMaxTimeAllowed() {
  196. //ob_start();
  197. $res = learnpathItem::get_max_time_allowed();
  198. $this->assertTrue(is_string($res));
  199. //ob_end_clean();
  200. //var_dump($res);
  201. }
  202. public function testGetMin() {
  203. //ob_start();
  204. $res = learnpathItem::get_min();
  205. $this->assertTrue(is_numeric($res));
  206. //ob_end_clean();
  207. //var_dump($res);
  208. }
  209. public function testGetParent() {
  210. //ob_start();
  211. $res = learnpathItem::get_parent();
  212. $this->assertTrue(is_null($res));
  213. //ob_end_clean();
  214. //var_dump($res);
  215. }
  216. public function testGetPath() {
  217. //ob_start();
  218. $res = learnpathItem::get_path();
  219. $this->assertTrue(is_string($res));
  220. //ob_end_clean();
  221. //var_dump($res);
  222. }
  223. public function testGetPrereqString() {
  224. //ob_start();
  225. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  226. $res = $obj->get_prereq_string;
  227. $this->assertTrue(is_null($res));
  228. //ob_end_clean();
  229. ///var_dump($res);
  230. }
  231. public function testGetPreventReinit() {
  232. //ob_start();
  233. $res = learnpathItem::get_prevent_reinit();
  234. $this->assertTrue(is_numeric($res));
  235. //ob_end_clean();
  236. //var_dump($res);
  237. }
  238. public function testGetRef() {
  239. //ob_start();
  240. $res = learnpathItem::get_ref();
  241. $this->assertTrue(is_null($res));
  242. //ob_end_clean();
  243. //var_dump($res);
  244. }
  245. public function testGetResourcesFromSource() {
  246. //ob_start();
  247. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  248. $res = $obj->get_resources_from_source($type=null,$abs_path=null, $recursivity=1);
  249. $this->assertTrue(is_array($res));
  250. //ob_end_clean();
  251. //var_dump($res);
  252. }
  253. public function testGetScore() {
  254. //ob_start();
  255. $res = learnpathItem::get_score();
  256. $this->assertTrue(is_numeric($res));
  257. //ob_end_clean();
  258. //var_dump($res);
  259. }
  260. public function testGetStatus() {
  261. //ob_start();
  262. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  263. $res = $obj->get_status($check_db=true,$update_local=false);
  264. $this->assertTrue(is_string($res));
  265. //ob_end_clean();
  266. //var_dump($res);
  267. }
  268. public function testGetSuspendData() {
  269. //ob_start();
  270. $res = learnpathItem::get_suspend_data();
  271. $this->assertTrue(is_string($res));
  272. //ob_end_clean();
  273. //var_dump($res);
  274. }
  275. public function testGetScormTime() {
  276. //ob_start();
  277. $res = learnpathItem::get_scorm_time($origin='php',$given_time=null);
  278. $this->assertTrue(is_string($res));
  279. //ob_end_clean();
  280. //var_dump($res);
  281. }
  282. public function testGetTerms() {
  283. //ob_start();
  284. $res = learnpathItem::get_terms();
  285. $this->assertTrue(is_null($res));
  286. //ob_end_clean();
  287. //var_dump($res);
  288. }
  289. public function testGetTitle() {
  290. //ob_start();
  291. $res = learnpathItem::get_title();
  292. $this->assertTrue(is_string($res));
  293. //ob_end_clean();
  294. //var_dump($res);
  295. }
  296. public function testGetTotalTime() {
  297. //ob_start();
  298. $res = learnpathItem::get_total_time();
  299. $this->assertTrue(is_numeric($res));
  300. //ob_end_clean();
  301. //var_dump($res);
  302. }
  303. public function testGetType() {
  304. //ob_start();
  305. $res = learnpathItem::get_type();
  306. $this->assertTrue(is_string($res));
  307. //ob_end_clean();
  308. //var_dump($res);
  309. }
  310. public function testGetViewCount() {
  311. //ob_start();
  312. $res = learnpathItem::get_view_count();
  313. $this->assertTrue(is_numeric($res));
  314. //ob_end_clean();
  315. //var_dump($res);
  316. }
  317. public function testIsDone() {
  318. //ob_start();
  319. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  320. $res = $obj->is_done();
  321. $this->assertTrue(is_bool($res));
  322. //ob_end_clean();
  323. //var_dump($res);
  324. }
  325. public function testIsRestartAllowed() {
  326. //ob_start();
  327. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  328. $res = $obj->is_restart_allowed();
  329. $this->assertTrue(is_numeric($res));
  330. //ob_end_clean();
  331. //var_dump($res);
  332. }
  333. public function testOpen() {
  334. //ob_start();
  335. $res = learnpathItem::open($allow_new_attempt=false);
  336. $this->assertTrue(is_null($res));
  337. //ob_end_clean();
  338. //var_dump($res);
  339. }
  340. public function testOutput() {
  341. //ob_start();
  342. $res = learnpathItem::output();
  343. $this->assertTrue(is_string($res));
  344. //ob_end_clean();
  345. //var_dump($res);
  346. }
  347. public function testParsePrereq() {
  348. //ob_start();
  349. $res = learnpathItem::parse_prereq($prereqs_string = '', $items = array(), $refs_list = array(),$user_id = 1);
  350. $this->assertTrue(is_bool($res));
  351. //ob_end_clean();
  352. //var_dump($res);
  353. }
  354. /*
  355. public function testRestart() {
  356. //ob_start();
  357. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  358. $res = $obj->restart();
  359. $this->assertTrue(is_bool($res));
  360. //ob_end_clean();
  361. //var_dump($res);
  362. }
  363. public function testSave() {
  364. //ob_start();
  365. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  366. $res = $obj->save($from_outside=true,$prereqs_complete=false);
  367. $this->assertTrue(is_bool($res));
  368. //ob_end_clean();
  369. //var_dump($res);
  370. }
  371. */
  372. public function testSetAttemptId() {
  373. //ob_start();
  374. $res = learnpathItem::set_attempt_id($num = 1);
  375. $this->assertTrue(is_bool($res));
  376. //ob_end_clean();
  377. //var_dump($res);
  378. }
  379. public function testSetCoreExit() {
  380. //ob_start();
  381. $res = learnpathItem::set_core_exit($value = 1);
  382. $this->assertTrue(is_bool($res));
  383. //ob_end_clean();
  384. //var_dump($res);
  385. }
  386. public function testSetDescription() {
  387. //ob_start();
  388. $res = learnpathItem::set_description($string = '');
  389. $this->assertTrue(is_null($res));
  390. //ob_end_clean();
  391. //var_dump($res);
  392. }
  393. public function testSetLessonLocation() {
  394. //ob_start();
  395. $res = learnpathItem::set_lesson_location($location = '');
  396. $this->assertTrue(is_bool($res));
  397. //ob_end_clean();
  398. //var_dump($res);
  399. }
  400. public function testSetLevel() {
  401. //ob_start();
  402. $res = learnpathItem::set_level($int=0);
  403. $this->assertTrue(is_null($res));
  404. //ob_end_clean();
  405. //var_dump($res);
  406. }
  407. public function testSetLpView() {
  408. //ob_start();
  409. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  410. $res = $obj->set_lp_view($lp_view_id = 1);
  411. $this->assertTrue(is_null($res));
  412. //ob_end_clean();
  413. //var_dump($res);
  414. }
  415. public function testSetPath() {
  416. //ob_start();
  417. $res = learnpathItem::set_path($string='');
  418. $this->assertTrue(is_null($res));
  419. //ob_end_clean();
  420. //var_dump($res);
  421. }
  422. public function testSetPreventReinit() {
  423. //ob_start();
  424. $res = learnpathItem::set_prevent_reinit($prevent = 1);
  425. $this->assertTrue(is_null($res));
  426. //ob_end_clean();
  427. //var_dump($res);
  428. }
  429. public function testSetScore() {
  430. //ob_start();
  431. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  432. $res = $obj->set_score($score = 1.56);
  433. $this->assertTrue(is_bool($res));
  434. //ob_end_clean();
  435. //var_dump($res);
  436. }
  437. public function testSetMaxScore() {
  438. //ob_start();
  439. $res = learnpathItem::set_max_score($score = 1.56);
  440. $this->assertTrue(is_bool($res));
  441. //ob_end_clean();
  442. //var_dump($res);
  443. }
  444. /*
  445. public function testSetStatus() {
  446. //ob_start();
  447. $res = learnpathItem::set_status($status = '');
  448. $this->assertTrue(is_bool($res));
  449. //ob_end_clean();
  450. //var_dump($res);
  451. }
  452. */
  453. public function testSetTerms() {
  454. //ob_start();
  455. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  456. $res = $obj->set_terms($terms = '');
  457. $this->assertTrue(is_bool($res));
  458. //ob_end_clean();
  459. //var_dump($res);
  460. }
  461. public function testGetSearchDid() {
  462. //ob_start();
  463. $res = learnpathItem::get_search_did();
  464. $this->assertTrue(is_null($res));
  465. //ob_end_clean();
  466. //var_dump($res);
  467. }
  468. public function testSetTime() {
  469. //ob_start();
  470. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  471. $res = $obj->set_time($scorm_time = '',$format='scorm');
  472. $this->assertTrue(is_null($res));
  473. //ob_end_clean();
  474. //var_dump($res);
  475. }
  476. public function testSetTitle() {
  477. //ob_start();
  478. $res = learnpathItem::set_title($string='');
  479. $this->assertTrue(is_null($res));
  480. //ob_end_clean();
  481. //var_dump($res);
  482. }
  483. public function testSetType() {
  484. //ob_start();
  485. $res = learnpathItem::set_type($string='');
  486. $this->assertTrue(is_null($res));
  487. //ob_end_clean();
  488. //var_dump($res);
  489. }
  490. public function testStatusIs() {
  491. //ob_start();
  492. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  493. $res = $obj->status_is($list=array());
  494. $this->assertTrue(is_bool($res));
  495. //ob_end_clean();
  496. //var_dump($res);
  497. }
  498. public function testUpdateTime() {
  499. //ob_start();
  500. $res = learnpathItem::update_time($total_sec=0);
  501. $this->assertTrue(is_null($res));
  502. //ob_end_clean();
  503. //var_dump($res);
  504. }
  505. public function testWriteObjectivesToDb() {
  506. //ob_start();
  507. $res = learnpathItem::write_objectives_to_db();
  508. $this->assertTrue(is_null($res));
  509. //ob_end_clean();
  510. //var_dump($res);
  511. }
  512. /*
  513. public function testWriteToDb() {
  514. //ob_start();
  515. $obj = new learnpathItem($db_id = 1, $user_id = 1);
  516. $res = $obj->write_to_db();
  517. $this->assertTrue(is_bool($res));
  518. //ob_end_clean();
  519. //var_dump($res);
  520. }
  521. */
  522. public function __destruct() {
  523. // The destructor acts like a global tearDown for the class
  524. // require_once api_get_path(SYS_TEST_PATH).'teardown.inc.php';
  525. }
  526. }