scorm.lib.test.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. require_once(api_get_path(SYS_CODE_PATH).'newscorm/scorm.lib.php');
  3. class TestScormLib extends UnitTestCase {
  4. /**
  5. * This public 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. public 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 public function
  24. */
  25. public function testget_scorm_version() {
  26. $path_name = api_get_path(SYS_COURSE_PATH);
  27. $path=$path_name.'scorm/';
  28. $res=get_scorm_version($path);
  29. $this->assertTrue(is_string($res));
  30. //var_dump($res);
  31. }
  32. /**
  33. * Delete a scorm directory (check for imsmanifest and if found, deletes the related rows in scorm tables also)
  34. * @param string Dir path
  35. * @return boolean True on success, false otherwise
  36. */
  37. public function testremovescormDirFalse() {
  38. $path_name = api_get_path(SYS_COURSE_PATH);
  39. $dir=$path_name.'scorm/';
  40. $res=removescormDir($dir);
  41. $this->assertFalse($res);
  42. //var_dump($res);
  43. }
  44. public function testremovescormDirTrue() {
  45. $path_name = api_get_path(SYS_COURSE_PATH);
  46. $dir=$path_name.'scorm/';
  47. $res=removescormDir($dir);
  48. $this->assertTrue(is_bool($res));
  49. //var_dump($res);
  50. }
  51. /**
  52. * This public function removes a directory if it exists
  53. * @param string Dir path
  54. * @return boolean True on success, false otherwise
  55. * @uses removescormDir() to actually remove the directory
  56. */
  57. public function testscorm_delete() {
  58. require_once(api_get_path(LIBRARY_PATH).'/fileManage.lib.php');
  59. $path_name = api_get_path(SYS_COURSE_PATH);
  60. $file=$path_name.'scorm/';
  61. $res=scorm_delete($file);
  62. $this->assertTrue(is_bool($res));
  63. //var_dump($res);
  64. }
  65. }
  66. ?>