Removed 'base_path' from AkInstaller->setInstalledVersion because Ak:make_dir can...
[akelos.git] / vendor / simpletest / extensions / pear_test_case.php
blobaff14124a05061378669d485a4028e7ce62496ce
1 <?php
2 /**
3 * adapter for SimpleTest to use PEAR PHPUnit test cases
4 * @package SimpleTest
5 * @subpackage Extensions
6 * @version $Id: pear_test_case.php,v 1.8 2005/08/03 23:25:19 lastcraft Exp $
7 */
9 /**#@+
10 * include SimpleTest files
12 require_once(dirname(__FILE__) . '/../dumper.php');
13 require_once(dirname(__FILE__) . '/../compatibility.php');
14 require_once(dirname(__FILE__) . '/../test_case.php');
15 require_once(dirname(__FILE__) . '/../expectation.php');
16 /**#@-*/
18 /**
19 * Adapter for PEAR PHPUnit test case to allow
20 * legacy PEAR test cases to be used with SimpleTest.
21 * @package SimpleTest
22 * @subpackage Extensions
24 class PHPUnit_TestCase extends SimpleTestCase {
25 var $_loosely_typed;
27 /**
28 * Constructor. Sets the test name.
29 * @param $label Test name to display.
30 * @public
32 function PHPUnit_TestCase($label = false) {
33 $this->SimpleTestCase($label);
34 $this->_loosely_typed = false;
37 /**
38 * Will test straight equality if set to loose
39 * typing, or identity if not.
40 * @param $first First value.
41 * @param $second Comparison value.
42 * @param $message Message to display.
43 * @public
45 function assertEquals($first, $second, $message = "%s", $delta = 0) {
46 if ($this->_loosely_typed) {
47 $expectation = &new EqualExpectation($first);
48 } else {
49 $expectation = &new IdenticalExpectation($first);
51 $this->assert($expectation, $second, $message);
54 /**
55 * Passes if the value tested is not null.
56 * @param $value Value to test against.
57 * @param $message Message to display.
58 * @public
60 function assertNotNull($value, $message = "%s") {
61 parent::assertTrue(isset($value), $message);
64 /**
65 * Passes if the value tested is null.
66 * @param $value Value to test against.
67 * @param $message Message to display.
68 * @public
70 function assertNull($value, $message = "%s") {
71 parent::assertTrue(!isset($value), $message);
74 /**
75 * In PHP5 the identity test tests for the same
76 * object. This is a reference test in PHP4.
77 * @param $first First object handle.
78 * @param $second Hopefully the same handle.
79 * @param $message Message to display.
80 * @public
82 function assertSame(&$first, &$second, $message = "%s") {
83 $dumper = &new SimpleDumper();
84 $message = sprintf(
85 $message,
86 "[" . $dumper->describeValue($first) .
87 "] and [" . $dumper->describeValue($second) .
88 "] should reference the same object");
89 return $this->assertTrue(
90 SimpleTestCompatibility::isReference($first, $second),
91 $message);
94 /**
95 * In PHP5 the identity test tests for the same
96 * object. This is a reference test in PHP4.
97 * @param $first First object handle.
98 * @param $second Hopefully a different handle.
99 * @param $message Message to display.
100 * @public
102 function assertNotSame(&$first, &$second, $message = "%s") {
103 $dumper = &new SimpleDumper();
104 $message = sprintf(
105 $message,
106 "[" . $dumper->describeValue($first) .
107 "] and [" . $dumper->describeValue($second) .
108 "] should not be the same object");
109 return $this->assertFalse(
110 SimpleTestCompatibility::isReference($first, $second),
111 $message);
115 * Sends pass if the test condition resolves true,
116 * a fail otherwise.
117 * @param $condition Condition to test true.
118 * @param $message Message to display.
119 * @public
121 function assertTrue($condition, $message = "%s") {
122 parent::assertTrue($condition, $message);
126 * Sends pass if the test condition resolves false,
127 * a fail otherwise.
128 * @param $condition Condition to test false.
129 * @param $message Message to display.
130 * @public
132 function assertFalse($condition, $message = "%s") {
133 parent::assertTrue(!$condition, $message);
137 * Tests a regex match. Needs refactoring.
138 * @param $pattern Regex to match.
139 * @param $subject String to search in.
140 * @param $message Message to display.
141 * @public
143 function assertRegExp($pattern, $subject, $message = "%s") {
144 $this->assert(new PatternExpectation($pattern), $subject, $message);
148 * Tests the type of a value.
149 * @param $value Value to take type of.
150 * @param $type Hoped for type.
151 * @param $message Message to display.
152 * @public
154 function assertType($value, $type, $message = "%s") {
155 parent::assertTrue(gettype($value) == strtolower($type), $message);
159 * Sets equality operation to act as a simple equal
160 * comparison only, allowing a broader range of
161 * matches.
162 * @param $loosely_typed True for broader comparison.
163 * @public
165 function setLooselyTyped($loosely_typed) {
166 $this->_loosely_typed = $loosely_typed;
170 * For progress indication during
171 * a test amongst other things.
172 * @return Usually one.
173 * @public
175 function countTestCases() {
176 return $this->getSize();
180 * Accessor for name, normally just the class
181 * name.
182 * @public
184 function getName() {
185 return $this->getLabel();
189 * Does nothing. For compatibility only.
190 * @param $name Dummy
191 * @public
193 function setName($name) {