scorm.lib.test.php 2.3 KB

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