diff options
Diffstat (limited to 'mod/diagnostics')
| -rw-r--r-- | mod/diagnostics/index.php | 17 | ||||
| -rw-r--r-- | mod/diagnostics/languages/en.php | 31 | ||||
| -rw-r--r-- | mod/diagnostics/start.php | 27 | ||||
| -rw-r--r-- | mod/diagnostics/testreport.php | 43 | ||||
| -rw-r--r-- | mod/diagnostics/unittester.php | 41 | ||||
| -rw-r--r-- | mod/diagnostics/views/default/diagnostics/test.php | 27 | ||||
| -rw-r--r-- | mod/diagnostics/views/default/diagnostics/testresult.php | 40 | 
7 files changed, 29 insertions, 197 deletions
diff --git a/mod/diagnostics/index.php b/mod/diagnostics/index.php index 9a7b66191..0cae3743c 100644 --- a/mod/diagnostics/index.php +++ b/mod/diagnostics/index.php @@ -1,7 +1,7 @@  <?php  /**   * Elgg diagnostics - *  + *   * @package ElggDiagnostics   * @author Curverider Ltd   * @link http://elgg.com/ @@ -14,23 +14,28 @@ set_context('admin');  // system diagnostics  $body = elgg_view_title(elgg_echo('diagnostics')); -$body .= elgg_view('page_elements/contentwrapper', array('body' =>  +$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')); + +$test_body = '<p>' . elgg_echo('diagnostics:unittester:description') . '</p>'; +$test_body .= '<h3>' . elgg_echo('diagnostics:unittester:warning') . '</h3>'; +  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); +	$test_body .= elgg_view('input/button', $params);  } else {  	// no tests when not in debug mode -	$button = elgg_echo('diagnostics:unittester:debug'); +	$test_body .= elgg_echo('diagnostics:unittester:debug');  } -$body .= elgg_view('page_elements/contentwrapper', array('body' =>  -	elgg_echo('diagnostics:unittester:description') . "<br />$button") + +$body .= elgg_view('page_elements/contentwrapper', array( +	'body' => $test_body)  );  // create page diff --git a/mod/diagnostics/languages/en.php b/mod/diagnostics/languages/en.php index 2562c10b8..ae72564d7 100644 --- a/mod/diagnostics/languages/en.php +++ b/mod/diagnostics/languages/en.php @@ -1,44 +1,45 @@  <?php  	/**  	 * Elgg diagnostics language pack. -	 *  +	 *  	 * @package ElggDiagnostics  	 * @author Curverider Ltd  	 * @link http://elgg.com/  	 */  	$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:unittester:description' => 'Unit tests are useful to detect errors introduced by new plugins or modifications to Elgg.', + +			'diagnostics:unittester:description' => 'Unit tests check Elgg Core for broken or buggy APIs.',  			'diagnostics:unittester:debug' => 'The site must be in debug mode to run unit tests.', -	 +			'diagnostics:unittester:warning' => 'WARNING: These tests can leave behind debugging objects in your database.  DO NOT USE ON A PRODUCTION SITE!', +  			'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' => 'SUCCESS', -	 +  			'diagnostics:unittest:example' => 'Example unit test, only available in debug mode.', -	 +  			'diagnostics:unittester:report' => 'Test report for %s', -	 +  			'diagnostics:download' => 'Download .txt', -	 -	 + +  			'diagnostics:header' => '========================================================================  Elgg Diagnostic Report  Generated %s by %s  ======================================================================== -			 +  ',  			'diagnostics:report:basic' => '  Elgg Release %s, version %s @@ -63,8 +64,8 @@ Global variables:  %s  ------------------------------------------------------------------------', -	 +  	); -					 +  	add_translation("en",$english);  ?>
\ No newline at end of file diff --git a/mod/diagnostics/start.php b/mod/diagnostics/start.php index 76676c6a4..f4d1ab2af 100644 --- a/mod/diagnostics/start.php +++ b/mod/diagnostics/start.php @@ -43,31 +43,8 @@ function diagnostics_page_handler($page)  {  	global $CONFIG; -	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"); -	} +	// 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 deleted file mode 100644 index 2068ec280..000000000 --- a/mod/diagnostics/testreport.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php -	/** -	 * Elgg diagnostics - test report -	 *  -	 * @package ElggDiagnostics -	 * @author Curverider Ltd -	 * @link http://elgg.com/ -	 */ - -	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']); -		 -	// Which test are we executing? -	$test_func = get_input('test_func'); - -	$title_txt = sprintf(elgg_echo('diagnostics:unittester:report'), $test_func ? $testfunc : elgg_echo('diagnostics:test:executeall')); -		 -	$title = elgg_view_title(); -	 -	$result = null; -	if ($test_func) -		$result = array(execute_elgg_test($test_func)); -	else -		$result = execute_elgg_tests(); -		 -	if ($result) -	{ -		foreach ($result as $r) -			$body .= elgg_view('page_elements/contentwrapper', array('body' => -				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 deleted file mode 100644 index 8b1993041..000000000 --- a/mod/diagnostics/unittester.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -	/** -	 * Elgg diagnostics - unit tester -	 *  -	 * @package ElggDiagnostics -	 * @author Curverider Ltd -	 * @link http://elgg.com/ -	 */ - -	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']); - -	$title = elgg_view_title(elgg_echo('diagnostics:unittester')); -	 -	$tests = get_available_tests(); -	$test_body = ""; -	if ($tests) -	{ -		foreach ($tests as $func => $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/test.php b/mod/diagnostics/views/default/diagnostics/test.php deleted file mode 100644 index 7546e6024..000000000 --- a/mod/diagnostics/views/default/diagnostics/test.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php -	/** -	 * Elgg diagnostics -	 *  -	 * @package ElggDiagnostics -	 * @author Curverider Ltd -	 * @link http://elgg.com/ -	 */ - -	 -?> -<div class="test"> -	<div class="test_header"> -		<b><?php echo $vars['function']; ?></b> -	</div> -	<div class="test_description"> -		<?php echo $vars['description']; ?> -	</div> -	<div class="test_button"> -		<?php -		 -			$form_body = elgg_view('input/submit', array('internalname' => 'execute', 'value' => elgg_echo('diagnostics:test:executetest'))); -		 -			echo elgg_view('input/form', array('action' => $vars['url'] . "pg/diagnostics/tests/{$vars['function']}", 'body' => $form_body)); -		?> -	</div> -</div>
\ No newline at end of file diff --git a/mod/diagnostics/views/default/diagnostics/testresult.php b/mod/diagnostics/views/default/diagnostics/testresult.php deleted file mode 100644 index 8db769f1d..000000000 --- a/mod/diagnostics/views/default/diagnostics/testresult.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php -	/** -	 * Elgg diagnostics - test report -	 *  -	 * @package ElggDiagnostics -	 * @author Curverider Ltd -	 * @link http://elgg.com/ -	 */ - -	$result = $vars['result']; -	 -	$testresult_div = 'fail'; -	$successmessage = ""; -	 -	if (!($result instanceof ElggTestResult)) -	{ -		$successmessage = elgg_echo('diagnostics:unittester:testresult:nottestclass'); -		$result = ElggTestResult::CreateFailResult(elgg_echo('diagnostics:unittester:testresult:fail')); -	} -	else -	{ -		if ($result->isSuccess()) -			$successmessage = elgg_echo('diagnostics:unittester:testresult:success'); -		else -			$successmessage = elgg_echo('diagnostics:unittester:testresult:fail'); -	} -?> -<div class="testreport"> -	<div class="testreport_<?php echo $testresult_div; ?>"> -		<div class="testreport_header"> -			<p><b><?php echo $vars['function']; ?> : </b><?php echo $successmessage; ?></p> -		</div> -		<div class="testreport_details"> -			<?php echo $result->getDetails(); ?> -		</div> -		<div class="testreport_debug"> -			<?php echo $result->getDebug(); ?> -		</div> -	</div> -</div>
\ No newline at end of file  | 
