3 * adapter for SimpleTest to use PHPUnit test cases
5 * @subpackage Extensions
6 * @version $Id: phpunit_test_case.php,v 1.3 2004/04/23 03:11:56 jsweat Exp $
10 * include SimpleTest files
12 require_once dirname(__FILE__
).DIRECTORY_SEPARATOR
13 .'..'.DIRECTORY_SEPARATOR
. 'unit_tester.php';
14 require_once dirname(__FILE__
).DIRECTORY_SEPARATOR
15 .'..'.DIRECTORY_SEPARATOR
. 'expectation.php';
19 * Adapter for sourceforge PHPUnit test case to allow
20 * legacy test cases to be used with SimpleTest.
22 * @subpackage Extensions
24 class TestCase
extends SimpleTestCase
{
27 * Constructor. Sets the test name.
28 * @param $label Test name to display.
31 function TestCase($label) {
32 $this->SimpleTestCase($label);
36 * Sends pass if the test condition resolves true,
38 * @param $condition Condition to test true.
39 * @param $message Message to display.
42 function assert($condition, $message = false
) {
43 parent
::assertTrue($condition, $message);
47 * Will test straight equality if set to loose
48 * typing, or identity if not.
49 * @param $first First value.
50 * @param $second Comparison value.
51 * @param $message Message to display.
54 function assertEquals($first, $second, $message = false
) {
55 $this->assertExpectation(
56 new EqualExpectation($first),
62 * Will test straight equality if set to loose
63 * typing, or identity if not.
64 * @param $first First value.
65 * @param $second Comparison value.
66 * @param $message Message to display.
69 function assertEqualsMultilineStrings($first, $second, $message = false
) {
70 $this->assertExpectation(
71 new EqualExpectation($first),
77 * Tests a regex match.
78 * @param $pattern Regex to match.
79 * @param $subject String to search in.
80 * @param $message Message to display.
83 function assertRegexp($pattern, $subject, $message = false
) {
84 $this->assertExpectation(
85 new WantedPatternExpectation($pattern),
91 * Sends an error which we interpret as a fail
92 * with a different message for compatibility.
93 * @param $message Message to display.
96 function error($message) {
97 parent
::assertTrue(false
, "Error triggered [$message]");
105 return $this->getLabel();