Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ELIS 2.2.0.5 release

  • Loading branch information...
commit 78219ca1284bb672b3775c0bdffb98a5aaf096ee 1 parent 3b22aed
brendan authored
Showing with 19,327 additions and 3,058 deletions.
  1. +0 −54 addons/blocks/elis_info/block_elis_info.php
  2. +0 −45 addons/blocks/elis_info/db/access.php
  3. +0 −144 addons/blocks/elis_info/elis_info.php
  4. +0 −14 addons/blocks/elis_info/lang/en_utf8/block_elis_info.php
  5. +5 −0 core/admin/styles.css
  6. +39 −0 core/admin/tool/phpunittest/db/access.php
  7. +417 −0 core/admin/tool/phpunittest/ex_phpunit_test.php
  8. +433 −0 core/admin/tool/phpunittest/ex_reporter.php
  9. +576 −0 core/admin/tool/phpunittest/index.php
  10. +69 −0 core/admin/tool/phpunittest/lang/en/tool_phpunittest.php
  11. +71 −0 core/admin/tool/phpunittest/phpunit/testphpunit.php
  12. +4 −0 core/admin/tool/phpunittest/settings.php
  13. +41 −0 core/admin/tool/phpunittest/styles.css
  14. +152 −0 core/admin/tool/phpunittest/update.php
  15. +27 −0 core/admin/tool/phpunittest/version.php
  16. +34 −10 core/elis/core/cron.php
  17. +157 −28 core/elis/core/db/install.xml
  18. +5 −10 core/elis/core/db/{tasks.php → subplugins.php}
  19. +404 −44 core/elis/core/db/upgrade.php
  20. +586 −0 core/elis/core/fields/manual/custom_fields.php
  21. +55 −0 core/elis/core/fields/manual/field_controls/checkbox.php
  22. +34 −0 core/elis/core/fields/manual/field_controls/datetime.php
  23. +63 −0 core/elis/core/fields/manual/field_controls/menu.php
  24. +29 −0 core/elis/core/fields/manual/field_controls/password.php
  25. +29 −0 core/elis/core/fields/manual/field_controls/plaintextarea.php
  26. +37 −0 core/elis/core/fields/manual/field_controls/text.php
  27. +31 −0 core/elis/core/fields/manual/field_controls/textarea.php
  28. +29 −0 core/elis/core/fields/manual/lang/en/elisfields_manual.php
  29. +13 −0 core/elis/core/fields/manual/lang/es_mx/crlm_manual.php
  30. +37 −0 core/elis/core/fields/manual/sources.php
  31. +57 −0 core/elis/core/fields/manual/sources/learning_objectives.php
  32. +14 −25 core/{local/db/upgrade.php → elis/core/fields/manual/sources/themes.php}
  33. +48 −0 core/elis/core/fields/manual/sources/userset_classifications.php
  34. +180 −0 core/elis/core/fields/moodle_profile/custom_fields.php
  35. +10 −0 core/elis/core/fields/moodle_profile/lang/en/elisfields_moodle_profile.php
  36. +281 −0 core/elis/core/js/associate.class.js
  37. +15 −6 core/elis/core/js/associate.js
  38. +121 −0 core/elis/core/js/dependentselect.js
  39. +536 −0 core/elis/core/js/module.js
  40. +275 −0 core/elis/core/lang/en/elis_core.php
  41. +26 −0 core/elis/core/lang/en_us/elis_core.php
  42. +0 −46 core/elis/core/lang/en_utf8/elis_core.php
  43. +0 −4 core/elis/core/lang/es_mx_utf8/elis_core.php
  44. +922 −0 core/elis/core/lib/data/customfield.class.php
  45. +440 −0 core/elis/core/lib/data/data_filter.class.php
  46. +1,090 −0 core/elis/core/lib/data/data_object.class.php
  47. +328 −0 core/elis/core/lib/data/data_object_with_custom_fields.class.php
  48. +172 −0 core/elis/core/lib/filtering/autocomplete.php
  49. +327 −0 core/elis/core/lib/filtering/checkboxes.php
  50. +236 −0 core/elis/core/lib/filtering/custom_field_datetime.php
  51. +216 −0 core/elis/core/lib/filtering/custom_field_select.php
  52. +295 −0 core/elis/core/lib/filtering/custom_field_text.php
  53. +119 −30 core/elis/core/lib/filtering/date.php
  54. +199 −0 core/elis/core/lib/filtering/dependentselect.php
  55. +126 −0 core/elis/core/lib/filtering/display_text.php
  56. +56 −21 core/elis/core/lib/filtering/equalityselect.php
  57. +112 −0 core/elis/core/lib/filtering/exists_select.php
  58. +97 −43 core/elis/core/lib/filtering/lib.php
  59. +221 −51 core/elis/core/lib/filtering/multifilter.php
  60. +62 −31 core/elis/core/lib/filtering/profileselect.php
  61. +211 −0 core/elis/core/lib/filtering/radiobuttons.php
  62. +80 −0 core/elis/core/lib/filtering/selectall.php
  63. +98 −0 core/elis/core/lib/filtering/selectany.php
  64. +191 −0 core/elis/core/lib/filtering/setselect.php
  65. +104 −65 core/elis/core/lib/filtering/simpleselect.php
  66. +70 −16 core/elis/core/lib/filtering/text.php
  67. +116 −0 core/elis/core/lib/filtering/userprofiledatetime.php
  68. +607 −0 core/elis/core/lib/filtering/userprofilematch.php
  69. +101 −0 core/elis/core/lib/filtering/userprofileselect.php
  70. +136 −0 core/elis/core/lib/filtering/userprofiletext.php
  71. +30 −3 core/elis/core/lib/filtering/yesno.php
  72. +345 −0 core/elis/core/lib/form/autocomplete.php
  73. +195 −0 core/elis/core/lib/form/custom_field_multiselect.php
  74. +101 −0 core/elis/core/lib/form/gradebookidnumber.php
  75. +140 −0 core/elis/core/lib/form/gradebookidnumber_ajax.php
  76. +4 −0 core/elis/core/lib/form/jquery-1.7.1.min.js
  77. +25 −1 core/elis/core/lib/form/timeselector.php
  78. +2 −0  core/elis/core/lib/form/xbutton.php
  79. +262 −185 core/elis/core/lib/page.class.php
  80. +75 −0 core/elis/core/lib/rollover/backup/rollover_backup_controller.class.php
  81. +47 −0 core/elis/core/lib/rollover/backup/rollover_backup_factory.class.php
  82. +140 −0 core/elis/core/lib/rollover/backup/rollover_backup_final_task.class.php
  83. +60 −0 core/elis/core/lib/rollover/backup/rollover_backup_plan.class.php
  84. +56 −0 core/elis/core/lib/rollover/backup/rollover_backup_plan_builder.class.php
  85. +52 −0 core/elis/core/lib/rollover/backup/stepslib.php
  86. +94 −0 core/elis/core/lib/rollover/lib.php
  87. +90 −0 core/elis/core/lib/rollover/restore/rollover_restore_controller.class.php
  88. +46 −0 core/elis/core/lib/rollover/restore/rollover_restore_final_task.class.php
  89. +13 −15 core/elis/core/lib/{filtering/nofilterdate.php → rollover/restore/rollover_restore_plan.class.php}
  90. +54 −0 core/elis/core/lib/rollover/restore/rollover_restore_plan_builder.class.php
  91. +47 −0 core/elis/core/lib/rollover/restore/stepslib.php
  92. +151 −0 core/elis/core/lib/setup.php
  93. +374 −0 core/elis/core/lib/table.class.php
  94. +22 −17 core/elis/core/lib/tasklib.php
  95. +682 −0 core/elis/core/lib/testlib.php
  96. +15 −45 core/elis/core/lib/workflow.class.php
  97. +36 −24 core/elis/core/lib/workflowpage.class.php
  98. +3 −0  core/elis/core/phpunit/phpunit_data_object_delete_test_result.csv
  99. +4 −0 core/elis/core/phpunit/phpunit_data_object_test.csv
  100. +405 −0 core/elis/core/phpunit/test_custom_field_permissions.php
  101. +313 −0 core/elis/core/phpunit/test_data_filter.php
  102. +415 −0 core/elis/core/phpunit/test_data_object.php
  103. +80 −0 core/elis/core/phpunit/test_overlay_database.php
  104. +38 −0 core/elis/core/plugins/user_activity/db/install.php
  105. +43 −0 core/elis/core/plugins/user_activity/db/install.xml
  106. +40 −0 core/elis/core/plugins/user_activity/db/tasks.php
  107. +88 −0 core/elis/core/plugins/user_activity/db/upgrade.php
  108. +6 −0 core/elis/core/plugins/user_activity/defaults.php
  109. +415 −0 core/elis/core/plugins/user_activity/etl.php
  110. +84 −0 core/elis/core/plugins/user_activity/health.php
  111. +3 −0  core/elis/core/plugins/user_activity/lang/en/eliscoreplugins_user_activity.php
  112. +6 −0 core/elis/core/plugins/user_activity/version.php
  113. +294 −0 core/elis/core/scripts/preupgrade.php
  114. +9 −0 core/elis/core/styles.css
  115. +5 −3 core/{local/version.php → elis/core/test_config.php}
  116. +28 −2 core/elis/core/version.php
  117. +48 −0 core/install/lang/bn/error.php
  118. +34 −0 core/install/lang/en_kids/langconfig.php
  119. +33 −0 core/install/lang/ha/langconfig.php
  120. +42 −0 core/install/lang/ms/admin.php
  121. +83 −0 core/install/lang/ms/install.php
  122. +35 −0 core/install/lang/ms/moodle.php
  123. +33 −0 core/install/lang/my/langconfig.php
  124. +33 −0 core/install/lang/sw/langconfig.php
  125. +33 −0 core/install/lang/vi/error.php
  126. +26 −0 core/lang/en_us/block_news_items.php
  127. +26 −0 core/lang/en_us/block_recent_activity.php
  128. +26 −0 core/lang/en_us/block_site_main_menu.php
  129. +31 −0 core/lang/en_us/enrol.php
  130. +48 −0 core/lang/en_us/enrol_authorize.php
  131. +27 −0 core/lang/en_us/enrol_flatfile.php
  132. +28 −0 core/lang/en_us/enrol_imsenterprise.php
  133. +29 −22 core/lang/{en_us_utf8 → en_us}/enrol_ldap.php
  134. +28 −0 core/lang/en_us/enrol_self.php
  135. +43 −0 core/lang/en_us/langconfig.php
  136. +70 −0 core/lang/en_us/moodle.php
  137. +0 −10 core/lang/en_us_utf8/README
  138. +0 −18 core/lang/en_us_utf8/docs/module_files.txt
  139. +0 −29 core/lang/en_us_utf8/enrol_authorize.php
  140. +0 −15 core/lang/en_us_utf8/enrol_database.php
  141. +0 −6 core/lang/en_us_utf8/enrol_flatfile.php
  142. +0 −9 core/lang/en_us_utf8/enrol_imsenterprise.php
  143. +0 −13 core/lang/en_us_utf8/enrol_manual.php
  144. +0 −9 core/lang/en_us_utf8/enrol_paypal.php
  145. +0 −23 core/lang/en_us_utf8/help/enrolmentkey.html
  146. +0 −21 core/lang/en_us_utf8/help/guestaccess.html
  147. +0 −20 core/lang/en_us_utf8/langconfig.php
  148. +0 −100 core/lang/en_us_utf8/moodle.php
  149. +0 −705 core/lib/HTML_TreeMenu-1.2.0/TreeMenu.js
  150. +0 −824 core/lib/HTML_TreeMenu-1.2.0/TreeMenu.php
  151. BIN  core/lib/HTML_TreeMenu-1.2.0/docs/HTML_TreeMenu.doc
  152. BIN  core/lib/HTML_TreeMenu-1.2.0/docs/HTML_TreeMenu.pdf
  153. +0 −105 core/lib/HTML_TreeMenu-1.2.0/docs/example.php
  154. +0 −42 core/lib/HTML_TreeMenu-1.2.0/docs/map_fs.php
  155. BIN  core/lib/HTML_TreeMenu-1.2.0/images/Copy of minussingle.gif
  156. BIN  core/lib/HTML_TreeMenu-1.2.0/images/Copy of plussingle.gif
  157. BIN  core/lib/HTML_TreeMenu-1.2.0/images/branch.gif
  158. BIN  core/lib/HTML_TreeMenu-1.2.0/images/branchbottom.gif
  159. BIN  core/lib/HTML_TreeMenu-1.2.0/images/branchsingle.gif
  160. BIN  core/lib/HTML_TreeMenu-1.2.0/images/branchtop.gif
  161. BIN  core/lib/HTML_TreeMenu-1.2.0/images/course-orig.gif
  162. BIN  core/lib/HTML_TreeMenu-1.2.0/images/course.gif
  163. BIN  core/lib/HTML_TreeMenu-1.2.0/images/courseact.gif
  164. BIN  core/lib/HTML_TreeMenu-1.2.0/images/coursefav.gif
  165. BIN  core/lib/HTML_TreeMenu-1.2.0/images/courseinact.gif
  166. BIN  core/lib/HTML_TreeMenu-1.2.0/images/coursemem.gif
  167. BIN  core/lib/HTML_TreeMenu-1.2.0/images/folder-expanded.gif
  168. BIN  core/lib/HTML_TreeMenu-1.2.0/images/folder.gif
  169. BIN  core/lib/HTML_TreeMenu-1.2.0/images/home.gif
  170. BIN  core/lib/HTML_TreeMenu-1.2.0/images/line.gif
  171. BIN  core/lib/HTML_TreeMenu-1.2.0/images/linebottom.gif
  172. BIN  core/lib/HTML_TreeMenu-1.2.0/images/minus.gif
  173. BIN  core/lib/HTML_TreeMenu-1.2.0/images/minusbottom.gif
  174. BIN  core/lib/HTML_TreeMenu-1.2.0/images/minussingle.gif
  175. BIN  core/lib/HTML_TreeMenu-1.2.0/images/minustop.gif
  176. BIN  core/lib/HTML_TreeMenu-1.2.0/images/pics.gif
  177. BIN  core/lib/HTML_TreeMenu-1.2.0/images/plus.gif
  178. BIN  core/lib/HTML_TreeMenu-1.2.0/images/plusbottom.gif
  179. BIN  core/lib/HTML_TreeMenu-1.2.0/images/plussingle.gif
  180. BIN  core/lib/HTML_TreeMenu-1.2.0/images/plustop.gif
  181. BIN  core/lib/HTML_TreeMenu-1.2.0/images/reel.gif
  182. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt/branch.gif
  183. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt/branchbottom.gif
  184. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt/branchtop.gif
  185. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt/folder-expanded.gif
  186. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt/folder.gif
  187. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt/line.gif
  188. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt/linebottom.gif
  189. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt/minus.gif
  190. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt/minusbottom.gif
  191. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt/minustop.gif
  192. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt/plus.gif
  193. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt/plusbottom.gif
  194. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt/plustop.gif
  195. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt2/branch.gif
  196. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt2/branchbottom.gif
  197. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt2/branchtop.gif
  198. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt2/folder-expanded.gif
  199. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt2/folder.gif
  200. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt2/line.gif
  201. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt2/linebottom.gif
  202. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt2/minus.gif
  203. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt2/minusbottom.gif
  204. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt2/minustop.gif
  205. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt2/plus.gif
  206. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt2/plusbottom.gif
  207. BIN  core/lib/HTML_TreeMenu-1.2.0/imagesAlt2/plustop.gif
  208. +0 −105 core/lib/moodlelib2.0.php
  209. +628 −0 core/lib/pear/File/CSV.php
  210. +197 −0 core/lib/pear/File/Iterator.php
  211. +155 −0 core/lib/pear/File/Iterator/Factory.php
  212. +482 −0 core/lib/pear/File/Util.php
Sorry, we could not display the entire diff because too many files (661) changed.
54 addons/blocks/elis_info/block_elis_info.php
View
@@ -1,54 +0,0 @@
-<?php // $Id$
-
-/**
- * ELIS_info Block is a Moodle block to display ELIS components
- * and their release version string.
- *
- * @author Brent Boghosian <brent.boghosian@remote-learner.net>
- * @copyright Copyright (c) 2011 Remote-Learner
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package ELIS
- */
-
-class block_elis_info extends block_base {
-
- function init() {
- $this->title = get_string('elis_info', 'block_elis_info');
- $this->version = 2011020100;
- $this->release = '1.0';
- }
-
- function applicable_formats() {
- return array('site' => true);
- }
-
- /**
- * Simply displays a link to ELIS Information page: blocks/elis_info.php
- *
- * @uses $CFG
- */
- function get_content() {
- global $CFG;
-
- if ($this->content !== NULL) {
- return $this->content;
- }
-
- // check user capabilities to view elis_info
- $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
- if (!has_capability('block/elis_info:view', $context)) {
- return '';
- }
-
- $this->content = new stdClass;
- $this->content->text = '<center>'.
- "<a href=\"{$CFG->wwwroot}/blocks/elis_info/elis_info.php\">".
- get_string('elis_info','block_elis_info'). '</a></center>';
- $this->content->footer = '';
-
- return $this->content;
- }
-
-}
-
-?>
45 addons/blocks/elis_info/db/access.php
View
@@ -1,45 +0,0 @@
-<?php
-//
-// Capability definitions for the elis_info block.
-//
-// The capabilities are loaded into the database table when the block is
-// installed or updated. Whenever the capability definitions are updated,
-// the module version number should be bumped up.
-//
-// The system has four possible values for a capability:
-// CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT, and inherit (not set).
-//
-//
-// CAPABILITY NAMING CONVENTION
-//
-// It is important that capability names are unique. The naming convention
-// for capabilities that are specific to modules and blocks is as follows:
-// [mod/block]/<component_name>:<capabilityname>
-//
-// component_name should be the same as the directory name of the mod or block.
-//
-// Core moodle capabilities are defined thus:
-// moodle/<capabilityclass>:<capabilityname>
-//
-// Examples: mod/forum:viewpost
-// block/recent_activity:view
-// moodle/site:deleteuser
-//
-// The variable name for the capability definitions array follows the format
-// $<componenttype>_<component_name>_capabilities
-//
-// For the core capabilities, the variable is $moodle_capabilities.
-
-$block_elis_info_capabilities = array(
-
- 'block/elis_info:view' => array(
- 'riskbitmask' => RISK_CONFIG,
- 'captype' => 'read',
- 'contextlevel' => CONTEXT_SYSTEM,
- 'legacy' => array(
- 'admin' => CAP_ALLOW
- )
- )
-);
-
-?>
144 addons/blocks/elis_info/elis_info.php
View
@@ -1,144 +0,0 @@
-<?php // $Id$
-/**
- * elis_info.php - display elis component information
- *
- * @uses $COURSE, $CFG, $USER
- * @author Brent Boghosian <brent.boghosian@remote-learner.net>
- * @version 1.0
- * @package block elis_info
- *
- **/
-
-require_once(dirname(__FILE__)."/../../config.php" );
-require_once("{$CFG->dirroot}/blocks/moodleblock.class.php");
-
-global $COURSE, $USER;
-
-$strelisinfo = get_string('elis_info', 'block_elis_info');
-
-// Build navigation
-$navlinks = array();
-//$navlinks[] = array('name' => $strelisinfo);
-$navlinks[] = array('name' => $strelisinfo, 'link' => null, 'type' => 'misc');
-$navigation = build_navigation($navlinks);
-if (!($site = get_site())) {
- print_error('no_site', 'block_elis_info');
-}
-print_header($site->fullname, $strelisinfo, $navigation, '', '', true, '');
-
-// if ($COURSE->id != SITEID) { TBD }
-$context = get_context_instance(CONTEXT_SYSTEM, SITEID); // SYSTEM context
-if (!has_capability('block/elis_info:view', $context)) {
- print_error('no_privilege', 'block_elis_info');
-}
-
-echo "<center><br/>\n";
-echo '<table class="elis_info" cellpadding="3" cellspacing="3" border="1"><tr class="elis_info">'."\n";
-echo ' <th class="elis_info">'.get_string('elis_component', 'block_elis_info').
- "</th>\n";
-echo ' <th class="elis_info">'.get_string('elis_version', 'block_elis_info').
- "</th>\n";
-echo "</tr>\n";
-
-$plugins = array();
-$cnt = 0;
-$authplugins = get_list_of_plugins('auth');
-foreach ($authplugins as $authplugin) {
- $plugins[$cnt] = new stdClass;
- $plugins[$cnt]->dir = "auth/{$authplugin}";
- $plugins[$cnt]->obj = get_auth_plugin($authplugin);
- ++$cnt;
-}
-$blockplugins = get_list_of_plugins('blocks');
-foreach ($blockplugins as $blockplugin) {
- $plugins[$cnt] = new stdClass;
- $plugins[$cnt]->dir = "blocks/{$blockplugin}";
- $plugins[$cnt]->obj = "block_{$blockplugin}";
- ++$cnt;
-}
-$coursefmtplugins = get_list_of_plugins('course/format');
-foreach ($coursefmtplugins as $coursefmtplugin) {
- $plugins[$cnt] = new stdClass;
- $plugins[$cnt]->dir = "course/format/{$coursefmtplugin}";
- // TBD: no object for course/format?
- ++$cnt;
-}
-$enrolplugins = get_list_of_plugins('enrol');
-// require class enrolment_factory for enrolplugin
-require_once("{$CFG->dirroot}/enrol/enrol.class.php");
-foreach ($enrolplugins as $enrolplugin) {
- $plugins[$cnt] = new stdClass;
- $plugins[$cnt]->dir = "enrol/{$enrolplugin}";
- $plugins[$cnt]->obj = enrolment_factory::factory($enrolplugin);
- ++$cnt;
-}
-$filterplugins = get_list_of_plugins('filter');
-foreach ($filterplugins as $filterplugin) {
- $plugins[$cnt] = new stdClass;
- $plugins[$cnt]->dir = "filter/{$filterplugin}";
- // TBD: no object for filters?
- ++$cnt;
-}
-$modplugins = get_list_of_plugins('mod');
-foreach ($modplugins as $modplugin) {
- $plugins[$cnt] = new stdClass;
- $plugins[$cnt]->dir = "mod/{$modplugin}";
- $plugins[$cnt]->obj = "mod_{$modplugin}";
- ++$cnt;
-}
-$assigntypeplugins = get_list_of_plugins('mod/assignment/type');
-// require class assignment_base for assigntypeplugin
-require_once("{$CFG->dirroot}/mod/assignment/lib.php");
-foreach ($assigntypeplugins as $assigntypeplugin) {
- $plugins[$cnt] = new stdClass;
- $plugins[$cnt]->dir = "mod/assignment/type/{$assigntypeplugin}";
- $classname = "assignment_{$assigntypeplugin}";
- $classfile = "{$CFG->dirroot}/{$plugins[$cnt]->dir}/assignment.class.php";
- if (!class_exists($classname) && file_exists($classfile)) {
- require_once($classfile);
- }
- if (class_exists($classname)) {
- $plugins[$cnt]->obj = new $classname;
- }
- ++$cnt;
-}
-//var_dump($plugins);
-foreach ($plugins as $curplugin) {
- $versionfile = "{$CFG->dirroot}/{$curplugin->dir}/version.php";
- $plugin_obj = new stdClass;
- if (file_exists($versionfile)) {
- if (is_readable($versionfile)) {
- //error_log("blocks/elis_info.php: checking version file '{$versionfile}'");
- $plugin = new stdClass;
- $module = new stdClass;
- include($versionfile); // include_once() fails for 'mod'
- $plugin_obj = property_exists($module, 'release')
- ? $module : $plugin; // modules : filters
- } else {
- error_log("blocks/elis_info.php: version file '$versionfile' not readable!");
- }
- } else if (property_exists($curplugin, 'obj')) {
- if (is_object($curplugin->obj)) {
- $plugin_obj = $curplugin->obj; // auth, enrol?
- } else {
- $classfile = "{$CFG->dirroot}/{$curplugin->dir}/{$curplugin->obj}.php";
- if (!class_exists($curplugin->obj) &&
- file_exists($classfile)) {
- include_once($classfile);
- }
- if (class_exists($curplugin->obj)) {
- $plugin_obj = new $curplugin->obj; // blocks ...
- }
- }
- }
- if (property_exists($plugin_obj, 'release')) {
- echo "<tr><td class=\"elis_info\">{$curplugin->dir}</td>\n";
- echo " <td class=\"elis_info\">{$plugin_obj->release}</td>\n</tr>\n";
- }
-}
-
-echo "</table>\n";
-echo "</center>\n";
-print_footer($COURSE);
-
-?>
14 addons/blocks/elis_info/lang/en_utf8/block_elis_info.php
View
@@ -1,14 +0,0 @@
-<?php
-
-$string['blockname'] = 'ELIS Component Info';
-
-$string['elis_component'] = 'ELIS Component';
-$string['elis_info'] = 'ELIS Component Info';
-$string['elis_info:view'] = 'View ELIS component information';
-$string['elis_release'] = 'ELIS Component Version: ';
-$string['elis_version'] = 'Version';
-
-$string['no_privilege'] = 'You do not have privileges to view ELIS Component Info';
-$string['no_site'] = 'Site not defined!';
-
-?>
5 core/admin/styles.css
View
@@ -0,0 +1,5 @@
+
+.role_tables {
+ overflow-x: auto;
+ padding-bottom: 5px;
+}
39 core/admin/tool/phpunittest/db/access.php
View
@@ -0,0 +1,39 @@
+<?php
+
+///////////////////////////////////////////////////////////////////////////
+// //
+// NOTICE OF COPYRIGHT //
+// //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment //
+// http://moodle.com //
+// //
+// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
+// //
+// This program is free software; you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation; either version 2 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details: //
+// //
+// http://www.gnu.org/copyleft/gpl.html //
+// //
+///////////////////////////////////////////////////////////////////////////
+
+$capabilities = array(
+
+ 'tool/phpunittest:view' => array(
+ 'riskbitmask' => RISK_DATALOSS,
+ 'captype' => 'read',
+ 'contextlevel' => CONTEXT_SYSTEM,
+ 'archetypes' => array(
+ 'manager' => CAP_ALLOW
+ ),
+
+ 'clonepermissionsfrom' => 'moodle/site:config',
+ )
+);
+
417 core/admin/tool/phpunittest/ex_phpunit_test.php
View
@@ -0,0 +1,417 @@
+<?php
+/**
+ * A PHPUnit test GroupTest that automatically finds all the
+ * test files in a directory tree according to certain rules.
+ * From: /admin/tool/unittest/ex_simple_test.php
+ *
+ * ELIS(TM): Enterprise Learning Intelligence Suite
+ * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package tool
+ * @subpackage phpunitest
+ * @author Remote-Learner.net Inc
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
+ */
+
+if (!defined('MOODLE_INTERNAL')) {
+ die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
+}
+
+require_once('PHPUnit/Framework.php');
+require_once(dirname(__FILE__).'/../../../config.php');
+
+if (!defined('LANG_FILE')) {
+ define('LANG_FILE', 'tool_phpunittest');
+}
+
+/**
+ * This is a composite test class for finding test cases and
+ * other RunnableTest classes in a directory tree and combining
+ * them into a group test.
+ * @package SimpleTestEx
+ */
+class AutoGroupTest extends PHPUnit_Framework_TestSuite {
+
+ var $thorough;
+ var $progress;
+ var $showsearch;
+ var $outhandle;
+ var $async;
+
+ function AutoGroupTest($outhandle, $showsearch, $progress, $async = false, $thorough = false, $test_name = null) {
+ //$this->TestSuite($test_name);
+ $this->outhandle = $outhandle;
+ $this->setName(empty($test_name) ? "noname" : $test_name);
+ $this->showsearch = $showsearch;
+ $this->progress = $progress;
+ $this->async = $async;
+ $this->thorough = $thorough;
+ //$incfiles = get_included_files();
+ //print_object($incfiles);
+ }
+
+ function setLabel($test_name) {
+ //:HACK: there is no GroupTest::setLabel, so access parent::_label.
+ $this->_label = $test_name;
+ }
+
+ /**
+ * @return resource - file handle object
+ */
+ function getHandle() {
+ return $this->outhandle;
+ }
+
+ function addIgnoreFolder($ignorefolder) {
+ $this->ignorefolders[]=$ignorefolder;
+ }
+
+ function _recurseFolders($path) {
+ static $recurse;
+ if ($this->showsearch) {
+ $num = $recurse % 3;
+ test_output($this->outhandle, TEST_SEARCH_ID, "<li class=\"phpunittest testsearch dirlevel{$num}\">" . basename(realpath($path)) . "<ul class=\"phpunittest testsearch dirlevel{$num}\">");
+ }
+
+ $files = scandir($path);
+ static $s_count = 0;
+
+ foreach ($files as $file) {
+ if ($file == '.' || $file == '..') {
+ continue;
+ }
+ $file_path = $path . '/' . $file;
+ if (is_dir($file_path)) {
+ if ($file != 'CVS' && $file != '.git' && !in_array($file_path, $this->ignorefolders)) {
+ ++$recurse;
+ $this->_recurseFolders($file_path);
+ --$recurse;
+ }
+ } elseif (preg_match('/phpunit(\/|\\\\)test.*\.php$/', $file_path) ||
+ ($this->thorough && preg_match('/phpunit(\/|\\\\)slowtest.*\.php$/', $file_path))) {
+
+ $s_count++;
+ // OK, found: this shows as a 'Notice' for any 'simpletest/test*.php' file.
+ //$this->addTestCase(new FindFileNotice($file_path, 'Found unit test file, '. $s_count));
+
+ // addTestFile: Unfortunately this doesn't return fail/success (bool).
+ $this->addTestFile($file_path, true);
+ }
+ }
+
+ if ($this->showsearch) {
+ test_output($this->outhandle, TEST_SEARCH_ID, '</ul>'. '</li>');
+ }
+ return $s_count;
+ }
+
+ function findTestFiles($dir) {
+ if ($this->showsearch) {
+ $param = new stdClass;
+ $param->path = realpath($dir);
+ test_output($this->outhandle, TEST_SEARCH_ID,
+ get_string('searchingfolder', LANG_FILE, $param) .'<ul class="phpunittest testsearch">');
+ }
+ $path = $dir;
+ $count = $this->_recurseFolders($path);
+ // BJB101201: simpletest::addTestCase() => phpunit::addTest
+ if ($count <= 0) {
+ $this->addTest(new BadAutoGroupTest($this->outhandle, $path,
+ get_string('nounittestsfound', LANG_FILE),
+ $this->progress, $this->async));
+ } else {
+ $param = new stdClass;
+ $param->count = $count;
+ $this->addTest(new AutoGroupTestNotice($this->outhandle, $path,
+ get_string('totalfound', LANG_FILE, $param),
+ $this->progress, $this->async));
+ }
+ if ($this->showsearch) {
+ test_output($this->outhandle, TEST_SEARCH_ID, '</ul>');
+ }
+ return $count;
+ }
+
+ function addTestFile($file, $internalcall = false) {
+ if ($this->showsearch) {
+ if ($internalcall) {
+ test_output($this->outhandle, TEST_SEARCH_ID, '<li class="phpunittest testsearch"><b>' . basename($file) . '</b></li>');
+ } else {
+ test_output($this->outhandle, TEST_SEARCH_ID, '<li class="phpunittest testsearch">'. get_string('addingtest', LANG_FILE) . realpath($file) . '</li>');
+ }
+
+ // Make sure that syntax errors show up suring the search, otherwise you often
+ // get blank screens because evil people turn down error_reporting elsewhere.
+ //error_reporting(E_ALL); // causes PHPUnit tests to fail!?!
+ }
+ if(!is_file($file) ){
+ parent::addTestCase(new BadTest($this->outhandle, $file,
+ get_string('notafile', LANG_FILE)));
+ }
+ parent::addTestFile($file);
+ }
+}
+
+
+/* ======================================================================= */
+// get_class_ex: Insert spaces to prettify the class-name.
+function get_class_ex($object) {
+ return preg_replace('/(.?)([A-Z])/', '${1} ${2}', get_class($object));
+}
+
+
+/**
+ * A failing test base-class for when a test suite has NOT loaded properly.
+ */
+class BadTest implements PHPUnit_Framework_Test
+{ // added implements for phpunit
+
+ var $label;
+ var $error;
+ var $progress;
+ var $outhandle;
+ var $async;
+
+ function BadTest($outhandle, $label, $error, $progress = false, $async = false) {
+ $this->label = $label;
+ $this->error = $error;
+ $this->progress = $progress;
+ $this->async = $async;
+ $this->outhandle = $outhandle;
+ }
+
+ function getLabel() {
+ return $this->label;
+ }
+
+ // Implement PHPUnit_Framework_Test::void run(PHPUnit_Framework_TestResult $result)
+ // was: function run(&$reporter) {
+ function run(PHPUnit_Framework_TestResult $reporter = NULL) {
+ if ($this->progress && !$this->async) {
+ test_output($this->outhandle, TEST_OUTTER_PROGRESS_ID,
+ '</div><br />', 100);
+ }
+ test_output($this->outhandle, TEST_RESULTS_ID, get_string('notestsfound', LANG_FILE) . '<hr />');
+ //$reporter->paintGroupStart(basename(__FILE__), $this->getSize());
+ //$reporter->paintFail(get_class_ex($this) .' ['. $this->getLabel() .'] with error ['. $this->error .']');
+ //$reporter->paintGroupEnd($this->getLabel());
+ //return $reporter->getStatus();
+
+ // HACK: should do this once in index.php but $outhandle corrupt!?!
+ if ($this->async) {
+ test_output($this->outhandle, TEST_COMPLETE_ID, get_string('testscomplete', LANG_FILE), 100);
+ // $outhandle now filename since update.php won't read open file!?!
+ //fclose($this->outhandle);
+ }
+ }
+
+ /**
+ * @return int the number of test cases starting.
+ */
+ function getSize() {
+ return 0;
+ }
+
+ /**
+ * Implement PHPUnit_Framework_Test::int count()
+ * @return # of tests
+ */
+ function count() { return $this->getSize(); }
+}
+
+/**
+ * An informational notice base-class for when a test suite is being processed.
+ * See class, simple_test.php: BadGroupTest.
+ * @package SimpleTestEx
+ */
+class Notice implements PHPUnit_Framework_Test
+{
+ var $label;
+ var $status;
+ var $progress;
+ var $outhandle;
+ var $async;
+
+ function Notice($outhandle, $label, $error, $progress = false, $async = false) {
+ $this->label = $label;
+ $this->status = $error;
+ $this->progress = $progress;
+ $this->async = $async;
+ $this->outhandle = $outhandle;
+ }
+
+ function getLabel() {
+ return $this->label;
+ }
+
+ // Implement PHPUnit_Framework_Test::void run(PHPUnit_Framework_TestResult $result)
+ // was: function run(&$reporter) {
+ function run(PHPUnit_Framework_TestResult $reporter = NULL)
+ {
+ global $CFG, $showpasses;
+
+ if (!empty($reporter)) {
+ if ($this->progress && !$this->async) {
+ test_output($this->outhandle, TEST_OUTTER_PROGRESS_ID,
+ '</div><br />', 100);
+ }
+ if (method_exists($reporter, 'paintGroupStart'))
+ $reporter->paintGroupStart(basename(__FILE__), $this->getSize());
+ //else
+ // test_output($this->outhandle, TEST_RESULTS_ID, basename(__FILE__)." size(".$this->getSize().") <br/>\n");
+
+ if (method_exists($reporter, 'paintNotice'))
+ $reporter->paintNotice(get_class_ex($this) .
+ ' ['. $this->getLabel() .'] with status [' . $this->status . ']');
+ else {
+ if (!$this->async ) {
+ test_output($this->outhandle, TEST_RESULTS_ID,
+ "<div id=\"na_results\">\n");
+ }
+ test_output($this->outhandle, TEST_RESULTS_ID,
+ $this->status ."<br/>&nbsp;<br/>\n", 100); // TBD
+ }
+
+ //print_object($reporter);
+
+ if ($reporter->errorCount() > 0) {
+ test_output($this->outhandle, TEST_RESULTS_ID, "<b>".get_string('errors', LANG_FILE).": ".$reporter->errorCount()
+ ."</b> <ul class=\"phpunittest testerror\">");
+ foreach($reporter->errors() as $key => $value) {
+ $this->print_testfailure($value, 'phpunittest testerror');
+ }
+ test_output($this->outhandle, TEST_RESULTS_ID, "</ul><br/>", 100);
+ } else {
+ test_output($this->outhandle, TEST_RESULTS_ID, get_string('noerrors', LANG_FILE)." <br/>&nbsp;<br/>\n", 100);
+ }
+
+ if ($showpasses) {
+ $passedtests = array_keys($reporter->passed());
+ if (!empty($passedtests)) {
+ test_output($this->outhandle, TEST_RESULTS_ID, get_string('passedtests', LANG_FILE).": ".count($passedtests)
+ ."<ul class=\"phpunittest testpass\">", 100);
+ foreach($reporter->passed() as $key => $value) {
+ test_output($this->outhandle, TEST_RESULTS_ID, "<li class=\"phpunittest testpass\">$key =&gt; ".($value ? $value : get_string('testok', LANG_FILE))."</li>\n", 100);
+ }
+ test_output($this->outhandle, TEST_RESULTS_ID, "</ul><br/>", 100);
+ } else {
+ test_output($this->outhandle, TEST_RESULTS_ID, get_string('nopassedtests', LANG_FILE)."<br/>&nbsp;<br/>\n", 100);
+ }
+ }
+
+ if ($reporter->failureCount() > 0) {
+ test_output($this->outhandle, TEST_RESULTS_ID, "<b>".get_string('failedtests', LANG_FILE).": ".$reporter->failureCount()
+ ."</b> <ul class=\"phpunittest testfail\">", 100);
+ foreach($reporter->failures() as $key => $value) {
+ $this->print_testfailure($value, 'phpunittest testfail');
+ }
+ test_output($this->outhandle, TEST_RESULTS_ID, "</ul><br/>", 100);
+ } else {
+ test_output($this->outhandle, TEST_RESULTS_ID, get_string('nofailures', LANG_FILE)." <br/>&nbsp;<br/>\n", 100);
+ }
+
+ if ($reporter->skippedCount() > 0) {
+ test_output($this->outhandle, TEST_RESULTS_ID, get_string('skippedtests', LANG_FILE).": ".$reporter->skippedCount()
+ ."<ul class=\"phpunittest testskipped\">\n", 100);
+ foreach($reporter->skipped() as $key => $value) {
+ $this->print_testfailure($value, 'phpunittest testskipped');
+ }
+ test_output($this->outhandle, TEST_RESULTS_ID, "</ul><br/>", 100);
+ } else {
+ test_output($this->outhandle, TEST_RESULTS_ID, get_string('noskippedtests', LANG_FILE)."<br/>&nbsp;<br/>\n", 100);
+ }
+
+ if ($reporter->notImplementedCount() > 0) {
+ test_output($this->outhandle, TEST_RESULTS_ID, get_string('notimplementedtests', LANG_FILE).": "
+ .$reporter->notImplementedCount()."<ul class=\"phpunittest testincomplete\">\n", 100);
+ foreach($reporter->notImplemented() as $key => $value) {
+ $this->print_testfailure($value, 'phpunittest testincomplete');
+ }
+ test_output($this->outhandle, TEST_RESULTS_ID, "</ul><br/>", 100);
+ } else {
+ test_output($this->outhandle, TEST_RESULTS_ID, get_string('nonotimplementedtests', LANG_FILE)."<br/>&nbsp;<br/>\n", 100);
+ }
+
+ if (method_exists($reporter, 'paintGroupEnd'))
+ $reporter->paintGroupEnd($this->getLabel());
+ else {
+ test_output($this->outhandle, TEST_RESULTS_ID, "<input type=\"button\" value=\"". get_string('clearresults', LANG_FILE)
+ ."\" onclick=\"cleartests();\"><hr/><br/>", 100);
+ if (!$this->async) {
+ test_output($this->outhandle, TEST_RESULTS_ID, "</div>");
+ }
+ }
+ //return $reporter->getStatus();
+ }
+
+ // HACK: should do this once in index.php but $outhandle corrupt!?!
+ if ($this->async) {
+ test_output($this->outhandle, TEST_COMPLETE_ID, get_string('testscomplete', LANG_FILE), 100);
+ // $outhandle now filename since update.php won't read open file!?!
+ //fclose($this->outhandle);
+ }
+
+ }
+
+ function getSize() {
+ return 0;
+ }
+
+ /**
+ * Implement PHPUnit_Framework_Test::int count()
+ * @return # of tests
+ */
+ function count() { return $this->getSize(); }
+
+ function print_testfailure( $testfailure, $class )
+ {
+ test_output($this->outhandle, TEST_RESULTS_ID,
+ "<li class=\"$class\">".$testfailure->failedTest()->getName()." =&gt; ");
+ test_output($this->outhandle, TEST_RESULTS_ID,
+ htmlspecialchars($testfailure->failedTest()->getStatusMessage())."<br/>\n");
+ $tracefiles = $testfailure->thrownException()->getTrace();
+ foreach ($tracefiles as $tfile) {
+ if (!empty($tfile['file']) && !stristr($tfile['file'], '/lib/pear/PHPUnit')) {
+ test_output($this->outhandle, TEST_RESULTS_ID,
+ htmlspecialchars($tfile['file']).":".$tfile['line']."<br/>\n");
+ }
+ }
+ //test_output($this->outhandle, TEST_RESULTS_ID, nl2br(htmlspecialchars($testfailure->thrownException()->xdebug_message)))
+ test_output($this->outhandle, TEST_RESULTS_ID, "</li>");
+ }
+}
+
+/**
+ * A failing folder test for when the test-user specifies an invalid directory
+ * (run.php?folder=woops).
+ * @package PHPUnitTestEx
+ */
+class BadFolderTest extends BadTest { }
+
+/**
+ * A failing auto test for when no unit test files are found.
+ * @package PHPUnitTestEx
+ */
+class BadAutoGroupTest extends BadTest { }
+
+/**
+ * Auto group test notices - 1. Search complete. 2. A test file has been found.
+ * @package PHPUNitTestEx
+ */
+class AutoGroupTestNotice extends Notice { }
+
+class FindFileNotice extends Notice { }
433 core/admin/tool/phpunittest/ex_reporter.php
View
@@ -0,0 +1,433 @@
+<?php
+/**
+ * A PHPUnit Test report format for Moodle.
+ * From: /admin/tool/phpunittest/ex_reporter.php
+ *
+ *
+ * ELIS(TM): Enterprise Learning Intelligence Suite
+ * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package tool
+ * @subpackage phpunitest
+ * @author Remote-Learner.net Inc
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
+ */
+
+if (!defined('MOODLE_INTERNAL')) {
+ die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
+}
+
+require_once($CFG->libdir . '/simpletestlib/reporter.php'); // TBD: use PHPUnit class
+
+if (!defined('LANG_FILE')) {
+ define('LANG_FILE', 'tool_phpunittest');
+}
+
+/**
+ * PHPUnit_Framework_TestListener implementation for showing test progress
+ * @package PHPUnitTests
+ */
+class PHPUnitTestListener implements PHPUnit_Framework_TestListener
+{
+ var $outhandle;
+ var $numtests;
+ var $curtest = 0;
+ var $init = false;
+
+ // Constructors
+ function PHPUnitTestListener( $outhandle )
+ {
+ $this->outhandle = $outhandle;
+ //parent::__construct();
+ }
+
+ function __construct( $outhandle )
+ {
+ $this->PHPUnitTestListener($outhandle);
+ }
+
+ public function
+ addError(PHPUnit_Framework_Test $test,
+ Exception $e,
+ $time)
+ {
+ $param = new stdClass;
+ $param->name = $test->getName();
+ test_output($this->outhandle, TEST_PROGRESS_ID,
+ get_string('testerror', LANG_FILE, $param) ."<br />\n",
+ $this->percentdone());
+ }
+
+ public function
+ addFailure(PHPUnit_Framework_Test $test,
+ PHPUnit_Framework_AssertionFailedError $e,
+ $time)
+ {
+ $param = new stdClass;
+ $param->name = $test->getName();
+ test_output($this->outhandle, TEST_PROGRESS_ID,
+ get_string('testfail', LANG_FILE, $param) ."<br />\n",
+ $this->percentdone());
+ }
+
+ public function
+ addIncompleteTest(PHPUnit_Framework_Test $test,
+ Exception $e,
+ $time)
+ {
+ $param = new stdClass;
+ $param->name = $test->getName();
+ test_output($this->outhandle, TEST_PROGRESS_ID,
+ get_string('testincomplete', LANG_FILE, $param) ."<br />\n",
+ $this->percentdone());
+ }
+
+ public function
+ addSkippedTest(PHPUnit_Framework_Test $test,
+ Exception $e,
+ $time)
+ {
+ $param = new stdClass;
+ $param->name = $test->getName();
+ test_output($this->outhandle, TEST_PROGRESS_ID,
+ get_string('testskipped', LANG_FILE, $param) ."<br />\n",
+ $this->percentdone());
+ }
+
+ public function startTest(PHPUnit_Framework_Test $test)
+ {
+ ++$this->curtest;
+ $sparams = new stdClass;
+ $sparams->num = $this->curtest;
+ $sparams->total = $this->numtests;
+ $sparams->name = $test->getName();
+ test_output($this->outhandle, TEST_PROGRESS_ID,
+ get_string('teststart', LANG_FILE, $sparams) . "<br />\n",
+ $this->percentdone());
+ }
+
+ public function endTest(PHPUnit_Framework_Test $test, $time)
+ {
+ $param = new stdClass;
+ $param->name = $test->getName();
+ test_output($this->outhandle, TEST_PROGRESS_ID,
+ get_string('testend', LANG_FILE, $param) .
+ sprintf("%.6f ms.<br />\n", 1000.0 * $time), $this->percentdone());
+
+ if (method_exists($test, 'hasFailed') && $test->hasFailed() == FALSE &&
+ method_exists($test, 'getResult') && $test->getResult() == NULL &&
+ method_exists($test, 'setResult') )
+ { // Bit of a hack, since TestResult for passed tests NULL set to string
+ $test->setResult(sprintf("%s: %.6f ms.",
+ get_string('testok', LANG_FILE), 1000.0 * $time));
+ }
+ }
+
+ public function
+ startTestSuite(PHPUnit_Framework_TestSuite $suite)
+ {
+ //$param = new stdClass;
+ //$param->name = $suite->getName();
+ //test_output($this->outhandle, TEST_PROGRESS_ID, get_string('suitestart', LANG_FILE, $param) ."<br />\n");
+ //print_object($suite);
+ //print_object(get_class_methods($suite));
+ if (!$this->init) { // Only want highest level suite count - total tests!
+ $this->numtests = $suite->count();
+ $this->init = true;
+ }
+ }
+
+ public function
+ endTestSuite(PHPUnit_Framework_TestSuite $suite)
+ {
+ //$param = new stdClass;
+ //$param->name = $suite->getName();
+ //$this->outhandle, TEST_PROGRESS_ID, get_string('suiteend', LANG_FILE, $param) ."<br />\n<hr />\n");
+ }
+
+ public function percentdone()
+ {
+ return( 100.0 * $this->curtest / $this->numtests );
+ }
+}
+
+/**
+ * Extended in-browser test displayer. HtmlReporter generates
+ * only failure messages and a pass count. ExHtmlReporter also
+ * generates pass messages and a time-stamp.
+ *
+ * @package SimpleTestEx
+ */
+if (!defined('BROKEN_CLASS')) {
+class ExHtmlReporter extends PHPUnit_Framework_TestResult // ..._TestListener ???
+{}
+} else {
+ // OLD simpletest class
+class ExHtmlReporter extends HtmlReporter {
+ // Options set when the class is created.
+ var $showpasses;
+
+ // Lang strings. Set in the constructor.
+ var $strrunonlyfolder;
+ var $strrunonlyfile;
+
+ var $strseparator;
+
+ /**
+ * Constructor.
+ *
+ * @param bool $showpasses Whether this reporter should output anything for passes.
+ */
+ function ExHtmlReporter($showpasses) {
+ global $CFG, $THEME;
+
+ //$this->HtmlReporter();
+ $this->showpasses = $showpasses;
+
+ $this->strrunonlyfolder = $this->get_string('runonlyfolder', LANG_FILE);
+ $this->strrunonlyfile = $this->get_string('runonlyfile', LANG_FILE);
+ $this->strseparator = get_separator();
+ }
+
+ /**
+ * Called when a pass needs to be output.
+ */
+ function paintPass($message) {
+ //(Implicitly call grandparent, as parent not implemented.)
+ parent::paintPass($message);
+ if ($this->showpasses) {
+ $this->_paintPassFail('pass', $message);
+ }
+ }
+
+ /**
+ * Called when a fail needs to be output.
+ */
+ function paintFail($message) {
+ // Explicitly call grandparent, not parent::paintFail.
+ SimpleScorer::paintFail($message);
+ $this->_paintPassFail('fail', $message, debug_backtrace());
+ }
+
+ /**
+ * Called when an error (uncaught exception or PHP error) needs to be output.
+ */
+ function paintError($message) {
+ // Explicitly call grandparent, not parent::paintError.
+ SimpleScorer::paintError($message);
+ $this->_paintPassFail('exception', $message);
+ }
+
+ /**
+ * Called when a caught exception needs to be output.
+ */
+ function paintException($exception) {
+ // Explicitly call grandparent, not parent::paintException.
+ SimpleScorer::paintException($exception);
+ $message = 'Unexpected exception of type [' . get_class($exception) .
+ '] with message ['. $exception->getMessage() .
+ '] in ['. $exception->getFile() .
+ ' line ' . $exception->getLine() . ']';
+ $stacktrace = null;
+ if (method_exists($exception, 'getTrace')) {
+ $stacktrace = $exception->getTrace();
+ }
+ $this->_paintPassFail('exception', $message, $stacktrace);
+ }
+
+ /**
+ * Private method. Used by printPass/Fail/Error/Exception.
+ */
+ function _paintPassFail($passorfail, $message, $stacktrace = null) {
+ global $FULLME, $CFG, $OUTPUT;
+
+ echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide '. $passorfail);
+ //^Was: print_simple_box_start('', '100%', '', 5, $passorfail . ' generalbox');
+ $url = $this->_htmlEntities($this->_stripParameterFromUrl($FULLME, 'path'));
+ echo '<b class="', $passorfail, '">', $this->get_string($passorfail), '</b>: ';
+ $breadcrumb = $this->getTestList();
+ array_shift($breadcrumb);
+ $file = array_shift($breadcrumb);
+ $pathbits = preg_split('/\/|\\\\/', substr($file, strlen($CFG->dirroot) + 1));
+ $file = array_pop($pathbits);
+ $folder = '';
+ foreach ($pathbits as $pathbit) {
+ $folder .= $pathbit . '/';
+ echo "<a href=\"{$url}path=$folder\" title=\"$this->strrunonlyfolder\">$pathbit</a>/";
+ }
+ echo "<a href=\"{$url}path=$folder$file\" title=\"$this->strrunonlyfile\">$file</a>";
+ echo $this->strseparator, implode($this->strseparator, $breadcrumb);
+ echo $this->strseparator, '<br />', $this->_htmlEntities($message), "\n\n";
+ if ($stacktrace) {
+ $dotsadded = false;
+ $interestinglines = 0;
+ $filteredstacktrace = array();
+ foreach ($stacktrace as $frame) {
+ if (empty($frame['file']) || (strpos($frame['file'], 'simpletestlib') === false
+ && strpos($frame['file'], 'report/unittest') === false)) {
+ $filteredstacktrace[] = $frame;
+ $interestinglines += 1;
+ $dotsadded = false;
+ } else if (!$dotsadded) {
+ $filteredstacktrace[] = array('line' => '...', 'file' => '...');
+ $dotsadded = true;
+ }
+ }
+ if ($interestinglines > 1 || $passorfail == 'exception') {
+ echo '<div class="notifytiny">' . phpunit_format_backtrace($filteredstacktrace) . "</div>\n\n";
+ }
+ }
+ echo $OUTPUT->box_end();
+ flush();
+ }
+
+ /**
+ * Called when a notice needs to be output.
+ */
+ function paintNotice($message) {
+ $this->paintMessage($this->_htmlEntities($message));
+ }
+
+ /**
+ * Paints a simple supplementary message.
+ * @param string $message Text to display.
+ */
+ function paintMessage($message) {
+ if ($this->showpasses) {
+ echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
+ //^Was: print_simple_box_start('', '100%');
+ echo '<span class="notice">', $this->get_string('notice'), '</span>: ';
+ $breadcrumb = $this->getTestList();
+ array_shift($breadcrumb);
+ echo implode($this->strseparator, $breadcrumb);
+ echo $this->strseparator, '<br />', $message, "\n";
+ echo $OUTPUT->box_end();
+ flush();
+ }
+ }
+
+ /**
+ * Output anything that should appear above all the test output.
+ */
+ function paintHeader($test_name) {
+ // We do this the moodle way instead.
+ }
+
+ /**
+ * Output anything that should appear below all the test output, e.g. summary information.
+ */
+ function paintFooter($test_name) {
+ $summarydata = new stdClass;
+ $summarydata->run = $this->getTestCaseProgress();
+ $summarydata->total = $this->getTestCaseCount();
+ $summarydata->passes = $this->getPassCount();
+ $summarydata->fails = $this->getFailCount();
+ $summarydata->exceptions = $this->getExceptionCount();
+
+ if ($summarydata->fails == 0 && $summarydata->exceptions == 0) {
+ $status = "passed";
+ } else {
+ $status = "failed";
+ }
+ echo '<div class="unittestsummary ', $status, '">';
+ echo $this->get_string('summary', $summarydata);
+ echo '</div>';
+
+ $param1 = new stdClass;
+ $param1->date = date('<b>d-m-Y H:i T</b>');
+ $param2 = new stdClass;
+ $param2->version = SimpleTestOptions::getVersion();
+ echo '<div class="performanceinfo">',
+ $this->get_string('runat', $param1),
+ $this->get_string('version', $param2),
+ '</div>';
+ }
+
+ /**
+ * Strip a specified parameter from the query string of a URL, if present.
+ * Adds a separator to the end of the URL, so that a new parameter
+ * can easily be appended. For example (assuming $param = 'frog'):
+ *
+ * http://example.com/index.php -> http://example.com/index.php?
+ * http://example.com/index.php?frog=1 -> http://example.com/index.php?
+ * http://example.com/index.php?toad=1 -> http://example.com/index.php?toad=1&
+ * http://example.com/index.php?frog=1&toad=1 -> http://example.com/index.php?toad=1&
+ *
+ * @param string $url the URL to modify.
+ * @param string $param the parameter to strip from the URL, if present.
+ *
+ * @return string The modified URL.
+ */
+ function _stripParameterFromUrl($url, $param) {
+ $url = preg_replace('/(\?|&)' . $param . '=[^&]*&?/', '$1', $url);
+ if (strpos($url, '?') === false) {
+ $url = $url . '?';
+ } else {
+ $url = $url . '&';
+ }
+ return $url;
+ }
+
+ /**
+ * Look up a lang string in the appropriate file.
+ */
+ function get_string($identifier, $a = NULL) {
+ return get_string($identifier, LANG_FILE, $a);
+ }
+}
+} // END 'BROKEN_CLASS'
+
+/**
+ * Formats a backtrace ready for output.
+ *
+ * @param array $callers backtrace array, as returned by debug_backtrace().
+ * @param boolean $plaintext if false, generates HTML, if true generates plain text.
+ * @return string formatted backtrace, ready for output.
+ */
+function phpunit_format_backtrace($callers, $plaintext = false) {
+ // do not use $CFG->dirroot because it might not be available in destructors
+ $dirroot = dirname(dirname(__FILE__));
+
+ if (empty($callers)) {
+ return '';
+ }
+
+ $from = $plaintext ? '' : '<ul style="text-align: left">';
+ foreach ($callers as $caller) {
+ if (!isset($caller['line'])) {
+ $caller['line'] = '?'; // probably call_user_func()
+ }
+ if (!isset($caller['file'])) {
+ $caller['file'] = 'unknownfile'; // probably call_user_func()
+ }
+ $from .= $plaintext ? '* ' : '<li>';
+ $from .= 'line ' . $caller['line'] . ' of ' . str_replace($dirroot, '', $caller['file']);
+ if (isset($caller['function'])) {
+ $from .= ': call to ';
+ if (isset($caller['class'])) {
+ $from .= $caller['class'] . $caller['type'];
+ }
+ $from .= $caller['function'] . '()';
+ } else if (isset($caller['exception'])) {
+ $from .= ': '.$caller['exception'].' thrown';
+ }
+ $from .= $plaintext ? "\n" : '</li>';
+ }
+ $from .= $plaintext ? '' : '</ul>';
+
+ return $from;
+}
576 core/admin/tool/phpunittest/index.php
View
@@ -0,0 +1,576 @@
+<?php
+/**
+ * Run the unit tests.
+ * From: /admin/tool/phpunittest/index.php
+ *
+ * ELIS(TM): Enterprise Learning Intelligence Suite
+ * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package tool
+ * @subpackage phpunitest
+ * @author Remote-Learner.net Inc
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
+ */
+
+require_once(dirname(__FILE__).'/../../../config.php');
+
+require_once($CFG->libdir.'/adminlib.php');
+require_once($CFG->libdir.'/phpunittestlib.php');
+require_once('ex_phpunit_test.php');
+require_once('ex_reporter.php');
+
+// CGI arguments
+$path = optional_param('path', null, PARAM_PATH);
+$showpasses = optional_param('showpasses', false, PARAM_BOOL);
+$showsearch = optional_param('showsearch', false, PARAM_BOOL);
+$thorough = optional_param('thorough', false, PARAM_BOOL);
+$progress = optional_param('progress', false, PARAM_BOOL);
+$async = optional_param('async', false, PARAM_BOOL);
+
+$filename = null;
+$langfile = LANG_FILE;
+$testdir = "{$CFG->dataroot}/phpunittests";
+$debug_all = DEBUG_ALL; // require var for javascript
+$debug_err = get_string('debugsettoalljs', $langfile);
+$testinprogress = get_string('testinprogress', $langfile);
+$strtitle = get_string('phpunittests', $langfile);
+$progress_str = get_string('progress', $langfile) . '<br />';
+$testscomplete = get_string('testscomplete', $langfile);
+
+/* The UNITTEST constant can be checked elsewhere if you need to know
+ * when your code is being run as part of a unit test. */
+define('UNITTEST', true);
+
+global $COURSE, $OUTPUT, $PAGE, $SITE;
+$COURSE = clone($SITE);
+
+$context = get_context_instance(CONTEXT_SYSTEM);
+$PAGE->set_context($context);
+$PAGE->requires->css('/admin/tool/phpunittest/styles.css');
+$PAGE->set_url('/admin/tool/phpunittest/index.php');
+$PAGE->set_title(get_string('phpunittests', $langfile));
+$PAGE->set_heading(get_string('phpunittests', $langfile));
+
+if ($async) { // force javascript not to wait for initial response!
+ $progress = 1;
+ $filename = required_param('filename', PARAM_PATH);
+ header("Connection: close\r\n");
+ header("Content-Encoding: none\r\n");
+ header("Content-Length: 0\r\n");
+ ignore_user_abort(true); // TBD?
+ set_time_limit(0); // TBD: run script until completed
+ flush();
+} else {
+ // Print the header.
+ admin_externalpage_setup('tool_phpunittest', '', array('showpasses' => $showpasses,
+ 'showsearch' => $showsearch, 'progress' => $progress,
+ 'thorough' => $thorough));
+
+ echo $OUTPUT->header();
+
+ // required javascript code
+ echo <<<EOT
+<!-- Combo-handled YUI CSS files: -->
+<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.8.2r1/build/progressbar/assets/skins/sam/progressbar.css&2.8.2r1/build/slider/assets/skins/sam/slider.css">
+<!-- Combo-handled YUI JS files: -->
+<script type="text/javascript" src="http://yui.yahooapis.com/combo?2.8.2r1/build/yahoo-dom-event/yahoo-dom-event.js&2.8.2r1/build/animation/animation-min.js&2.8.2r1/build/element/element-min.js&2.8.2r1/build/progressbar/progressbar-min.js&2.8.2r1/build/dragdrop/dragdrop-min.js&2.8.2r1/build/slider/slider-min.js"></script>
+<script type="text/javascript">
+//<![CDATA[
+
+var testinprogress = false;
+var timer = 0;
+var refreshtime = 500; // TBD: half second requests ???
+var updateurl = "{$CFG->wwwroot}/admin/tool/phpunittest/update.php";
+var filename;
+var lasttftime = 0;
+var testcomplete = false;
+var progressbar;
+var review = false;
+var updating_page = false;
+
+function lpad(n, tot, ch)
+{
+ var snum = n.toString();
+ while (tot > snum.length)
+ {
+ snum = ch + snum;
+ }
+ return snum;
+}
+
+function getupdate( fname, tftime )
+{
+ refreshdivs(window.updateurl + "?fromtime=" + tftime + "&filename=" + fname);
+}
+
+function getRequestObj() {
+ var xmlObj = null;
+ if ( "XMLHttpRequest" in window ) {
+ return new XMLHttpRequest();
+ } else if ( "ActiveXObject" in window ) {
+ var prodId = [ "MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP" ];
+ for ( x in prodId ) {
+ if (xmlObj = new ActiveXObject(prodId[x])) {
+ break;
+ }
+ } delete x;
+ return xmlObj;
+ } else {
+ if ( "createRequest" in window ) {
+ return window.createRequest();
+ }
+ }
+ return xmlObj;
+}
+
+var AjaxUpdate = ( function() {
+ this.xml = getRequestObj();
+} ); AjaxUpdate.prototype = {
+ Ready : ( function( url, sets ) {
+ if ( this.xml ) {
+ if (!window.testinprogress) { // TBD: M$ IE
+ this.xml.abort();
+ return false;
+ }
+ sets.method = sets.method.toUpperCase();
+ (( "overrideMimeType" in this.xml ) ? this.xml.overrideMimeType("text/xml") : this.xml );
+ this.xml.onreadystatechange = ( function( ) {
+ if (document.all && (this.status != 200 || !window.testinprogress)) { // M$ IE
+ window.testinprogress = false;
+ this.abort();
+ return false;
+ }
+ if ( { 4 : 4, complete : 4 }[ this.readyState ] ) {
+ sets.onReady(
+ this.getResponseHeader("divid"),
+ this.getResponseHeader("tftime"),
+ this.getResponseHeader("percent"),
+ this.responseText
+ );
+ return true;
+ }
+ if (document.all && !window.updating_page && window.testinprogress) { // M$ IE
+ window.lasttftime = parseFloat(window.lasttftime) + 0.000001;
+ window.timer =
+ setTimeout( function () { getupdate(window.filename, window.lasttftime); },
+ window.refreshtime);
+ }
+ } );
+ this.xml.open( sets.method, url, true );
+ (( sets.method === "POST" ) ? this.xml.setRequestHeader("Content-Type", "application/www-x-form-urlencoded; " + sets.charset + ";" ) : this.xml );
+ this.xml.send(((sets.method === "POST") ? " " : null));
+ } return false;
+ } )
+}; var HandleUpdate;
+var refreshdivs = function( url ) {
+ //alert("refreshdivs( " + url + " )");
+ var xmlHttp = new AjaxUpdate();
+ xmlHttp.Ready( url, {
+ method : "GET",
+ charset : "UTF-8",
+ onReady : ( HandleUpdate = function( divid, tftime, percentdone, response ) {
+ //alert('divid: ' + divid + ' tftime: ' + tftime + ' percent: ' + percentdone);
+ // above tests new browser supports getResponseHeader
+ window.updating_page = true;
+ if (divid != null && divid != "" && tftime > window.lasttftime) { // M$ IE
+ ipercent = (divid != 'complete') ? parseInt(percentdone) : 100; // M$ IE
+ pbv_div = document.getElementById('pb_value');
+ if (pbv_div && (!pbv_div.innerHTML || ipercent > parseInt(pbv_div.innerHTML))) {
+ window.progressbar.set('value', ipercent);
+ if (ipercent == 100) {
+ pbv_div.innerHTML = "100% - {$testscomplete}";
+ window.testcomplete = true;
+ } else {
+ pbv_div.innerHTML = ipercent + "%";
+ }
+ }
+ if (divid != 'complete') {
+ var div = document.getElementById(divid);
+ if (!div && document.all) {
+ div = document.all[divid];
+ }
+ if (div) {
+ var current = div.innerHTML;
+ div.innerHTML = current + response;
+ window.lasttftime = tftime; // TBD: moved from above
+ if (divid == 'progress') { // progress scrollbar to bottom
+ // scroll progress to bottom
+ div.scrollTop = (div.scrollHeight > 0) ? div.scrollHeight
+ : div.offsetHeight;
+ } //else alert('divid: ' + divid + ' tftime: ' + tftime + ' percent: ' + percentdone);
+ }
+ } else {
+ if (!window.review) {
+ var prevtests = document.getElementById('prevtests');
+ var testtime = window.filename.substring(
+ window.filename.lastIndexOf('/') + 1,
+ window.filename.lastIndexOf('.'));
+ //alert("Adding new test: " + testtime);
+ var newOpt = document.createElement('option');
+ newOpt.value = testtime + '.out';
+ var testDate = new Date(testtime * 1000);
+ var month = lpad(testDate.getMonth() + 1, 2, '0');
+ newOpt.text = testDate.getFullYear() + '-' +
+ month + '-' + lpad(testDate.getDate(), 2, '0') +
+ ' ' + lpad(testDate.getHours(), 2, '0') + ':' +
+ lpad(testDate.getMinutes(), 2, '0') + ':' +
+ lpad(testDate.getSeconds(), 2, '0');
+
+ try {
+ prevtests.add(newOpt, null); // Standards compliant
+ } catch (ex) {
+ prevtests.add(newOpt); // M$ IE
+ }
+ }
+ canceltests();
+ if (this.abort) {
+ this.abort(); // TBD: M$ IE
+ }
+ window.updating_page = false;
+ return;
+ }
+ }
+ window.timer =
+ setTimeout( function () { getupdate(window.filename, window.lasttftime); },
+ window.refreshtime);
+ window.updating_page = false;
+ } )
+ } );
+};
+
+function canceltests()
+{
+ if (window.timer != 0) {
+ clearTimeout(window.timer);
+ window.timer = 0;
+ }
+ window.testinprogress = false;
+ //alert('Testing complete!'); // TBD
+}
+
+function cleartests()
+{
+ // clear any previous test output
+ if ((nadiv = document.getElementById('nonasync')) ||
+ (document.all && (nadiv = document.all['nonasync']))) {
+ nadiv.innerHTML = '';
+ }
+
+ if ((searchdiv = document.getElementById('outter_search')) ||
+ (document.all && (searchdiv = document.all['outter_search']))) {
+ searchdiv.innerHTML = '';
+ }
+
+ if ((progressbardiv = document.getElementById('progress_bar')) ||
+ (document.all && (progressbardiv = document.all['progress_bar']))) {
+ progressbardiv.innerHTML = '';
+ }
+
+ if ((pbvalue = document.getElementById('pb_value')) ||
+ (document.all && (pbvalue = document.all['pb_value']))) {
+ pbvalue.innerHTML = '';
+ }
+
+ if ((progressdiv = document.getElementById('outter_progress')) ||
+ (document.all && (progressdiv = document.all['outter_progress']))) {
+ progressdiv.innerHTML = '';
+ }
+
+ if ((resultsdiv = document.getElementById('results')) ||
+ (document.all && (resultsdiv = document.all['results']))) {
+ resultsdiv.innerHTML = '';
+ }
+
+ window.scroll(0,0);
+}
+
+function setTestFile( )
+{
+ var newTime = new Date() / 1000;
+ newTime = newTime.toString().substring(0, newTime.toString().indexOf('.'));
+ while ((newfile = "$testdir" + "/" + newTime + ".out") ==
+ document.phpunittest_form.filename.value)
+ {
+ newTime += 1;
+ }
+ window.filename = document.phpunittest_form.filename.value = newfile;
+}
+
+function run__tests( prev )
+{
+ //if ( $CFG->debug < $debug_all ) {
+ // alert('{$debug_err}');
+ // return false;
+ //}
+
+ if (window.testinprogress) {
+ alert('{$testinprogress}');
+ return false;
+ }
+
+ cleartests();
+ window.lasttftime = 0;
+ window.testcomplete = false;
+ var selopt = document.getElementById('prevtests');
+ window.review = (prev != 0);
+ //alert('window.review=' + window.review);
+ if (window.review) {
+ window.filename = '{$testdir}/' + selopt.options[prev].value;
+ document.phpunittest_form.async.checked = true;
+ } else {
+ selopt.selectedIndex = 0;
+ setTestFile();
+ }
+
+ if (document.phpunittest_form.async.checked == true) {
+ //alert('Running PHPUnit tests asynchronously!');
+ // setup progress bar
+ if ((progressbardiv = document.getElementById('progress_bar')) ||
+ (document.all && (progressbardiv = document.all['progress_bar']))) {
+ progressbardiv.innerHTML = "{$progress_str}";
+ }
+ window.progressbar = new YAHOO.widget.ProgressBar({
+ minValue: 0,
+ maxValue: 100,
+ value: 0,
+ height: 50,
+ width: 800,
+ ariaTextTemplate: '{value}%'
+ });
+ window.progressbar.render("progress_bar");
+
+ // run tests asynchronously
+ window.testinprogress = true;
+ if (window.review != true) {
+ initurl = "{$CFG->wwwroot}/admin/tool/phpunittest/index.php?async=1&filename=" + window.filename
+ + '&path=' + document.phpunittest_form.path.value
+ + '&progress=' + (document.phpunittest_form.progress.checked ? 1 : 0)
+ + '&showpasses=' + (document.phpunittest_form.showpasses.checked ? 1 : 0)
+ + '&showsearch=' + (document.phpunittest_form.showsearch.checked ? 1 : 0)
+ + '&thorough=' + (document.phpunittest_form.thorough.checked ? 1 : 0)
+ ;
+ initReq = getRequestObj();
+ // send initial request - start tests - don't care about this response!
+ initReq.open("GET", initurl, true);
+ initReq.timeout = 65535; // M$ IE
+ initReq.send(null);
+ }
+ window.timer =
+ setTimeout( function () { getupdate(window.filename, 0); },
+ window.refreshtime);
+ return false;
+ }
+ return true;
+}
+
+//]]>
+</script>
+EOT;
+
+ echo "<div id=\"phpunittests\">";
+}
+
+if (!is_null($path)) {
+
+ // Create/open test output file or stdout for non-async
+ $outhandle = ($async) ? $filename : 'php://output';
+ // NOTE: setting $outhandle to filename since update.php won't read from open file!
+ // still must open/create test output file.
+ if (($oh = fopen($outhandle, 'xb')) != false) {
+ fclose($oh);
+ } else {
+ if ($async) { // TBD: IF file_exists -> test already in progress?
+ error_log(__FILE__ .': '. get_string('createfileerr', $langfile));
+ }
+ print_error('createfileerr', $langfile);
+ }
+
+ if (!$async) { // require div around non-async output to clear in javascript
+ echo "<div id=\"nonasync\">";
+ } else if ($showsearch) {
+ test_output($outhandle, TEST_OUTTER_SEARCH_ID, '<br />'. get_string('search', $langfile) ."<div id=\"search\" style=\"width:98%;height:200px;background-color:#ffffff;border:1px solid;overflow:auto;\"></div>\n");
+ }
+
+ /* *********************************************
+ // PHPUnit3.5 behaves different when DEBUG_ALL or greater set
+ // but only if set _before_ including config.php (setup.php)
+ if ($CFG->debug < DEBUG_ALL) { // TBD: is problem in Moodle 2.0???
+ $param = new stdClass;
+ $param->href = $CFG->wwwroot .'/admin/settings.php?section=debugging';
+ if ($async) {
+ test_output($outhandle, TEST_SEARCH_ID,
+ get_string('debugsettoall', $langfile, $param));
+ test_output($outhandle, TEST_COMPLETE_ID, '');
+ }
+ print_error('debugsettoall', $langfile, '', $param);
+ }
+ ********************************************** */
+
+ // Create the group of tests.
+ $test =& new AutoGroupTest($outhandle, $showsearch, $progress, $async, $thorough);
+
+ // OU specific. We use the _nonproject folder for stuff we want to
+ // keep in CVS, but which is not really relevant. It does no harm
+ // to leave this here.
+ $test->addIgnoreFolder($CFG->dirroot . '/_nonproject');
+
+ // Make the reporter, which is what displays the test progress.
+ $reporter = ($progress) ? new PHPUnit_Framework_TestResult
+ : NULL;
+
+ if ($showsearch) {
+ echo $OUTPUT->heading(get_string('searchfortests', $langfile));
+ }
+ flush();
+
+ // Work out what to test.
+ if (substr($path, 0, 1) == '/') {
+ $path = substr($path, 1);
+ }
+ $path = $CFG->dirroot . '/' . $path;
+ if (substr($path, -1) == '/') {
+ $path = substr($path, 0, -1);
+ }
+ $displaypath = substr($path, strlen($CFG->dirroot) + 1);
+ $ok = true;
+ if (is_file($path)) {
+ $test->addTestFile($path);
+ } else if (is_dir($path)){
+ $test->findTestFiles($path);
+ } else {
+ $param = new stdClass;
+ $param->path = $path;
+ echo $OUTPUT->box(get_string('pathdoesnotexist', $langfile, $param), 'errorbox');
+ $ok = false;
+ }
+
+ // If we have something to test, do it.
+ if ($ok) {
+ $param = new stdClass;
+ if ($path == $CFG->dirroot) {
+ $param->path = get_string('all', $langfile);
+ $title = get_string('moodleunittests', $langfile, $param);
+ } else {
+ $param->path = $displaypath;
+ $title = get_string('moodleunittests', $langfile, $param);
+ }
+ echo $OUTPUT->heading($title);
+ if ($progress) {
+ test_output($outhandle, TEST_OUTTER_PROGRESS_ID, get_string('testprogress', $langfile) ."<div id=\"progress\" style=\"width:98%;height:200px;background-color:#ffffff;border:1px solid;overflow:auto;\">");
+ if ($async) {
+ test_output($outhandle, TEST_OUTTER_PROGRESS_ID, "</div>\n");
+ }
+ }
+ if ($reporter != NULL) {
+ $reporter->addListener(new PHPUnitTestListener($outhandle));
+ }
+ //print_object($outhandle);
+ $test->run($reporter);
+ //print_object($outhandle);
+ /* ********
+ NOTE: $outhandle becomes somehow corrupted, unset and unuseable after
+ call to: $test->run($reporter);
+ if ($async) {
+ test_output($outhandle, TEST_COMPLETE_ID, $testscomplete, 100);
+ fclose($outhandle);
+ }
+ ********* */
+ }
+
+ if (!$async) { // require div around non-async output to clear in javascript
+ echo "</div>";
+ }
+
+ $formheader = get_string('retest', $langfile);
+} else {
+ $displaypath = '';
+ $formheader = get_string('rununittests', $langfile);
+ // create directory for async test file output
+ if (!file_exists($testdir)) {
+ // create phpunittests directory in dataroot
+ if (!mkdir($testdir)) {
+ echo "Error: creating test directory: $testdir<br />\n";
+ }
+ } else {
+ // TBD: Check for still running test(s) ...
+ // if running test then use its' filename !?!
+ }
+}
+$filename = "{$testdir}/". time() .'.out';
+
+if (!$async) {
+ $prevtests = scandir($testdir);
+ $prevoptions = '';
+ if (!empty($prevtests)) {
+ foreach ($prevtests as $prevtest) {
+ if (($fdot = strpos($prevtest, '.')) != false) {
+ $prevtime = substr($prevtest, 0, $fdot);
+ if (is_numeric($prevtime) && $prevtime > 0 &&
+ ($prevdate = date('Y-m-d H:i:s', $prevtime)) != false) {
+ $prevoptions .= '<option value="'.$prevtest.'">'.$prevdate."</option>\n";
+ }
+ }
+ }
+ }
+ echo "<div id=\"progress_bar\"></div><div id=\"pb_value\"></div>\n";
+ echo "<div id=\"outter_search\"></div><br />\n";
+ echo "<div id=\"outter_progress\"></div><br />\n";
+ echo "<div id=\"results\"></div><br />\n";
+ echo "</div>";
+
+ // Print the form for adjusting options.
+ echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
+ //^Was: print_simple_box_start('center', '70%');
+ echo '<form name="phpunittest_form" method="get" action="index.php" '.
+ 'onsubmit="return run__tests(0);">';
+ echo '<fieldset class="invisiblefieldset">';
+ echo $OUTPUT->heading($formheader);
+ echo '<p>';
+ echo html_writer::checkbox('showpasses', 1, $showpasses, get_string('showpasses', $langfile));
+ echo '</p>';
+ echo '<p>';
+ echo html_writer::checkbox('showsearch', 1, $showsearch, get_string('showsearch', $langfile));
+ echo '</p>';
+ echo '<p>';
+ echo html_writer::checkbox('progress', 1, $progress, get_string('showprogress', $langfile));
+ echo '</p>';
+ echo '<p>';
+ echo html_writer::checkbox('async', 1, is_null($path), get_string('testasync', $langfile) ); //, '', 'if (document.phpunittest_form.async.checked == true) document.phpunittest_form.progress.checked = 1;');
+ echo '</p>';
+ echo '<p>';
+ echo html_writer::checkbox('thorough', 1, $thorough, get_string('thorough', $langfile));
+ echo '</p>';
+ echo '<p>';
+ echo '<label for="path">', get_string('onlytest', $langfile), '</label> ';
+ echo '<input type="text" id="path" name="path" value="'. $displaypath .'" size="40" />';
+ echo '</p>';
+ echo '<p>'. get_string('reviewtest', $langfile);
+ echo "<select id=\"prevtests\" onchange=\"if (this.selectedIndex > 0) run__tests(this.selectedIndex);\">\n";
+ echo '<option selected="yes">['.get_string('new')."]</option>\n";
+ if (!empty($prevoptions)) {
+ echo $prevoptions;
+ }
+ echo '</select></p>';
+ echo '<input type="hidden" id="filename" name="filename" value="'. $filename . '" />';
+ echo '<input type="submit" value="'. get_string('runtests', $langfile) .'" />';
+ echo '</fieldset>';
+ echo '</form>';
+ echo $OUTPUT->box_end();
+
+ // Footer.
+ echo $OUTPUT->footer();
+}
69 core/admin/tool/phpunittest/lang/en/tool_phpunittest.php
View
@@ -0,0 +1,69 @@
+<?php
+
+$string['addingtest'] = 'Adding test file: ';
+$string['all'] = 'ALL';
+$string['createfileerr'] = 'Error creating test output file.';
+$string['clearresults'] = 'Clear Results';
+$string['debugsettoall'] = '<b>Debugging</b> must be set to <em>DEBUG_ALL</em> or <em>DEBUG_DEVELOPER</em> for PHPUnit tests!<br /><a href=\'{$a->href}\'>Click here to set <b>Debugging</b>.</a>';
+$string['debugsettoalljs'] = 'Debugging must be set to DEBUG_ALL or DEBUG_DEVELOPER for PHPUnit tests!';
+$string['errors'] = 'Errors';
+$string['exception'] = 'Exception';
+$string['fail'] = 'Fail';
+$string['failedtests'] = 'Failed Tests';
+$string['ignorefile'] = 'Ignore tests in the file';
+$string['ignorethisfile'] = 'Re-run the tests ignoring this test file.';
+$string['moodleunittests'] = 'PHPUnit tests: {$a->path}';
+$string['noerrors'] = 'No errors!';
+$string['nofailures'] = 'No failures!';
+$string['nonotimplementedtests'] = 'No not-implemented tests!';
+$string['nopassedtests'] = 'No passed tests!';
+$string['noskippedtests'] = 'No skipped tests!';
+$string['notafile'] = 'Not a file or does not exist.';
+$string['notestsfound'] = '<b>No tests found!</b>';
+$string['notice'] = 'Notice';
+$string['notimplementedtests'] = 'Not Implemented Tests';
+$string['nounittestsfound'] = 'Search complete. No unit test files found';
+$string['onlytest'] = 'Only run tests in';
+$string['pass'] = 'Pass';
+$string['passedtests'] = 'Passed Tests';
+$string['pathdoesnotexist'] = 'The path \'{$a->path}\' does not exist.';
+$string['phpunittest:view'] = 'Run PHPUnit tests';
+$string['phpunittests'] = 'PHPUnit tests';
+$string['pluginname'] = 'PHPUnit tests';
+$string['progress'] = '<strong>Progress:</strong>';
+$string['tool_phpunittest'] = 'Run PHPUnit tests';
+$string['retest'] = 'Re-run the tests';
+$string['retestonlythisfile'] = 'Re-run only this test file.';
+$string['reviewtest'] = 'Review previous test: ';
+$string['runall'] = 'Run the tests from all the test files.';
+$string['runat'] = 'Run at {$a->date}.';
+$string['runonlyfile'] = 'Run only the tests in this file';
+$string['runonlyfolder'] = 'Run only the tests in this folder';
+$string['runtests'] = 'Run tests';
+$string['rununittests'] = 'Run the unit tests';
+$string['search'] = '<strong>Search:</strong>';
+$string['searchfortests'] = 'Searching for test cases';
+$string['searchingfolder'] = '<p>Searching folder: {$a->path}</p>';
+$string['showpasses'] = 'Show passes as well as fails.';
+$string['showprogress'] = 'Show progress of tests.';
+$string['showsearch'] = 'Show the search for test files.';
+$string['skippedtests'] = 'Skipped Tests';
+$string['stacktrace'] = 'Stack trace:';
+$string['suiteend'] = 'TestSuite \'{$a->name}\' ended.';
+$string['suitestart'] = 'TestSuite \'{$a->name}\' started.';
+$string['summary'] = '{$a->run}/{$a->total} test cases complete: <strong>{$a->passes}</strong> passes, <strong>{$a->fails}</strong> fails and <strong>{$a->exceptions}</strong> exceptions.';
+$string['testasync'] = 'Run tests asynchronously.';
+$string['testend'] = 'Test \'{$a->name}\' ended. Test time: ';
+$string['testerror'] = '<font color=\'darkred\'>Error while running test \'{$a->name}\'.</font>';
+$string['testfail'] = '<font color=\'red\'>Test \'{$a->name}\' failed.</font>';
+$string['testincomplete'] = '<font color=\'blue\'>Test \'{$a->name}\' is incomplete.</font>';
+$string['testinprogress'] = 'Test already in progress!';
+$string['testok'] = 'OK';
+$string['testprogress'] = '<strong>Test Progress:</strong>';
+$string['testscomplete'] = '<strong>Tests Complete!</strong>';
+$string['testskipped'] = '<font color=\'orange\'>Test \'{$a->name}\' has been skipped.</font>';
+$string['teststart'] = 'Test {$a->num} of {$a->total}: \'{$a->name}\' started.';
+$string['thorough'] = 'Run a thorough test (may be slow).';
+$string['totalfound'] = 'Search complete. Total unit test files found: {$a->count}';
+$string['version'] = 'Using <a href=\"http://sourceforge.net/projects/simpletest/\">SimpleTest</a> version {$a->version}.';
+
71 core/admin/tool/phpunittest/phpunit/testphpunit.php
View
@@ -0,0 +1,71 @@
+<?php
+
+/**
+ * Example test of PHPUnit
+ *
+ * Basic functionality tests.
+ *
+ * ELIS(TM): Enterprise Learning Intelligence Suite
+ * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @package tool
+ * @subpackage phpunitest
+ * @author Remote-Learner.net Inc
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL
+ * @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
+ */
+
+if (!defined('PHPUnit_MAIN_METHOD') && !defined('MOODLE_INTERNAL')) {
+ // Must be run via phpunit command-line or included from a Moodle page
+ die('Direct access to this script is forbidden.');
+}
+
+defined('PHPUNIT_SCRIPT') || define('PHPUNIT_SCRIPT', true);
+
+require_once(dirname(__FILE__) .'/../../../../config.php');
+
+if (! isset($CFG)) {
+ global $CFG; // Required when running test from Moodle admin reports.
+}
+
+/**
+ * PHPUnit Test Class
+ *
+ * Implement the basic functionality tests.
+ *
+ * @author Brent Boghosian <brent.boghosian@remote-learner.net>
+ */
+class PHPUnitTestExample extends PHPUnit_Framework_TestCase {
+ protected $backupGlobals = FALSE;
+
+ public function testSanity() {
+ $this->assertTrue(true);
+ }
+
+ public function testNotImplemented() {
+ $this->markTestIncomplete('Example Not Implemented Test');
+ }
+
+ public function testSkipped() {
+ $this->markTestSkipped('Example Skipped Test');
+ }
+
+ public function testError() {
+ //trigger_error('Example Test Error.', E_USER_WARNING);
+ print_header(); // intentionally cause error for test
+ print_header();
+ }
+}
4 core/admin/tool/phpunittest/settings.php
View
@@ -0,0 +1,4 @@
+<?php
+
+$ADMIN->add('reports', new admin_externalpage('tool_phpunittest', get_string('pluginname', 'tool_phpunittest'),
+ "$CFG->wwwroot/$CFG->admin/tool/phpunittest/index.php", 'tool/phpunittest:view'));
41 core/admin/tool/phpunittest/styles.css
View
@@ -0,0 +1,41 @@
+.phpunittest {
+ margin-top: 0px;
+ margin-bottom: 0px;
+ line-height: 1em;
+}
+
+.testsearch {
+ line-height: 1em;
+}
+
+.dirlevel0 {
+ list-style-type: disc;
+}
+
+.dirlevel1 {
+ list-style-type: circle;