From cf07718b4e44cb2711380a0ceb37de1031a5d4a8 Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 13 May 2009 11:24:40 +0000 Subject: Refs #1009: Changed the method tests are performed. git-svn-id: https://code.elgg.org/elgg/trunk@3285 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/testing.php | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'engine') diff --git a/engine/lib/testing.php b/engine/lib/testing.php index 5f24939e8..afa5dd2e2 100644 --- a/engine/lib/testing.php +++ b/engine/lib/testing.php @@ -66,13 +66,51 @@ static public function CreateFailResult($details, $debug = "") { return new ElggTestResult(false, $details, $debug); } } - function testing_execute_tests() + /** + * Execute an elgg test. + * + * @param string $function The test function + */ + function execute_elgg_test($function) { + if (is_callable($function)) + return $function(); + + return false; + } + + /** + * Execute all tests. + * + * @return array + */ + function execute_elgg_tests() + { + global $ELGG_TEST_REGISTRY; + $report = array(); // An array to be populated with ElggTestResult objects - $report = trigger_plugin_hook('test', 'test', null, $report); + foreach ($ELGG_TEST_REGISTRY as $func => $desc) + { + $report[] = execute_elgg_test($func); + } return $report; } + /** + * Register an Elgg unit test. + * + * @param string $description elgg_echo description of test. + * @param string $function Function to execute. This function should execute the test and return a ElggTestResult object. + */ + function register_elgg_test($description, $function) + { + global $ELGG_TEST_REGISTRY; + + if (!$ELGG_TEST_REGISTRY) $ELGG_TEST_REGISTRY = array(); + + $ELGG_TEST_REGISTRY[$function] = $description; + } + ?> \ No newline at end of file -- cgit v1.2.3