]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Adding unit testing to the GUI.
authornickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 22 Oct 2009 14:57:08 +0000 (14:57 +0000)
committernickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 22 Oct 2009 14:57:08 +0000 (14:57 +0000)
Unit tests can be run from the core Diagnostics mod.

git-svn-id: http://code.elgg.org/elgg/trunk@3570 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/diagnostics/index.php
mod/diagnostics/languages/en.php

index 11f489475e4f9c89a3f70878dfd815a26fe68352..e77d004a8ee0de1609aa8e35684907a182a926ea 100644 (file)
@@ -1,25 +1,40 @@
 <?php
-       /**
       * Elgg diagnostics
       
       * @package ElggDiagnostics
       * @author Curverider Ltd
       * @link http://elgg.com/
       */
+/**
+ * Elgg diagnostics
+ * 
+ * @package ElggDiagnostics
+ * @author Curverider Ltd
+ * @link http://elgg.com/
+ */
 
-       require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
 
-       admin_gatekeeper();
-       set_context('admin');
-       // Set admin user for user block
-               set_page_owner($_SESSION['guid']);
+admin_gatekeeper();
+set_context('admin');
 
-       $title = elgg_view_title(elgg_echo('diagnostics'));
-       
-       $body = elgg_view('page_elements/contentwrapper', array('body' => 
-               elgg_echo('diagnostics:description') . elgg_view('diagnostics/forms/download'))
-       );
-       
-       
-       page_draw(elgg_echo('diagnostics'),elgg_view_layout("two_column_left_sidebar", '', $title . $body));
-?>
\ No newline at end of file
+// Set admin user for user block
+set_page_owner($_SESSION['guid']);
+
+// system diagnostics
+$body = elgg_view_title(elgg_echo('diagnostics'));
+$body .= elgg_view('page_elements/contentwrapper', array('body' => 
+       elgg_echo('diagnostics:description') . elgg_view('diagnostics/forms/download'))
+);
+
+// unit tests
+$body .= elgg_view_title(elgg_echo('diagnostics:unittester'));
+if (isset($CONFIG->debug)) {
+       // create a button to run tests
+       $js = "onclick=\"window.location='{$CONFIG->wwwroot}engine/tests/suite.php'\"";
+       $params = array('type' => 'button', 'value' => elgg_echo('diagnostics:test:executeall'), 'js' => $js);
+       $button = elgg_view('input/button', $params);
+} else {
+       // no tests when not in debug mode
+       $button = elgg_echo('diagnostics:unittester:debug');
+}
+$body .= elgg_view('page_elements/contentwrapper', array('body' => 
+       elgg_echo('diagnostics:unittester:description') . "<br />$button")
+);
+
+// create page
+page_draw(elgg_echo('diagnostics'), elgg_view_layout("two_column_left_sidebar", '', $body));
index 94d3fb99580ea2cdc9826e16fa1dca50aacb57bf..2562c10b8fe08b33239e80c7f643bec9a6c78472 100644 (file)
        $english = array(
        
                        'diagnostics' => 'System diagnostics',
-                       'diagnostics:unittester' => 'Unit tests',
+                       'diagnostics:unittester' => 'Unit Tests',
        
                        'diagnostics:description' => 'The following diagnostic report is useful for diagnosing any problems with Elgg, and should be attached to any bug reports you file.',
                        'diagnostics:unittester:description' => 'The following are diagnostic tests which are registered by plugins and may be performed in order to debug parts of the Elgg framework.',
+                       
+                       'diagnostics:unittester:description' => 'Unit tests are useful to detect errors introduced by new plugins or modifications to Elgg.',
+                       'diagnostics:unittester:debug' => 'The site must be in debug mode to run unit tests.',
        
                        'diagnostics:test:executetest' => 'Execute test',
                        'diagnostics:test:executeall' => 'Execute All',