scorm.lib.test.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. require_once(api_get_path(SYS_CODE_PATH).'newscorm/scorm.lib.php');
  3. class TestScorm extends UnitTestCase {
  4. /**
  5. * This function gets a list of scorm paths located in a given directory
  6. * @param string Base directory path
  7. * @param string Current directory
  8. * @param array Reference to a list of paths that exist in the database
  9. * @return array Array(type=>array(),size=>array(),date=>array())
  10. */
  11. function testget_scorm_paths_from_dir(){
  12. $basedir='';
  13. $curdir='';
  14. $attribute=array('abc');
  15. $res=get_scorm_paths_from_dir($basedir, $curdir, &$attribute);
  16. $this->assertTrue(is_array($res));
  17. //var_dump($res);
  18. }
  19. /**
  20. * Detects the SCORM version from an imsmanifest.xml file
  21. * @param string Path to imsmanifest.xml
  22. * @return string SCORM version (1.0,1.1,1.2,1.3)
  23. * @todo Implement this function
  24. */
  25. function testget_scorm_version(){
  26. $path='/main/erxercice/';
  27. $res=get_scorm_version($path);
  28. $this->assertTrue(is_string($res));
  29. //var_dump($res);
  30. }
  31. /**
  32. * Delete a scorm directory (check for imsmanifest and if found, deletes the related rows in scorm tables also)
  33. * @param string Dir path
  34. * @return boolean True on success, false otherwise
  35. */
  36. function testremovescormDirFalse() {
  37. global $_course;
  38. $dir='/main/exercice';
  39. $res=removescormDir($dir);
  40. $this->assertFalse($res);
  41. //var_dump($res);
  42. }
  43. function testremovescormDirTrue() {
  44. global $_course;
  45. $dir=api_get_path(SYS_CODE_PATH).'upload/users/';
  46. $res=removescormDir($dir);
  47. $this->assertTrue(is_bool($res));
  48. //var_dump($res);
  49. }
  50. /**
  51. * This function removes a directory if it exists
  52. * @param string Dir path
  53. * @return boolean True on success, false otherwise
  54. * @uses removescormDir() to actually remove the directory
  55. */
  56. function testscorm_delete() {
  57. require_once(api_get_path(LIBRARY_PATH).'/fileManage.lib.php');
  58. $file='/tmp/';
  59. $res=scorm_delete($file);
  60. $this->assertTrue(is_bool($res));
  61. //var_dump($res);
  62. }
  63. }
  64. ?>