aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/testing.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/testing.php')
-rw-r--r--engine/lib/testing.php42
1 files changed, 40 insertions, 2 deletions
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