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 --- engine/lib/testing.php | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'engine') diff --git a/engine/lib/testing.php b/engine/lib/testing.php index afa5dd2e2..6af96d8cf 100644 --- a/engine/lib/testing.php +++ b/engine/lib/testing.php @@ -52,6 +52,27 @@ $this->details = $details; $this->debug = $debug; } + + /** + * Successful execution or not? + * + * @return bool + */ + public function isSuccess() { return $this->successful; } + + /** + * Retrieve details. + * + * @return string + */ + public function getDetails() { return $this->details; } + + /** + * Retrieve debug. + * + * @return string + */ + public function getDebug() { return $this->debug; } /** * Factory function to generate a successful result. @@ -73,10 +94,12 @@ */ function execute_elgg_test($function) { - if (is_callable($function)) - return $function(); + global $ELGG_TEST_REGISTRY; + + if ((is_callable($function)) && (isset($ELGG_TEST_REGISTRY[$function]))) // must be callable, and registered (for security) + return array('function' => $function, 'result' => $function()); - return false; + return array('function' => $function, 'result' => false); } /** @@ -113,4 +136,15 @@ $ELGG_TEST_REGISTRY[$function] = $description; } + /** + * Return a list of available tests. + * + * @return array + */ + function get_available_tests() + { + global $ELGG_TEST_REGISTRY; + + return $ELGG_TEST_REGISTRY; + } ?> \ No newline at end of file -- cgit v1.2.3