diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-05-13 09:51:07 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-05-13 09:51:07 +0000 |
commit | 3f8b898702743f4b68b25907463fa788d3c8122f (patch) | |
tree | d8fece96a01a5c96d1b5366b899cb6be629bb447 /engine/lib | |
parent | 4793c2e10ef0f45fe556d248b8d96aaa844dc6ef (diff) | |
download | elgg-3f8b898702743f4b68b25907463fa788d3c8122f.tar.gz elgg-3f8b898702743f4b68b25907463fa788d3c8122f.tar.bz2 |
Refs #1009: Simple test framework outline added.
git-svn-id: https://code.elgg.org/elgg/trunk@3284 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/testing.php | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/engine/lib/testing.php b/engine/lib/testing.php new file mode 100644 index 000000000..5f24939e8 --- /dev/null +++ b/engine/lib/testing.php @@ -0,0 +1,78 @@ +<?php + /** + * Elgg testing framework. + * + * This library contains an Elgg unit test framework which can be used and extended by plugins to provide + * functional unit tests to aid diagnostics of problems. + * + * @package Elgg + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd <info@elgg.com> + * @copyright Curverider Ltd 2008-2009 + * @link http://elgg.org/ + */ + + /** + * Elgg test result object. + * This class is used to return the values of the test in order to generate a report. + */ + class ElggTestResult { + + /** + * Textual description of the test being performed (used for reporting). + * + * @var string + */ + private $details; + + /** + * Boolean, true if the test was executed successfully - false if not. + * + * @var bool + */ + private $successful; + + /** + * Any debug information for the report. + * + * @var string + */ + private $debug; + + /** + * Create a test result object. + * + */ + function __construct($success, $details = "", $debug = "") + { + $success = (bool)$success; + + $this->successful = $success; + $this->details = $details; + $this->debug = $debug; + } + + /** + * Factory function to generate a successful result. + * + */ + static public function CreateSuccessResult($details) { return new ElggTestResult(true, $details); } + + /** + * Factory function to generate a successful result. + * + */ + static public function CreateFailResult($details, $debug = "") { return new ElggTestResult(false, $details, $debug); } + } + + function testing_execute_tests() + { + $report = array(); // An array to be populated with ElggTestResult objects + + $report = trigger_plugin_hook('test', 'test', null, $report); + + return $report; + } + +?>
\ No newline at end of file |