aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/testing.php
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-05-13 11:24:40 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-05-13 11:24:40 +0000
commitcf07718b4e44cb2711380a0ceb37de1031a5d4a8 (patch)
tree7d6223d261fd807cb887eab032aa783717081799 /engine/lib/testing.php
parent3f8b898702743f4b68b25907463fa788d3c8122f (diff)
downloadelgg-cf07718b4e44cb2711380a0ceb37de1031a5d4a8.tar.gz
elgg-cf07718b4e44cb2711380a0ceb37de1031a5d4a8.tar.bz2
Refs #1009: Changed the method tests are performed.
git-svn-id: https://code.elgg.org/elgg/trunk@3285 36083f99-b078-4883-b0ff-0f9b5a30f544
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