From 322bb9cd2be9e51422cb2b82684692e825c2bfb7 Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 2 Oct 2009 18:40:04 +0000 Subject: Added simpletest and start of unit tests. git-svn-id: http://code.elgg.org/elgg/trunk@3503 36083f99-b078-4883-b0ff-0f9b5a30f544 --- .../simpletest/extensions/phpunit_test_case.php | 96 ++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100755 vendors/simpletest/extensions/phpunit_test_case.php (limited to 'vendors/simpletest/extensions/phpunit_test_case.php') diff --git a/vendors/simpletest/extensions/phpunit_test_case.php b/vendors/simpletest/extensions/phpunit_test_case.php new file mode 100755 index 000000000..e038a4967 --- /dev/null +++ b/vendors/simpletest/extensions/phpunit_test_case.php @@ -0,0 +1,96 @@ +SimpleTestCase($label); + } + + /** + * Sends pass if the test condition resolves true, + * a fail otherwise. + * @param $condition Condition to test true. + * @param $message Message to display. + * @public + */ + function assert($condition, $message = false) { + parent::assert(new TrueExpectation(), $condition, $message); + } + + /** + * Will test straight equality if set to loose + * typing, or identity if not. + * @param $first First value. + * @param $second Comparison value. + * @param $message Message to display. + * @public + */ + function assertEquals($first, $second, $message = false) { + parent::assert(new EqualExpectation($first), $second, $message); + } + + /** + * Simple string equality. + * @param $first First value. + * @param $second Comparison value. + * @param $message Message to display. + * @public + */ + function assertEqualsMultilineStrings($first, $second, $message = false) { + parent::assert(new EqualExpectation($first), $second, $message); + } + + /** + * Tests a regex match. + * @param $pattern Regex to match. + * @param $subject String to search in. + * @param $message Message to display. + * @public + */ + function assertRegexp($pattern, $subject, $message = false) { + parent::assert(new PatternExpectation($pattern), $subject, $message); + } + + /** + * Sends an error which we interpret as a fail + * with a different message for compatibility. + * @param $message Message to display. + * @public + */ + function error($message) { + parent::fail("Error triggered [$message]"); + } + + /** + * Accessor for name. + * @public + */ + function name() { + return $this->getLabel(); + } + } +?> -- cgit v1.2.3