test_suite.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This is the index file load when a user is testing functions in Chamilo.
  5. *
  6. * Libraries loaded:
  7. * - global.inc
  8. * - files of simpletest
  9. * - files with functions tests
  10. *
  11. * @todo rewrite code to separate display, logic, database code
  12. * @package chamilo.tests
  13. */
  14. /**
  15. * @todo shouldn't these settings be moved to the test_suite.php.
  16. * if these are really configuration then we can make require_once in each tests.
  17. * @todo use this file to load the setup in each file test.
  18. * @todo check for duplication of require with test_suite.php
  19. * @author aportugal
  20. */
  21. /**
  22. * Helpful info for newcomers
  23. *
  24. * @todo maybe not the right place?
  25. *
  26. * http://simpletest.sourceforge.net/en/unit_test_documentation.html
  27. *
  28. assertTrue($x) Fail if $x is false
  29. assertFalse($x) Fail if $x is true
  30. assertNull($x) Fail if $x is set
  31. assertNotNull($x) Fail if $x not set
  32. assertIsA($x, $t) Fail if $x is not the class or type $t
  33. assertNotA($x, $t) Fail if $x is of the class or type $t
  34. assertEqual($x, $y) Fail if $x == $y is false
  35. assertNotEqual($x, $y) Fail if $x == $y is true
  36. assertWithinMargin($x, $y, $m) Fail if abs($x - $y) < $m is false
  37. assertOutsideMargin($x, $y, $m) Fail if abs($x - $y) < $m is true
  38. assertIdentical($x, $y) Fail if $x == $y is false or a type mismatch
  39. assertNotIdentical($x, $y) Fail if $x == $y is true and types match
  40. assertReference($x, $y) Fail unless $x and $y are the same variable
  41. assertClone($x, $y) Fail unless $x and $y are identical copies
  42. assertPattern($p, $x) Fail unless the regex $p matches $x
  43. assertNoPattern($p, $x) Fail if the regex $p matches $x
  44. expectError($x) Swallows any upcoming matching error
  45. assert($e) Fail on failed expectation object $e
  46. */
  47. /* Included libraries */
  48. //The global.inc.php be need be load here to can load the settings files
  49. $incdir = dirname(__FILE__).'/../main/inc/';
  50. require_once $incdir.'global.inc.php';
  51. //This file load the functions to create and destroy the course
  52. require_once api_get_path(SYS_TEST_PATH).'test_manager.inc.php';
  53. //Files than need simpletest to can test
  54. require_once 'simpletest/unit_tester.php';
  55. require_once 'simpletest/web_tester.php';
  56. require_once 'simpletest/mock_objects.php';
  57. require_once 'simpletest/autorun.php';
  58. require_once 'simpletest/reporter.php';
  59. require_once 'simpletest/xml.php';
  60. /**
  61. * TEST SUITE
  62. * Start to load the tests files
  63. * @package chamilo.tests
  64. */
  65. class TestsSuite extends TestSuite {
  66. function TestsSuite() {
  67. // Name of this test suite
  68. $this->TestSuite('All tests suite');
  69. // Loading test cases
  70. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/database.lib.test.php');
  71. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/add_course.lib.inc.test.php');
  72. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/admin/calendar.lib.test.php');
  73. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/surveymanager.lib.test.php');
  74. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/session_handler.class.test.php');
  75. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/sessionmanager.lib.test.php');
  76. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/classmanager.lib.test.php');
  77. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/export.lib.inc.test.php');
  78. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/legal.lib.test.php');
  79. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/mail.lib.inc.test.php');
  80. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/message.lib.test.php');
  81. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/online.inc.test.php');
  82. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/security.lib.test.php');
  83. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/specific_fields_manager.lib.test.php');
  84. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/social.lib.test.php');
  85. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/sortabletable.class.test.php');
  86. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/statsUtils.lib.inc.test.php');
  87. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/tablesort.lib.test.php');
  88. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/text.lib.test.php');
  89. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/tracking.lib.test.php');
  90. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/blog.lib.test.php');
  91. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/urlmanager.lib.test.php');
  92. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/stats.lib.inc.test.php');
  93. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/display.lib.test.php');
  94. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/document.lib.test.php');
  95. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/events.lib.inc.test.php');
  96. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/fileDisplay.lib.test.php');
  97. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/fileManage.lib.test.php');
  98. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/geometry.lib.test.php');
  99. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/admin/statistics/statistics.lib.test.php');
  100. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/access_url_edit_courses_to_url_functions.lib.test.php');
  101. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/access_url_edit_sessions_to_url_functions.lib.test.php');
  102. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/access_url_edit_users_to_url_functions.lib.test.php');
  103. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/add_courses_to_sessions_functions.lib.test.php');
  104. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/add_many_session_to_category_functions.lib.test.php');
  105. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/admin/access_urls.test.php');
  106. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/admin/sub_language.class.test.php');
  107. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/auth/lost_password.lib.test.php');
  108. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/auth/openid/xrds.lib.test.php');
  109. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/chat/chat_functions.lib.test.php');
  110. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/conference/get_translation.lib.test.php');
  111. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/exercice/hotpotatoes.lib.test.php');
  112. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/newscorm/scorm.lib.test.php');
  113. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/survey/survey.lib.test.php');
  114. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/user/userInfoLib.test.php');
  115. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/webservices/user_import/import.lib.test.php');
  116. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/work/work.lib.test.php');
  117. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/glossary.lib.test.php');
  118. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/notebook.lib.test.php');
  119. // $this->addFile(api_get_path(SYS_TEST_PATH).'/main/permissions/permissions_functions.inc.test.php');
  120. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/dropbox/dropbox_class.inc.test.php');
  121. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/dropbox/dropbox_functions.inc.test.php');
  122. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/search/search_suggestions.test.php');
  123. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/exercice/export/qti2/qti2_classes.test.php');
  124. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/exercice/export/scorm/scorm_classes.test.php');
  125. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/usermanager.lib.test.php');
  126. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/groupmanager.lib.test.php');
  127. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/image.lib.test.php');
  128. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/import.lib.test.php');
  129. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/internationalization.lib.test.php');
  130. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/system_announcements.lib.test.php');
  131. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/fileUpload.lib.test.php');
  132. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/resourcelinker/resourcelinker.inc.test.php');
  133. // These files are metadata libraries, not available to test
  134. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/xht.lib.test.php');
  135. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/xmd.lib.test.php');
  136. // These files are not used and is not finished implement, not available to test
  137. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/exercice/export/qti/qti_classes.test.php');
  138. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/exercice/export/qti2/qti2_export.test.php');
  139. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/exercice/export/exercise_import.inc.test.php');
  140. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/exercice/export/scorm/scorm_export.test.php');
  141. // EXERCISES
  142. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/exercice/answer.class.test.php');
  143. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/exercice/exercise_result.class.test.php');
  144. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/exercise_show_functions.lib.test.php');
  145. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/exercice/exercise.class.test.php');
  146. // This files have problem with class and call objects, is not available to test
  147. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/exercice/exercise.lib.test.php');
  148. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/exercice/fill_blanks.class.test.php');
  149. //$this->addFile(api_get_path(SYS_TEST_PATH).'/main/exercice/freeanswer.class.test.php');
  150. // FORUM
  151. //$this->addFile(api_get_path(SYS_TEST_PATH).'main/forum/forumfunction.inc.test.php');
  152. // GRADEBOOK
  153. /* $this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/attendancelink.class.test.php');
  154. $this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/category.class.test.php');
  155. $this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/dropboxlink.class.test.php');
  156. $this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/evaluation.class.test.php');
  157. $this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/exerciselink.class.test.php');
  158. $this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/forumthreadlink.class.test.php');
  159. $this->addFile(api_get_path(SYS_TEST_PATH).'main/course_info/download.lib.test.php');
  160. */
  161. // NEW SCORM
  162. //$this->addFile(api_get_path(SYS_TEST_PATH).'main/newscorm/learnpath.class.test.php');
  163. //$this->addFile(api_get_path(SYS_TEST_PATH).'main/newscorm/learnpathItem.class.test.php');
  164. //$this->addFile(api_get_path(SYS_TEST_PATH).'main/newscorm/openoffice_document.class.test.php');
  165. //$this->addFile(api_get_path(SYS_TEST_PATH).'main/newscorm/openoffice_presentation.class.test.php');
  166. //$this->addFile(api_get_path(SYS_TEST_PATH).'main/newscorm/openoffice_text_document.class.test.php');
  167. //$this->addFile(api_get_path(SYS_TEST_PATH).'main/newscorm/openoffice_text.class.test.php');
  168. //$this->addFile(api_get_path(SYS_TEST_PATH).'main/newscorm/scorm.class.test.php');
  169. //$this->addFile(api_get_path(SYS_TEST_PATH).'main/newscorm/scorm.lib.test.php');
  170. //$this->addFile(api_get_path(SYS_TEST_PATH).'main/newscorm/scormItem.class.test.php');
  171. //$this->addFile(api_get_path(SYS_TEST_PATH).'main/newscorm/scormOrganization.class.test.php');
  172. //$this->addFile(api_get_path(SYS_TEST_PATH).'main/newscorm/scormResource.class.test.php');
  173. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/main_api.lib.test.php');//this file delete the course
  174. $this->addFile(api_get_path(SYS_TEST_PATH).'/main/inc/lib/debug.lib.inc.test.php');//this file need be to the finish of the tests
  175. }
  176. }
  177. $test = &new TestsSuite();
  178. $test->run(new XMLReporter());