3 * adapter for SimpleTest to use PHPUnit test cases
5 * @subpackage Extensions
6 * @version $Id: phpunit_test_case.php,v 1.6 2006/01/03 01:17:08 lastcraft Exp $
10 * include SimpleTest files
12 require_once(dirname(__FILE__
) . '/../unit_tester.php');
13 require_once(dirname(__FILE__
) . '/../expectation.php');
17 * Adapter for sourceforge PHPUnit test case to allow
18 * legacy test cases to be used with SimpleTest.
20 * @subpackage Extensions
22 class TestCase
extends SimpleTestCase
{
25 * Constructor. Sets the test name.
26 * @param $label Test name to display.
29 function TestCase($label) {
30 $this->SimpleTestCase($label);
34 * Sends pass if the test condition resolves true,
36 * @param $condition Condition to test true.
37 * @param $message Message to display.
40 function assert($condition, $message = false) {
41 parent
::assertTrue($condition, $message);
45 * Will test straight equality if set to loose
46 * typing, or identity if not.
47 * @param $first First value.
48 * @param $second Comparison value.
49 * @param $message Message to display.
52 function assertEquals($first, $second, $message = false) {
53 parent
::assert(new EqualExpectation($first), $second, $message);
57 * Simple string equality.
58 * @param $first First value.
59 * @param $second Comparison value.
60 * @param $message Message to display.
63 function assertEqualsMultilineStrings($first, $second, $message = false) {
64 parent
::assert(new EqualExpectation($first), $second, $message);
68 * Tests a regex match.
69 * @param $pattern Regex to match.
70 * @param $subject String to search in.
71 * @param $message Message to display.
74 function assertRegexp($pattern, $subject, $message = false) {
75 parent
::assert(new PatternExpectation($pattern), $subject, $message);
79 * Sends an error which we interpret as a fail
80 * with a different message for compatibility.
81 * @param $message Message to display.
84 function error($message) {
85 parent
::fail("Error triggered [$message]");
93 return $this->getLabel();