From 3d81c30a35b1b7d83f24adcfd27e390f98390096 Mon Sep 17 00:00:00 2001 From: alex <> Date: Sun, 13 Nov 2005 09:16:34 +0000 Subject: Finished tests cases for TPropertyValue. Some tests cases fail! --- tests/UnitTests/framework/common.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests/UnitTests/framework/common.php') diff --git a/tests/UnitTests/framework/common.php b/tests/UnitTests/framework/common.php index 71d6949e..bcff7a89 100644 --- a/tests/UnitTests/framework/common.php +++ b/tests/UnitTests/framework/common.php @@ -23,4 +23,40 @@ function __autoload($className) error_reporting(E_ALL); restore_error_handler(); + +/** + * PradoTestCase class. + * + * Extends the simpletest UnitTestCase class to provide some fairly generic extra functionality. + * + * @author Alex Flint + */ + +class PradoUnitTestCase extends UnitTestCase { + + /** + * Tests whether the given code results in an appropriate exception being raised. + * @param string the PHP code to execute. must end with a semi-colon. + * @param string the type of exception that should be raised. + * @return boolean true + */ + public function assertException(string $code, string $exception) { + $pass = false; + $code = " +try { + $code +} catch ($exception \$e) { + \$pass = true; +}"; + eval($code); + if ($pass) { + $this->pass(); + } else { + $this->fail("Code did not produce correct exception (wanted $exception, got something else"); + } + } +} + + + ?> \ No newline at end of file -- cgit v1.2.3