From 3773f8d81c53dd0508325d6380ee49569951a61f Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 13 May 2009 15:59:22 +0000 Subject: Refs #1009: Enhancements to diagnostics tool to use the test framework. git-svn-id: https://code.elgg.org/elgg/trunk@3286 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/diagnostics/index.php | 8 ++-- mod/diagnostics/languages/en.php | 13 +++++++ mod/diagnostics/start.php | 28 +++++++++++++- mod/diagnostics/testreport.php | 45 ++++++++++++++++++++++ mod/diagnostics/unittester.php | 43 +++++++++++++++++++++ .../views/default/diagnostics/runalltests.php | 15 ++++++++ mod/diagnostics/views/default/diagnostics/test.php | 29 ++++++++++++++ .../views/default/diagnostics/testresult.php | 42 ++++++++++++++++++++ 8 files changed, 216 insertions(+), 7 deletions(-) create mode 100644 mod/diagnostics/testreport.php create mode 100644 mod/diagnostics/unittester.php create mode 100644 mod/diagnostics/views/default/diagnostics/runalltests.php create mode 100644 mod/diagnostics/views/default/diagnostics/test.php create mode 100644 mod/diagnostics/views/default/diagnostics/testresult.php (limited to 'mod/diagnostics') diff --git a/mod/diagnostics/index.php b/mod/diagnostics/index.php index b9aa2e309..54c8e9c4f 100644 --- a/mod/diagnostics/index.php +++ b/mod/diagnostics/index.php @@ -18,11 +18,9 @@ $title = elgg_view_title(elgg_echo('diagnostics')); - $body .= "
"; - $body .= elgg_echo('diagnostics:description'); - - $body .= elgg_view('diagnostics/forms/download'); - $body .= "
"; + $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)); diff --git a/mod/diagnostics/languages/en.php b/mod/diagnostics/languages/en.php index 79d35e938..5d19824bd 100644 --- a/mod/diagnostics/languages/en.php +++ b/mod/diagnostics/languages/en.php @@ -12,8 +12,21 @@ $english = array( 'diagnostics' => 'System diagnostics', + '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:test:executetest' => 'Execute test', + 'diagnostics:test:executeall' => 'Execute All', + 'diagnostics:unittester:notests' => 'Sorry, there are no unit test modules currently installed.', + 'diagnostics:unittester:testnotfound' => 'Sorry, the report could not be generated because that test was not found', + + 'diagnostics:unittester:testresult:nottestclass' => 'FAIL - Result not a test class', + 'diagnostics:unittester:testresult:fail' => 'FAIL', + 'diagnostics:unittester:testresult:success' => 'FAIL', + + 'diagnostics:unittester:report' => 'Test report for %s', 'diagnostics:download' => 'Download .txt', diff --git a/mod/diagnostics/start.php b/mod/diagnostics/start.php index 5bf2dc468..a7afe346e 100644 --- a/mod/diagnostics/start.php +++ b/mod/diagnostics/start.php @@ -33,6 +33,7 @@ if (get_context() == 'admin' && isadminloggedin()) { global $CONFIG; add_submenu_item(elgg_echo('diagnostics'), $CONFIG->wwwroot . 'pg/diagnostics/'); + add_submenu_item(elgg_echo('diagnostics:unittester'), $CONFIG->wwwroot . 'pg/diagnostics/tests/'); } } @@ -45,8 +46,31 @@ { global $CONFIG; - // only interested in one page for now - include($CONFIG->pluginspath . "diagnostics/index.php"); + if (isset($page[0])) + { + switch ($page[0]) + { + case 'tests' : + if ((isset($page[1])) && ($page[1])) { + switch ($page[1]) + { + case 'all': break; + default: set_input('test_func', $page[1]); + } + + include($CONFIG->pluginspath . "diagnostics/testreport.php"); + } + else + include($CONFIG->pluginspath . "diagnostics/unittester.php"); + break; + default: include($CONFIG->pluginspath . "diagnostics/index.php"); + } + } + else + { + // only interested in one page for now + include($CONFIG->pluginspath . "diagnostics/index.php"); + } } /** diff --git a/mod/diagnostics/testreport.php b/mod/diagnostics/testreport.php new file mode 100644 index 000000000..979cca267 --- /dev/null +++ b/mod/diagnostics/testreport.php @@ -0,0 +1,45 @@ + + elgg_view('diagnostics/testresult', array('function' => $r['function'], 'result' => $r['result'])) + )); + } + else + $body = elgg_view('page_elements/contentwrapper', array('body' => + elgg_echo('diagnostics:unittester:testnotfound' ) + )); + + page_draw($title_txt, elgg_view_layout("two_column_left_sidebar", '', $title . $body)); +?> \ No newline at end of file diff --git a/mod/diagnostics/unittester.php b/mod/diagnostics/unittester.php new file mode 100644 index 000000000..d0aa0c8c4 --- /dev/null +++ b/mod/diagnostics/unittester.php @@ -0,0 +1,43 @@ + $desc) + $test_body .= elgg_view('diagnostics/test', array('function' => $func, 'description' => $desc)); + } + else + $test_body = elgg_echo('diagnostics:unittester:notests'); + + $body = elgg_view('page_elements/contentwrapper', array('body' => + elgg_echo('diagnostics:unittester:description') . + elgg_view('diagnostics/runalltests') + ) + ); + + $body .= elgg_view('page_elements/contentwrapper', array('body' => + $test_body ) + ); + + + page_draw(elgg_echo('diagnostics:unittester'),elgg_view_layout("two_column_left_sidebar", '', $title . $body)); +?> \ No newline at end of file diff --git a/mod/diagnostics/views/default/diagnostics/runalltests.php b/mod/diagnostics/views/default/diagnostics/runalltests.php new file mode 100644 index 000000000..12bbf2a4a --- /dev/null +++ b/mod/diagnostics/views/default/diagnostics/runalltests.php @@ -0,0 +1,15 @@ + 'execute', 'value' => elgg_echo('diagnostics:test:executeall'))); + + echo elgg_view('input/form', array('action' => $vars['url'] . "pg/diagnostics/tests/all", 'body' => $form_body)); +?> \ No newline at end of file diff --git a/mod/diagnostics/views/default/diagnostics/test.php b/mod/diagnostics/views/default/diagnostics/test.php new file mode 100644 index 000000000..5010eb903 --- /dev/null +++ b/mod/diagnostics/views/default/diagnostics/test.php @@ -0,0 +1,29 @@ + +
+
+ +
+
+ +
+
+ 'execute', 'value' => elgg_echo('diagnostics:test:executetest'))); + + echo elgg_view('input/form', array('action' => $vars['url'] . "pg/diagnostics/tests/{$vars['function']}", 'body' => $form_body)); + ?> +
+
\ No newline at end of file diff --git a/mod/diagnostics/views/default/diagnostics/testresult.php b/mod/diagnostics/views/default/diagnostics/testresult.php new file mode 100644 index 000000000..ddd688e93 --- /dev/null +++ b/mod/diagnostics/views/default/diagnostics/testresult.php @@ -0,0 +1,42 @@ +isSuccess()) + $successmessage = elgg_echo('diagnostics:unittester:testresult:success'); + else + $successmessage = elgg_echo('diagnostics:unittester:testresult:fail'); + } +?> +
+
+
+

:

+
+
+ getDetails(); ?> +
+
+ getDebug(); ?> +
+
+
\ No newline at end of file -- cgit v1.2.3