Commit 3cafce2e322c2bbd1eb76cf96742cc4a7c694086

Authored by Conrad Vermeulen
1 parent 71356ca5

"KTS-2117"

"upgrade simpletest"
Upgraded.

Reviewed By: Kevin Fourie


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@6800 c91229c3-7414-0410-bfa2-8a42b809f60b
thirdparty/simpletest/simpletest/HELP_MY_TESTS_DONT_WORK_ANYMORE
@@ -5,6 +5,28 @@ written with earlier versions will fail with the newest ones. The most @@ -5,6 +5,28 @@ written with earlier versions will fail with the newest ones. The most
5 dramatic changes are in the alpha releases. Here is a list of possible 5 dramatic changes are in the alpha releases. Here is a list of possible
6 problems and their fixes... 6 problems and their fixes...
7 7
  8 +No method _getTest() on mocks
  9 +-----------------------------
  10 +This has finally been removed. It was a pretty esoteric
  11 +flex point anyway. It was there to allow the mocks to
  12 +work with other test tools, but no one does this anyway.
  13 +
  14 +No method assertError(), assertNoErrors(), swallowErrors()
  15 +----------------------------------------------------------
  16 +These have been deprecated in 1.0.1beta in favour of
  17 +expectError() and expectException(). assertNoErrors() is
  18 +redundant if you use expectError() as failures are now reporterted
  19 +immediately.
  20 +
  21 +No method TestCase::signal()
  22 +----------------------------
  23 +This has been deprecated in favour of triggering an error or
  24 +throwing an exception. Deprecated as of 1.0.1beta.
  25 +
  26 +No method TestCase::sendMessage()
  27 +---------------------------------
  28 +This has been deprecated as of 1.0.1beta.
  29 +
8 Failure to connect now emits failures 30 Failure to connect now emits failures
9 ------------------------------------- 31 -------------------------------------
10 It used to be that you would have to use the 32 It used to be that you would have to use the
@@ -46,7 +68,7 @@ No method addPartialMockCode() @@ -46,7 +68,7 @@ No method addPartialMockCode()
46 ------------------------------ 68 ------------------------------
47 The ability to insert arbitrary partial mock code 69 The ability to insert arbitrary partial mock code
48 has been removed. This was a low value feature 70 has been removed. This was a low value feature
49 -causing needless complications.It was removed 71 +causing needless complications. It was removed
50 in the 1.0.1beta release. 72 in the 1.0.1beta release.
51 73
52 No method setMockBaseClass() 74 No method setMockBaseClass()
@@ -139,7 +161,7 @@ My custom test case ignored by tally() @@ -139,7 +161,7 @@ My custom test case ignored by tally()
139 The _assertTrue method has had it's signature changed due to a bug 161 The _assertTrue method has had it's signature changed due to a bug
140 in the PHP 5.0.1 release. You must now use getTest() from within 162 in the PHP 5.0.1 release. You must now use getTest() from within
141 that method to get the test case. Mock compatibility with other 163 that method to get the test case. Mock compatibility with other
142 -unit testers is now deprecated as of 1.0.1alpha as PEAR::PHUnit2 164 +unit testers is now deprecated as of 1.0.1alpha as PEAR::PHPUnit2
143 should soon have mock support of it's own. 165 should soon have mock support of it's own.
144 166
145 Broken code extending SimpleRunner 167 Broken code extending SimpleRunner
thirdparty/simpletest/simpletest/LICENSE
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 Version 2.1, February 1999 2 Version 2.1, February 1999
3 3
4 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 4 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5 - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 5 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 Everyone is permitted to copy and distribute verbatim copies 6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed. 7 of this license document, but changing it is not allowed.
8 8
@@ -485,7 +485,7 @@ convey the exclusion of warranty; and each file should have at least the @@ -485,7 +485,7 @@ convey the exclusion of warranty; and each file should have at least the
485 485
486 You should have received a copy of the GNU Lesser General Public 486 You should have received a copy of the GNU Lesser General Public
487 License along with this library; if not, write to the Free Software 487 License along with this library; if not, write to the Free Software
488 - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 488 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
489 489
490 Also add information on how to contact you by electronic and paper mail. 490 Also add information on how to contact you by electronic and paper mail.
491 491
thirdparty/simpletest/simpletest/README
1 SimpleTest 1 SimpleTest
2 ========== 2 ==========
3 You probably got this package from... 3 You probably got this package from...
4 -http://sourceforge.net/projects/simpletest/ 4 +http://simpletest.sourceforge.net/projects/simpletest/
5 5
6 If there is no licence agreement with this package please download 6 If there is no licence agreement with this package please download
7 a version from the location above. You must read and accept that 7 a version from the location above. You must read and accept that
thirdparty/simpletest/simpletest/VERSION
1 -1.0.1alpha3  
2 \ No newline at end of file 1 \ No newline at end of file
  2 +1.0.1beta
3 \ No newline at end of file 3 \ No newline at end of file
thirdparty/simpletest/simpletest/browser.php
@@ -894,6 +894,17 @@ @@ -894,6 +894,17 @@
894 $form->submitButton(new SimpleById($id), $additional)); 894 $form->submitButton(new SimpleById($id), $additional));
895 return ($success ? $this->getContent() : $success); 895 return ($success ? $this->getContent() : $success);
896 } 896 }
  897 +
  898 + /**
  899 + * Tests to see if a submit button exists with this
  900 + * label.
  901 + * @param string $label Button label.
  902 + * @return boolean True if present.
  903 + * @access public
  904 + */
  905 + function isSubmit($label) {
  906 + return (boolean)$this->_page->getFormBySubmit(new SimpleByLabel($label));
  907 + }
897 908
898 /** 909 /**
899 * Clicks the submit image by some kind of label. Usually 910 * Clicks the submit image by some kind of label. Usually
@@ -962,6 +973,17 @@ @@ -962,6 +973,17 @@
962 $form->submitImage(new SimpleById($id), $x, $y, $additional)); 973 $form->submitImage(new SimpleById($id), $x, $y, $additional));
963 return ($success ? $this->getContent() : $success); 974 return ($success ? $this->getContent() : $success);
964 } 975 }
  976 +
  977 + /**
  978 + * Tests to see if an image exists with this
  979 + * title or alt text.
  980 + * @param string $label Image text.
  981 + * @return boolean True if present.
  982 + * @access public
  983 + */
  984 + function isImage($label) {
  985 + return (boolean)$this->_page->getFormByImage(new SimpleByLabel($label));
  986 + }
965 987
966 /** 988 /**
967 * Submits a form by the ID. 989 * Submits a form by the ID.
@@ -981,16 +1003,16 @@ @@ -981,16 +1003,16 @@
981 } 1003 }
982 1004
983 /** 1005 /**
984 - * Follows a link by label. Will click the first link 1006 + * Finds a URL by label. Will find the first link
985 * found with this link text by default, or a later 1007 * found with this link text by default, or a later
986 * one if an index is given. The match ignores case and 1008 * one if an index is given. The match ignores case and
987 * white space issues. 1009 * white space issues.
988 * @param string $label Text between the anchor tags. 1010 * @param string $label Text between the anchor tags.
989 * @param integer $index Link position counting from zero. 1011 * @param integer $index Link position counting from zero.
990 - * @return string/boolean Page on success. 1012 + * @return string/boolean URL on success.
991 * @access public 1013 * @access public
992 */ 1014 */
993 - function clickLink($label, $index = 0) { 1015 + function getLink($label, $index = 0) {
994 $urls = $this->_page->getUrlsByLabel($label); 1016 $urls = $this->_page->getUrlsByLabel($label);
995 if (count($urls) == 0) { 1017 if (count($urls) == 0) {
996 return false; 1018 return false;
@@ -998,18 +1020,36 @@ @@ -998,18 +1020,36 @@
998 if (count($urls) < $index + 1) { 1020 if (count($urls) < $index + 1) {
999 return false; 1021 return false;
1000 } 1022 }
1001 - $this->_load($urls[$index], new SimpleGetEncoding());  
1002 - return $this->getContent(); 1023 + return $urls[$index];
1003 } 1024 }
1004 1025
1005 /** 1026 /**
1006 - * Tests to see if a link is present by label.  
1007 - * @param string $label Text of value attribute.  
1008 - * @return boolean True if link present. 1027 + * Follows a link by label. Will click the first link
  1028 + * found with this link text by default, or a later
  1029 + * one if an index is given. The match ignores case and
  1030 + * white space issues.
  1031 + * @param string $label Text between the anchor tags.
  1032 + * @param integer $index Link position counting from zero.
  1033 + * @return string/boolean Page on success.
  1034 + * @access public
  1035 + */
  1036 + function clickLink($label, $index = 0) {
  1037 + $url = $this->getLink($label, $index);
  1038 + if ($url === false) {
  1039 + return false;
  1040 + }
  1041 + $this->_load($url, new SimpleGetEncoding());
  1042 + return $this->getContent();
  1043 + }
  1044 +
  1045 + /**
  1046 + * Finds a link by id attribute.
  1047 + * @param string $id ID attribute value.
  1048 + * @return string/boolean URL on success.
1009 * @access public 1049 * @access public
1010 */ 1050 */
1011 - function isLink($label) {  
1012 - return (count($this->_page->getUrlsByLabel($label)) > 0); 1051 + function getLinkById($id) {
  1052 + return $this->_page->getUrlById($id);
1013 } 1053 }
1014 1054
1015 /** 1055 /**
@@ -1019,7 +1059,7 @@ @@ -1019,7 +1059,7 @@
1019 * @access public 1059 * @access public
1020 */ 1060 */
1021 function clickLinkById($id) { 1061 function clickLinkById($id) {
1022 - if (! ($url = $this->_page->getUrlById($id))) { 1062 + if (! ($url = $this->getLinkById($id))) {
1023 return false; 1063 return false;
1024 } 1064 }
1025 $this->_load($url, new SimpleGetEncoding()); 1065 $this->_load($url, new SimpleGetEncoding());
@@ -1027,16 +1067,6 @@ @@ -1027,16 +1067,6 @@
1027 } 1067 }
1028 1068
1029 /** 1069 /**
1030 - * Tests to see if a link is present by ID attribute.  
1031 - * @param string $id Text of id attribute.  
1032 - * @return boolean True if link present.  
1033 - * @access public  
1034 - */  
1035 - function isLinkById($id) {  
1036 - return (boolean)$this->_page->getUrlById($id);  
1037 - }  
1038 -  
1039 - /**  
1040 * Clicks a visible text item. Will first try buttons, 1070 * Clicks a visible text item. Will first try buttons,
1041 * then links and then images. 1071 * then links and then images.
1042 * @param string $label Visible text or alt text. 1072 * @param string $label Visible text or alt text.
@@ -1053,5 +1083,15 @@ @@ -1053,5 +1083,15 @@
1053 } 1083 }
1054 return $raw; 1084 return $raw;
1055 } 1085 }
  1086 +
  1087 + /**
  1088 + * Tests to see if a click target exists.
  1089 + * @param string $label Visible text or alt text.
  1090 + * @return boolean True if target present.
  1091 + * @access public
  1092 + */
  1093 + function isClickable($label) {
  1094 + return $this->isSubmit($label) || ($this->getLink($label) !== false) || $this->isImage($label);
  1095 + }
1056 } 1096 }
1057 ?> 1097 ?>
1058 \ No newline at end of file 1098 \ No newline at end of file
thirdparty/simpletest/simpletest/collector.php
1 <?php 1 <?php
2 -/**  
3 - * This file contains the following classes: {@link SimpleCollector},  
4 - * {@link SimplePatternCollector}.  
5 - *  
6 - * @author Travis Swicegood <development@domain51.com>  
7 - * @package SimpleTest  
8 - * @subpackage UnitTester  
9 - * @version $Id$  
10 - */  
11 -  
12 -/**  
13 - * The basic collector for {@link GroupTest}  
14 - *  
15 - * @see collect(), GroupTest::collect()  
16 - * @package SimpleTest  
17 - * @subpackage UnitTester  
18 - */  
19 -class SimpleCollector {  
20 -  
21 /** 2 /**
22 - * Strips off any kind of slash at the end so as to normalise the path 3 + * This file contains the following classes: {@link SimpleCollector},
  4 + * {@link SimplePatternCollector}.
23 * 5 *
24 - * @param string $path Path to normalise. 6 + * @author Travis Swicegood <development@domain51.com>
  7 + * @package SimpleTest
  8 + * @subpackage UnitTester
  9 + * @version $Id$
25 */ 10 */
26 - function _removeTrailingSlash($path) {  
27 - return preg_replace('|[\\/]$|', '', $path);  
28 -  
29 - /**  
30 - * @internal  
31 - * Try benchmarking the following. It's more code, but by not using the  
32 - * regex, it may be faster? Also, shouldn't be looking for  
33 - * DIRECTORY_SEPERATOR instead of a manual "/"?  
34 - */  
35 - if (substr($path, -1) == DIRECTORY_SEPERATOR) {  
36 - return substr($path, 0, -1);  
37 - } else {  
38 - return $path;  
39 - }  
40 - }  
41 - 11 +
42 /** 12 /**
43 - * Scans the directory and adds what it can.  
44 - * @param object $test Group test with {@link GroupTest::addTestFile()} method.  
45 - * @param string $path Directory to scan.  
46 - * @see _attemptToAdd() 13 + * The basic collector for {@link GroupTest}
  14 + *
  15 + * @see collect(), GroupTest::collect()
  16 + * @package SimpleTest
  17 + * @subpackage UnitTester
47 */ 18 */
48 - function collect(&$test, $path) {  
49 - $path = $this->_removeTrailingSlash($path);  
50 - if ($handle = opendir($path)) {  
51 - while (($entry = readdir($handle)) !== false) {  
52 - $this->_handle($test, $path . DIRECTORY_SEPARATOR . $entry); 19 + class SimpleCollector {
  20 +
  21 + /**
  22 + * Strips off any kind of slash at the end so as to normalise the path.
  23 + * @param string $path Path to normalise.
  24 + * @return string Path without trailing slash.
  25 + */
  26 + function _removeTrailingSlash($path) {
  27 + if (substr($path, -1) == DIRECTORY_SEPARATOR) {
  28 + return substr($path, 0, -1);
  29 + } elseif (substr($path, -1) == '/') {
  30 + return substr($path, 0, -1);
  31 + } else {
  32 + return $path;
53 } 33 }
54 - closedir($handle);  
55 } 34 }
56 - }  
57 35
58 - /**  
59 - * This method determines what should be done with a given file and adds  
60 - * it via {@link GroupTest::addTestFile()} if necessary.  
61 - *  
62 - * This method should be overriden to provide custom matching criteria,  
63 - * such as pattern matching, recursive matching, etc. For an example, see  
64 - * {@link SimplePatternCollector::_handle()}.  
65 - *  
66 - * @param object $test Group test with {@link GroupTest::addTestFile()} method.  
67 - * @param string $filename A filename as generated by {@link collect()}  
68 - * @see collect()  
69 - * @access protected  
70 - */  
71 - function _handle(&$test, $file) {  
72 - if (!is_dir($file)) {  
73 - $test->addTestFile($file); 36 + /**
  37 + * Scans the directory and adds what it can.
  38 + * @param object $test Group test with {@link GroupTest::addTestFile()} method.
  39 + * @param string $path Directory to scan.
  40 + * @see _attemptToAdd()
  41 + */
  42 + function collect(&$test, $path) {
  43 + $path = $this->_removeTrailingSlash($path);
  44 + if ($handle = opendir($path)) {
  45 + while (($entry = readdir($handle)) !== false) {
  46 + $this->_handle($test, $path . DIRECTORY_SEPARATOR . $entry);
  47 + }
  48 + closedir($handle);
  49 + }
74 } 50 }
75 - }  
76 -}  
77 -  
78 -/**  
79 - * An extension to {@link SimpleCollector} that only adds files matching a  
80 - * given pattern.  
81 - *  
82 - * @package SimpleTest  
83 - * @subpackage UnitTester  
84 - * @see SimpleCollector  
85 - */  
86 -class SimplePatternCollector extends SimpleCollector {  
87 - var $_pattern;  
88 51
  52 + /**
  53 + * This method determines what should be done with a given file and adds
  54 + * it via {@link GroupTest::addTestFile()} if necessary.
  55 + *
  56 + * This method should be overriden to provide custom matching criteria,
  57 + * such as pattern matching, recursive matching, etc. For an example, see
  58 + * {@link SimplePatternCollector::_handle()}.
  59 + *
  60 + * @param object $test Group test with {@link GroupTest::addTestFile()} method.
  61 + * @param string $filename A filename as generated by {@link collect()}
  62 + * @see collect()
  63 + * @access protected
  64 + */
  65 + function _handle(&$test, $file) {
  66 + if (! is_dir($file)) {
  67 + $test->addTestFile($file);
  68 + }
  69 + }
  70 + }
89 71
90 /** 72 /**
  73 + * An extension to {@link SimpleCollector} that only adds files matching a
  74 + * given pattern.
91 * 75 *
92 - * @param string $pattern Perl compatible regex to test name against  
93 - * See {@link http://us4.php.net/manual/en/reference.pcre.pattern.syntax.php PHP's PCRE}  
94 - * for full documentation of valid pattern.s 76 + * @package SimpleTest
  77 + * @subpackage UnitTester
  78 + * @see SimpleCollector
95 */ 79 */
96 - function SimplePatternCollector($pattern = '/php$/i') {  
97 - $this->_pattern = $pattern;  
98 - } 80 + class SimplePatternCollector extends SimpleCollector {
  81 + var $_pattern;
99 82
  83 + /**
  84 + *
  85 + * @param string $pattern Perl compatible regex to test name against
  86 + * See {@link http://us4.php.net/manual/en/reference.pcre.pattern.syntax.php PHP's PCRE}
  87 + * for full documentation of valid pattern.s
  88 + */
  89 + function SimplePatternCollector($pattern = '/php$/i') {
  90 + $this->_pattern = $pattern;
  91 + }
100 92
101 - /**  
102 - * Attempts to add files that match a given pattern.  
103 - *  
104 - * @see SimpleCollector::_handle()  
105 - * @param object $test Group test with {@link GroupTest::addTestFile()} method.  
106 - * @param string $path Directory to scan.  
107 - * @access protected  
108 - */  
109 - function _handle(&$test, $filename) {  
110 - if (preg_match($this->_pattern, $filename)) {  
111 - parent::_handle($test, $filename); 93 + /**
  94 + * Attempts to add files that match a given pattern.
  95 + *
  96 + * @see SimpleCollector::_handle()
  97 + * @param object $test Group test with {@link GroupTest::addTestFile()} method.
  98 + * @param string $path Directory to scan.
  99 + * @access protected
  100 + */
  101 + function _handle(&$test, $filename) {
  102 + if (preg_match($this->_pattern, $filename)) {
  103 + parent::_handle($test, $filename);
  104 + }
112 } 105 }
113 } 106 }
114 -}  
115 ?> 107 ?>
116 \ No newline at end of file 108 \ No newline at end of file
thirdparty/simpletest/simpletest/compatibility.php
@@ -70,6 +70,9 @@ @@ -70,6 +70,9 @@
70 if (is_array($first) && is_array($second)) { 70 if (is_array($first) && is_array($second)) {
71 return SimpleTestCompatibility::_isArrayOfIdenticalTypes($first, $second); 71 return SimpleTestCompatibility::_isArrayOfIdenticalTypes($first, $second);
72 } 72 }
  73 + if ($first !== $second) {
  74 + return false;
  75 + }
73 return true; 76 return true;
74 } 77 }
75 78
@@ -105,8 +108,7 @@ @@ -105,8 +108,7 @@
105 * @static 108 * @static
106 */ 109 */
107 function isReference(&$first, &$second) { 110 function isReference(&$first, &$second) {
108 - if (version_compare(phpversion(), '5', '>=')  
109 - && is_object($first)) { 111 + if (version_compare(phpversion(), '5', '>=') && is_object($first)) {
110 return ($first === $second); 112 return ($first === $second);
111 } 113 }
112 if (is_object($first) && is_object($second)) { 114 if (is_object($first) && is_object($second)) {
@@ -133,9 +135,6 @@ @@ -133,9 +135,6 @@
133 * @static 135 * @static
134 */ 136 */
135 function isA($object, $class) { 137 function isA($object, $class) {
136 - if (function_exists('is_a')) {  
137 - return is_a($object, $class);  
138 - }  
139 if (version_compare(phpversion(), '5') >= 0) { 138 if (version_compare(phpversion(), '5') >= 0) {
140 if (! class_exists($class, false)) { 139 if (! class_exists($class, false)) {
141 if (function_exists('interface_exists')) { 140 if (function_exists('interface_exists')) {
@@ -147,6 +146,9 @@ @@ -147,6 +146,9 @@
147 eval("\$is_a = \$object instanceof $class;"); 146 eval("\$is_a = \$object instanceof $class;");
148 return $is_a; 147 return $is_a;
149 } 148 }
  149 + if (function_exists('is_a')) {
  150 + return is_a($object, $class);
  151 + }
150 return ((strtolower($class) == get_class($object)) 152 return ((strtolower($class) == get_class($object))
151 or (is_subclass_of($object, $class))); 153 or (is_subclass_of($object, $class)));
152 } 154 }
@@ -167,18 +169,5 @@ @@ -167,18 +169,5 @@
167 set_socket_timeout($handle, $timeout, 0); 169 set_socket_timeout($handle, $timeout, 0);
168 } 170 }
169 } 171 }
170 -  
171 - /**  
172 - * Gets the current stack trace topmost first.  
173 - * @return array List of stack frames.  
174 - * @access public  
175 - * @static  
176 - */  
177 - function getStackTrace() {  
178 - if (function_exists('debug_backtrace')) {  
179 - return array_reverse(debug_backtrace());  
180 - }  
181 - return array();  
182 - }  
183 } 172 }
184 -?> 173 -?>
  174 +?>
185 \ No newline at end of file 175 \ No newline at end of file
thirdparty/simpletest/simpletest/dumper.php
@@ -356,47 +356,5 @@ @@ -356,47 +356,5 @@
356 ob_end_clean(); 356 ob_end_clean();
357 return $formatted; 357 return $formatted;
358 } 358 }
359 -  
360 - /**  
361 - * Extracts the last assertion that was not within  
362 - * Simpletest itself. The name must start with "assert".  
363 - * @param array $stack List of stack frames.  
364 - * @access public  
365 - * @static  
366 - */  
367 - function getFormattedAssertionLine($stack) {  
368 - foreach ($stack as $frame) {  
369 - if (isset($frame['file'])) {  
370 - if (strpos($frame['file'], SIMPLE_TEST) !== false) {  
371 - if (dirname($frame['file']) . '/' == SIMPLE_TEST) {  
372 - continue;  
373 - }  
374 - }  
375 - }  
376 - if (SimpleDumper::_stackFrameIsAnAssertion($frame)) {  
377 - return ' at [' . $frame['file'] . ' line ' . $frame['line'] . ']';  
378 - }  
379 - }  
380 - return '';  
381 - }  
382 -  
383 - /**  
384 - * Tries to determine if the method call is an assertion.  
385 - * @param array $frame PHP stack frame.  
386 - * @access private  
387 - * @static  
388 - */  
389 - function _stackFrameIsAnAssertion($frame) {  
390 - if (($frame['function'] == 'fail') || ($frame['function'] == 'pass')) {  
391 - return true;  
392 - }  
393 - if (strncmp($frame['function'], 'assert', 6) == 0) {  
394 - return true;  
395 - }  
396 - if (strncmp($frame['function'], 'expect', 6) == 0) {  
397 - return true;  
398 - }  
399 - return false;  
400 - }  
401 } 359 }
402 ?> 360 ?>
403 \ No newline at end of file 361 \ No newline at end of file
thirdparty/simpletest/simpletest/encoding.php
@@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
37 * @access public 37 * @access public
38 */ 38 */
39 function asRequest() { 39 function asRequest() {
40 - return $this->_key . '=' . urlencode($this->_value); 40 + return urlencode($this->_key) . '=' . urlencode($this->_value);
41 } 41 }
42 42
43 /** 43 /**
thirdparty/simpletest/simpletest/errors.php
@@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
15 * Includes SimpleTest files. 15 * Includes SimpleTest files.
16 */ 16 */
17 require_once(dirname(__FILE__) . '/invoker.php'); 17 require_once(dirname(__FILE__) . '/invoker.php');
  18 + require_once(dirname(__FILE__) . '/test_case.php');
  19 + require_once(dirname(__FILE__) . '/expectation.php');
18 20
19 /** 21 /**
20 * Extension that traps errors into an error queue. 22 * Extension that traps errors into an error queue.
@@ -39,13 +41,15 @@ @@ -39,13 +41,15 @@
39 * @access public 41 * @access public
40 */ 42 */
41 function invoke($method) { 43 function invoke($method) {
42 - set_error_handler('simpleTestErrorHandler'); 44 + $context = &SimpleTest::getContext();
  45 + $queue = &$context->get('SimpleErrorQueue');
  46 + $queue->setTestCase($this->GetTestCase());
  47 + set_error_handler('SimpleTestErrorHandler');
43 parent::invoke($method); 48 parent::invoke($method);
44 - $queue = &SimpleErrorQueue::instance();  
45 - while (list($severity, $message, $file, $line, $globals) = $queue->extract()) { 49 + while (list($severity, $message, $file, $line) = $queue->extract()) {
46 $severity = SimpleErrorQueue::getSeverityAsString($severity); 50 $severity = SimpleErrorQueue::getSeverityAsString($severity);
47 - $test_case = &$this->getTestCase();  
48 - $test_case->error($severity, $message, $file, $line); 51 + $test = &$this->getTestCase();
  52 + $test->error($severity, $message, $file, $line);
49 } 53 }
50 restore_error_handler(); 54 restore_error_handler();
51 } 55 }
@@ -59,28 +63,63 @@ @@ -59,28 +63,63 @@
59 */ 63 */
60 class SimpleErrorQueue { 64 class SimpleErrorQueue {
61 var $_queue; 65 var $_queue;
  66 + var $_expectation_queue;
  67 + var $_test;
62 68
63 /** 69 /**
64 * Starts with an empty queue. 70 * Starts with an empty queue.
65 - * @access public  
66 */ 71 */
67 function SimpleErrorQueue() { 72 function SimpleErrorQueue() {
68 $this->clear(); 73 $this->clear();
69 } 74 }
70 75
71 /** 76 /**
  77 + * Sets the currently running test case.
  78 + * @param SimpleTestCase $test Test case to send messages to.
  79 + * @access public
  80 + */
  81 + function setTestCase(&$test) {
  82 + $this->_test = &$test;
  83 + }
  84 +
  85 + /**
72 * Adds an error to the front of the queue. 86 * Adds an error to the front of the queue.
73 - * @param $severity PHP error code.  
74 - * @param $message Text of error.  
75 - * @param $filename File error occoured in.  
76 - * @param $line Line number of error.  
77 - * @param $super_globals Hash of PHP super global arrays. 87 + * @param integer $severity PHP error code.
  88 + * @param string $content Text of error.
  89 + * @param string $filename File error occoured in.
  90 + * @param integer $line Line number of error.
78 * @access public 91 * @access public
79 */ 92 */
80 - function add($severity, $message, $filename, $line, $super_globals) {  
81 - array_push(  
82 - $this->_queue,  
83 - array($severity, $message, $filename, $line, $super_globals)); 93 + function add($severity, $content, $filename, $line) {
  94 + $content = str_replace('%', '%%', $content);
  95 + if (count($this->_expectation_queue)) {
  96 + $this->_testLatestError($severity, $content, $filename, $line);
  97 + } else {
  98 + array_push(
  99 + $this->_queue,
  100 + array($severity, $content, $filename, $line));
  101 + }
  102 + }
  103 +
  104 + /**
  105 + * Tests the error against the most recent expected
  106 + * error.
  107 + * @param integer $severity PHP error code.
  108 + * @param string $content Text of error.
  109 + * @param string $filename File error occoured in.
  110 + * @param integer $line Line number of error.
  111 + * @access private
  112 + */
  113 + function _testLatestError($severity, $content, $filename, $line) {
  114 + list($expected, $message) = array_shift($this->_expectation_queue);
  115 + $severity = $this->getSeverityAsString($severity);
  116 + $is_match = $this->_test->assert(
  117 + $expected,
  118 + $content,
  119 + sprintf($message, "%s -> PHP error [$content] severity [$severity] in [$filename] line [$line]"));
  120 + if (! $is_match) {
  121 + $this->_test->error($severity, $content, $filename, $line);
  122 + }
84 } 123 }
85 124
86 /** 125 /**
@@ -105,32 +144,52 @@ @@ -105,32 +144,52 @@
105 */ 144 */
106 function clear() { 145 function clear() {
107 $this->_queue = array(); 146 $this->_queue = array();
  147 + $this->_expectation_queue = array();
108 } 148 }
109 149
110 /** 150 /**
111 - * Tests to see if the queue is empty.  
112 - * @return True if empty. 151 + * @deprecated
113 */ 152 */
114 - function isEmpty() {  
115 - return (count($this->_queue) == 0); 153 + function assertNoErrors($message) {
  154 + return $this->_test->assert(
  155 + new TrueExpectation(),
  156 + count($this->_queue) == 0,
  157 + sprintf($message, 'Should be no errors'));
116 } 158 }
117 159
118 /** 160 /**
119 - * Global access to a single error queue.  
120 - * @return Global error queue object.  
121 - * @access public  
122 - * @static 161 + * @deprecated
123 */ 162 */
124 - function &instance() {  
125 - static $queue = false;  
126 - if (! $queue) {  
127 - $queue = new SimpleErrorQueue(); 163 + function assertError($expected, $message) {
  164 + if (count($this->_queue) == 0) {
  165 + $this->_test->fail(sprintf($message, 'Expected error not found'));
  166 + return false;
128 } 167 }
129 - return $queue; 168 + list($severity, $content, $file, $line) = $this->extract();
  169 + $severity = $this->getSeverityAsString($severity);
  170 + return $this->_test->assert(
  171 + $expected,
  172 + $content,
  173 + sprintf($message, "Expected PHP error [$content] severity [$severity] in [$file] line [$line]"));
  174 + }
  175 +
  176 + /**
  177 + * Sets up an expectation of an error. If this is
  178 + * not fulfilled at the end of the test, a failure
  179 + * will occour. If the error does happen, then this
  180 + * will cancel it out and send a pass message.
  181 + * @param SimpleExpectation $expected Expected error match.
  182 + * @param string $message Message to display.
  183 + * @access public
  184 + */
  185 + function expectError($expected, $message) {
  186 + array_push(
  187 + $this->_expectation_queue,
  188 + array($expected, $message));
130 } 189 }
131 190
132 /** 191 /**
133 - * Converst an error code into it's string 192 + * Converts an error code into it's string
134 * representation. 193 * representation.
135 * @param $severity PHP integer error code. 194 * @param $severity PHP integer error code.
136 * @return String version of error code. 195 * @return String version of error code.
@@ -167,16 +226,17 @@ @@ -167,16 +226,17 @@
167 * @static 226 * @static
168 * @access public 227 * @access public
169 */ 228 */
170 - function simpleTestErrorHandler($severity, $message, $filename, $line, $super_globals) { 229 + function SimpleTestErrorHandler($severity, $message, $filename, $line, $super_globals) {
171 if ($severity = $severity & error_reporting()) { 230 if ($severity = $severity & error_reporting()) {
172 restore_error_handler(); 231 restore_error_handler();
173 if (ini_get('log_errors')) { 232 if (ini_get('log_errors')) {
174 $label = SimpleErrorQueue::getSeverityAsString($severity); 233 $label = SimpleErrorQueue::getSeverityAsString($severity);
175 error_log("$label: $message in $filename on line $line"); 234 error_log("$label: $message in $filename on line $line");
176 } 235 }
177 - $queue = &SimpleErrorQueue::instance();  
178 - $queue->add($severity, $message, $filename, $line, $super_globals);  
179 - set_error_handler('simpleTestErrorHandler'); 236 + $context = &SimpleTest::getContext();
  237 + $queue = &$context->get('SimpleErrorQueue');
  238 + $queue->add($severity, $message, $filename, $line);
  239 + set_error_handler('SimpleTestErrorHandler');
180 } 240 }
181 } 241 }
182 ?> 242 ?>
183 \ No newline at end of file 243 \ No newline at end of file
thirdparty/simpletest/simpletest/exceptions.php 0 โ†’ 100644
  1 +<?php
  2 + /**
  3 + * base include file for SimpleTest
  4 + * @package SimpleTest
  5 + * @subpackage UnitTester
  6 + * @version $Id: exceptions.php,v 1.12 2006/11/09 23:14:48 lastcraft Exp $
  7 + */
  8 +
  9 + /**#@+
  10 + * Includes SimpleTest files and defined the root constant
  11 + * for dependent libraries.
  12 + */
  13 + require_once(dirname(__FILE__) . '/invoker.php');
  14 + require_once(dirname(__FILE__) . '/expectation.php');
  15 +
  16 + /**
  17 + * Extension that traps exceptions and turns them into
  18 + * an error message. PHP5 only.
  19 + * @package SimpleTest
  20 + * @subpackage UnitTester
  21 + */
  22 + class SimpleExceptionTrappingInvoker extends SimpleInvokerDecorator {
  23 +
  24 + /**
  25 + * Stores the invoker to be wrapped.
  26 + * @param SimpleInvoker $invoker Test method runner.
  27 + */
  28 + function SimpleExceptionTrappingInvoker($invoker) {
  29 + $this->SimpleInvokerDecorator($invoker);
  30 + }
  31 +
  32 + /**
  33 + * Invokes a test method whilst trapping expected
  34 + * exceptions. Any left over unthrown exceptions
  35 + * are then reported as failures.
  36 + * @param string $method Test method to call.
  37 + */
  38 + function invoke($method) {
  39 + $trap = SimpleTest::getContext()->get('SimpleExceptionTrap');
  40 + $trap->clear();
  41 + try {
  42 + parent::invoke($method);
  43 + } catch (Exception $exception) {
  44 + if (! $trap->isExpected($this->getTestCase(), $exception)) {
  45 + $this->getTestCase()->exception($exception);
  46 + }
  47 + $trap->clear();
  48 + }
  49 + if ($message = $trap->getOutstanding()) {
  50 + $this->getTestCase()->fail($message);
  51 + }
  52 + }
  53 + }
  54 +
  55 + /**
  56 + * Tests exceptions either by type or the exact
  57 + * exception. This could be improved to accept
  58 + * a pattern expectation to test the error
  59 + * message, but that will have to come later.
  60 + * @package SimpleTest
  61 + * @subpackage UnitTester
  62 + */
  63 + class ExceptionExpectation extends SimpleExpectation {
  64 + private $expected;
  65 +
  66 + /**
  67 + * Sets up the conditions to test against.
  68 + * If the expected value is a string, then
  69 + * it will act as a test of the class name.
  70 + * An exception as the comparison will
  71 + * trigger an identical match. Writing this
  72 + * down now makes it look doubly dumb. I hope
  73 + * come up with a better scheme later.
  74 + * @param mixed $expected A class name or an actual
  75 + * exception to compare with.
  76 + * @param string $message Message to display.
  77 + */
  78 + function __construct($expected, $message = '%s') {
  79 + $this->expected = $expected;
  80 + parent::__construct($message);
  81 + }
  82 +
  83 + /**
  84 + * Carry out the test.
  85 + * @param Exception $compare Value to check.
  86 + * @return boolean True if matched.
  87 + */
  88 + function test($compare) {
  89 + if (is_string($this->expected)) {
  90 + return ($compare instanceof $this->expected);
  91 + }
  92 + if (get_class($compare) != get_class($this->expected)) {
  93 + return false;
  94 + }
  95 + return $compare->getMessage() == $this->expected->getMessage();
  96 + }
  97 +
  98 + /**
  99 + * Create the message to display describing the test.
  100 + * @param Exception $compare Exception to match.
  101 + * @return string Final message.
  102 + */
  103 + function testMessage($compare) {
  104 + if (is_string($this->expected)) {
  105 + return "Exception [" . $this->describeException($compare) .
  106 + "] should be type [" . $this->expected . "]";
  107 + }
  108 + return "Exception [" . $this->describeException($compare) .
  109 + "] should match [" .
  110 + $this->describeException($this->expected) . "]";
  111 + }
  112 +
  113 + /**
  114 + * Summary of an Exception object.
  115 + * @param Exception $compare Exception to describe.
  116 + * @return string Text description.
  117 + */
  118 + protected function describeException($exception) {
  119 + return get_class($exception) . ": " . $exception->getMessage();
  120 + }
  121 + }
  122 +
  123 + /**
  124 + * Stores expected exceptions for when they
  125 + * get thrown. Saves the irritating try...catch
  126 + * block.
  127 + * @package SimpleTest
  128 + * @subpackage UnitTester
  129 + */
  130 + class SimpleExceptionTrap {
  131 + private $expected;
  132 + private $message;
  133 +
  134 + /**
  135 + * Clears down the queue ready for action.
  136 + */
  137 + function __construct() {
  138 + $this->clear();
  139 + }
  140 +
  141 + /**
  142 + * Sets up an expectation of an exception.
  143 + * This has the effect of intercepting an
  144 + * exception that matches.
  145 + * @param SimpleExpectation $expected Expected exception to match.
  146 + * @param string $message Message to display.
  147 + * @access public
  148 + */
  149 + function expectException($expected = false, $message = '%s') {
  150 + if ($expected === false) {
  151 + $expected = new AnythingExpectation();
  152 + }
  153 + if (! SimpleExpectation::isExpectation($expected)) {
  154 + $expected = new ExceptionExpectation($expected);
  155 + }
  156 + $this->expected = $expected;
  157 + $this->message = $message;
  158 + }
  159 +
  160 + /**
  161 + * Compares the expected exception with any
  162 + * in the queue. Issues a pass or fail and
  163 + * returns the state of the test.
  164 + * @param SimpleTestCase $test Test case to send messages to.
  165 + * @param Exception $exception Exception to compare.
  166 + * @return boolean False on no match.
  167 + */
  168 + function isExpected($test, $exception) {
  169 + if ($this->expected) {
  170 + return $test->assert($this->expected, $exception, $this->message);
  171 + }
  172 + return false;
  173 + }
  174 +
  175 + /**
  176 + * Tests for any left over exception.
  177 + * @return string/false The failure message or false if none.
  178 + */
  179 + function getOutstanding() {
  180 + return sprintf($this->message, 'Failed to trap exception');
  181 + }
  182 +
  183 + /**
  184 + * Discards the contents of the error queue.
  185 + */
  186 + function clear() {
  187 + $this->expected = false;
  188 + $this->message = false;
  189 + }
  190 + }
  191 +?>
0 \ No newline at end of file 192 \ No newline at end of file
thirdparty/simpletest/simpletest/expectation.php
@@ -30,7 +30,6 @@ @@ -30,7 +30,6 @@
30 * @param string $message Customised message on failure. 30 * @param string $message Customised message on failure.
31 */ 31 */
32 function SimpleExpectation($message = '%s') { 32 function SimpleExpectation($message = '%s') {
33 - $this->_dumper = &new SimpleDumper();  
34 $this->_message = $message; 33 $this->_message = $message;
35 } 34 }
36 35
@@ -58,12 +57,14 @@ @@ -58,12 +57,14 @@
58 /** 57 /**
59 * Overlays the generated message onto the stored user 58 * Overlays the generated message onto the stored user
60 * message. An additional message can be interjected. 59 * message. An additional message can be interjected.
61 - * @param mixed $compare Comparison value.  
62 - * @return string Description of success  
63 - * or failure. 60 + * @param mixed $compare Comparison value.
  61 + * @param SimpleDumper $dumper For formatting the results.
  62 + * @return string Description of success
  63 + * or failure.
64 * @access public 64 * @access public
65 */ 65 */
66 - function overlayMessage($compare) { 66 + function overlayMessage($compare, $dumper) {
  67 + $this->_dumper = $dumper;
67 return sprintf($this->_message, $this->testMessage($compare)); 68 return sprintf($this->_message, $this->testMessage($compare));
68 } 69 }
69 70
@@ -91,6 +92,96 @@ @@ -91,6 +92,96 @@
91 SimpleTestCompatibility::isA($expectation, 'SimpleExpectation'); 92 SimpleTestCompatibility::isA($expectation, 'SimpleExpectation');
92 } 93 }
93 } 94 }
  95 +
  96 + /**
  97 + * A wildcard expectation always matches.
  98 + * @package SimpleTest
  99 + * @subpackage MockObjects
  100 + */
  101 + class AnythingExpectation extends SimpleExpectation {
  102 +
  103 + /**
  104 + * Tests the expectation. Always true.
  105 + * @param mixed $compare Ignored.
  106 + * @return boolean True.
  107 + * @access public
  108 + */
  109 + function test($compare) {
  110 + return true;
  111 + }
  112 +
  113 + /**
  114 + * Returns a human readable test message.
  115 + * @param mixed $compare Comparison value.
  116 + * @return string Description of success
  117 + * or failure.
  118 + * @access public
  119 + */
  120 + function testMessage($compare) {
  121 + $dumper = &$this->_getDumper();
  122 + return 'Anything always matches [' . $dumper->describeValue($compare) . ']';
  123 + }
  124 + }
  125 +
  126 + /**
  127 + * An expectation that passes on boolean true.
  128 + * @package SimpleTest
  129 + * @subpackage MockObjects
  130 + */
  131 + class TrueExpectation extends SimpleExpectation {
  132 +
  133 + /**
  134 + * Tests the expectation.
  135 + * @param mixed $compare Should be true.
  136 + * @return boolean True on match.
  137 + * @access public
  138 + */
  139 + function test($compare) {
  140 + return (boolean)$compare;
  141 + }
  142 +
  143 + /**
  144 + * Returns a human readable test message.
  145 + * @param mixed $compare Comparison value.
  146 + * @return string Description of success
  147 + * or failure.
  148 + * @access public
  149 + */
  150 + function testMessage($compare) {
  151 + $dumper = &$this->_getDumper();
  152 + return 'Expected true, got [' . $dumper->describeValue($compare) . ']';
  153 + }
  154 + }
  155 +
  156 + /**
  157 + * An expectation that passes on boolean false.
  158 + * @package SimpleTest
  159 + * @subpackage MockObjects
  160 + */
  161 + class FalseExpectation extends SimpleExpectation {
  162 +
  163 + /**
  164 + * Tests the expectation.
  165 + * @param mixed $compare Should be false.
  166 + * @return boolean True on match.
  167 + * @access public
  168 + */
  169 + function test($compare) {
  170 + return ! (boolean)$compare;
  171 + }
  172 +
  173 + /**
  174 + * Returns a human readable test message.
  175 + * @param mixed $compare Comparison value.
  176 + * @return string Description of success
  177 + * or failure.
  178 + * @access public
  179 + */
  180 + function testMessage($compare) {
  181 + $dumper = &$this->_getDumper();
  182 + return 'Expected false, got [' . $dumper->describeValue($compare) . ']';
  183 + }
  184 + }
94 185
95 /** 186 /**
96 * Test for equality. 187 * Test for equality.
@@ -471,8 +562,8 @@ @@ -471,8 +562,8 @@
471 /** 562 /**
472 * Describes a pattern match including the string 563 * Describes a pattern match including the string
473 * found and it's position. 564 * found and it's position.
474 - * @package SimpleTest  
475 - * @subpackage UnitTester 565 + * @package SimpleTest
  566 + * @subpackage UnitTester
476 * @param string $pattern Regex to match against. 567 * @param string $pattern Regex to match against.
477 * @param string $subject Subject to search. 568 * @param string $subject Subject to search.
478 * @access protected 569 * @access protected
@@ -480,7 +571,7 @@ @@ -480,7 +571,7 @@
480 function _describePatternMatch($pattern, $subject) { 571 function _describePatternMatch($pattern, $subject) {
481 preg_match($pattern, $subject, $matches); 572 preg_match($pattern, $subject, $matches);
482 $position = strpos($subject, $matches[0]); 573 $position = strpos($subject, $matches[0]);
483 - $dumper = &$this->_getDumper(); 574 + $dumper = $this->_getDumper();
484 return "Pattern [$pattern] detected at character [$position] in [" . 575 return "Pattern [$pattern] detected at character [$position] in [" .
485 $dumper->describeValue($subject) . "] as [" . 576 $dumper->describeValue($subject) . "] as [" .
486 $matches[0] . "] in region [" . 577 $matches[0] . "] in region [" .
@@ -717,4 +808,4 @@ @@ -717,4 +808,4 @@
717 "] should contain method [$method]"; 808 "] should contain method [$method]";
718 } 809 }
719 } 810 }
720 -?> 811 -?>
  812 +?>
721 \ No newline at end of file 813 \ No newline at end of file
thirdparty/simpletest/simpletest/extensions/pear_test_case.php
@@ -58,7 +58,7 @@ @@ -58,7 +58,7 @@
58 * @public 58 * @public
59 */ 59 */
60 function assertNotNull($value, $message = "%s") { 60 function assertNotNull($value, $message = "%s") {
61 - parent::assertTrue(isset($value), $message); 61 + parent::assert(new TrueExpectation(), isset($value), $message);
62 } 62 }
63 63
64 /** 64 /**
@@ -68,7 +68,7 @@ @@ -68,7 +68,7 @@
68 * @public 68 * @public
69 */ 69 */
70 function assertNull($value, $message = "%s") { 70 function assertNull($value, $message = "%s") {
71 - parent::assertTrue(!isset($value), $message); 71 + parent::assert(new TrueExpectation(), !isset($value), $message);
72 } 72 }
73 73
74 /** 74 /**
@@ -86,7 +86,8 @@ @@ -86,7 +86,8 @@
86 "[" . $dumper->describeValue($first) . 86 "[" . $dumper->describeValue($first) .
87 "] and [" . $dumper->describeValue($second) . 87 "] and [" . $dumper->describeValue($second) .
88 "] should reference the same object"); 88 "] should reference the same object");
89 - return $this->assertTrue( 89 + return $this->assert(
  90 + new TrueExpectation(),
90 SimpleTestCompatibility::isReference($first, $second), 91 SimpleTestCompatibility::isReference($first, $second),
91 $message); 92 $message);
92 } 93 }
@@ -106,7 +107,8 @@ @@ -106,7 +107,8 @@
106 "[" . $dumper->describeValue($first) . 107 "[" . $dumper->describeValue($first) .
107 "] and [" . $dumper->describeValue($second) . 108 "] and [" . $dumper->describeValue($second) .
108 "] should not be the same object"); 109 "] should not be the same object");
109 - return $this->assertFalse( 110 + return $this->assert(
  111 + new falseExpectation(),
110 SimpleTestCompatibility::isReference($first, $second), 112 SimpleTestCompatibility::isReference($first, $second),
111 $message); 113 $message);
112 } 114 }
@@ -119,7 +121,7 @@ @@ -119,7 +121,7 @@
119 * @public 121 * @public
120 */ 122 */
121 function assertTrue($condition, $message = "%s") { 123 function assertTrue($condition, $message = "%s") {
122 - parent::assertTrue($condition, $message); 124 + parent::assert(new TrueExpectation(), $condition, $message);
123 } 125 }
124 126
125 /** 127 /**
@@ -130,7 +132,7 @@ @@ -130,7 +132,7 @@
130 * @public 132 * @public
131 */ 133 */
132 function assertFalse($condition, $message = "%s") { 134 function assertFalse($condition, $message = "%s") {
133 - parent::assertTrue(!$condition, $message); 135 + parent::assert(new FalseExpectation(), $condition, $message);
134 } 136 }
135 137
136 /** 138 /**
@@ -152,7 +154,7 @@ @@ -152,7 +154,7 @@
152 * @public 154 * @public
153 */ 155 */
154 function assertType($value, $type, $message = "%s") { 156 function assertType($value, $type, $message = "%s") {
155 - parent::assertTrue(gettype($value) == strtolower($type), $message); 157 + parent::assert(new TrueExpectation(), gettype($value) == strtolower($type), $message);
156 } 158 }
157 159
158 /** 160 /**
thirdparty/simpletest/simpletest/extensions/phpunit_test_case.php
@@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
38 * @public 38 * @public
39 */ 39 */
40 function assert($condition, $message = false) { 40 function assert($condition, $message = false) {
41 - parent::assertTrue($condition, $message); 41 + parent::assert(new TrueExpectation(), $condition, $message);
42 } 42 }
43 43
44 /** 44 /**
thirdparty/simpletest/simpletest/mock_objects.php
@@ -27,36 +27,6 @@ @@ -27,36 +27,6 @@
27 } 27 }
28 28
29 /** 29 /**
30 - * A wildcard expectation always matches.  
31 - * @package SimpleTest  
32 - * @subpackage MockObjects  
33 - */  
34 - class AnythingExpectation extends SimpleExpectation {  
35 -  
36 - /**  
37 - * Tests the expectation. Always true.  
38 - * @param mixed $compare Ignored.  
39 - * @return boolean True.  
40 - * @access public  
41 - */  
42 - function test($compare) {  
43 - return true;  
44 - }  
45 -  
46 - /**  
47 - * Returns a human readable test message.  
48 - * @param mixed $compare Comparison value.  
49 - * @return string Description of success  
50 - * or failure.  
51 - * @access public  
52 - */  
53 - function testMessage($compare) {  
54 - $dumper = &$this->_getDumper();  
55 - return 'Anything always matches [' . $dumper->describeValue($compare) . ']';  
56 - }  
57 - }  
58 -  
59 - /**  
60 * Parameter comparison assertion. 30 * Parameter comparison assertion.
61 * @package SimpleTest 31 * @package SimpleTest
62 * @subpackage MockObjects 32 * @subpackage MockObjects
@@ -70,8 +40,6 @@ @@ -70,8 +40,6 @@
70 * those that are wildcarded. 40 * those that are wildcarded.
71 * If the value is not an array 41 * If the value is not an array
72 * then it is considered to match any. 42 * then it is considered to match any.
73 - * @param mixed $wildcard Any parameter matching this  
74 - * will always match.  
75 * @param string $message Customised message on failure. 43 * @param string $message Customised message on failure.
76 * @access public 44 * @access public
77 */ 45 */
@@ -151,7 +119,7 @@ @@ -151,7 +119,7 @@
151 $comparison = $this->_coerceToExpectation($expected[$i]); 119 $comparison = $this->_coerceToExpectation($expected[$i]);
152 if (! $comparison->test($parameters[$i])) { 120 if (! $comparison->test($parameters[$i])) {
153 $messages[] = "parameter " . ($i + 1) . " with [" . 121 $messages[] = "parameter " . ($i + 1) . " with [" .
154 - $comparison->overlayMessage($parameters[$i]) . "]"; 122 + $comparison->overlayMessage($parameters[$i], $this->_getDumper()) . "]";
155 } 123 }
156 } 124 }
157 return "Parameter expectation differs at " . implode(" and ", $messages); 125 return "Parameter expectation differs at " . implode(" and ", $messages);
@@ -473,7 +441,8 @@ @@ -473,7 +441,8 @@
473 * @access protected 441 * @access protected
474 */ 442 */
475 function &_getCurrentTestCase() { 443 function &_getCurrentTestCase() {
476 - return SimpleTest::getCurrent(); 444 + $context = &SimpleTest::getContext();
  445 + return $context->getTest();
477 } 446 }
478 447
479 /** 448 /**
@@ -809,20 +778,17 @@ @@ -809,20 +778,17 @@
809 * test method has finished. Totals up the call 778 * test method has finished. Totals up the call
810 * counts and triggers a test assertion if a test 779 * counts and triggers a test assertion if a test
811 * is present for expected call counts. 780 * is present for expected call counts.
812 - * @param string $method Current method name. 781 + * @param string $test_method Current method name.
  782 + * @param SimpleTestCase $test Test to send message to.
813 * @access public 783 * @access public
814 */ 784 */
815 - function atTestEnd($method) { 785 + function atTestEnd($test_method, &$test) {
816 foreach ($this->_expected_counts as $method => $expectation) { 786 foreach ($this->_expected_counts as $method => $expectation) {
817 - $this->_assertTrue(  
818 - $expectation->test($this->getCallCount($method)),  
819 - $expectation->overlayMessage($this->getCallCount($method))); 787 + $test->assert($expectation, $this->getCallCount($method));
820 } 788 }
821 foreach ($this->_max_counts as $method => $expectation) { 789 foreach ($this->_max_counts as $method => $expectation) {
822 if ($expectation->test($this->getCallCount($method))) { 790 if ($expectation->test($this->getCallCount($method))) {
823 - $this->_assertTrue(  
824 - true,  
825 - $expectation->overlayMessage($this->getCallCount($method))); 791 + $test->assert($expectation, $this->getCallCount($method));
826 } 792 }
827 } 793 }
828 } 794 }
@@ -880,39 +846,24 @@ @@ -880,39 +846,24 @@
880 * @access private 846 * @access private
881 */ 847 */
882 function _checkExpectations($method, $args, $timing) { 848 function _checkExpectations($method, $args, $timing) {
  849 + $test = &$this->_getCurrentTestCase();
883 if (isset($this->_max_counts[$method])) { 850 if (isset($this->_max_counts[$method])) {
884 if (! $this->_max_counts[$method]->test($timing + 1)) { 851 if (! $this->_max_counts[$method]->test($timing + 1)) {
885 - $this->_assertTrue(  
886 - false,  
887 - $this->_max_counts[$method]->overlayMessage($timing + 1)); 852 + $test->assert($this->_max_counts[$method], $timing + 1);
888 } 853 }
889 } 854 }
890 if (isset($this->_expected_args_at[$timing][$method])) { 855 if (isset($this->_expected_args_at[$timing][$method])) {
891 - $this->_assertTrue(  
892 - $this->_expected_args_at[$timing][$method]->test($args),  
893 - "Mock method [$method] at [$timing] -> " .  
894 - $this->_expected_args_at[$timing][$method]->overlayMessage($args)); 856 + $test->assert(
  857 + $this->_expected_args_at[$timing][$method],
  858 + $args,
  859 + "Mock method [$method] at [$timing] -> %s");
895 } elseif (isset($this->_expected_args[$method])) { 860 } elseif (isset($this->_expected_args[$method])) {
896 - $this->_assertTrue(  
897 - $this->_expected_args[$method]->test($args),  
898 - "Mock method [$method] -> " . $this->_expected_args[$method]->overlayMessage($args)); 861 + $test->assert(
  862 + $this->_expected_args[$method],
  863 + $args,
  864 + "Mock method [$method] -> %s");
899 } 865 }
900 } 866 }
901 -  
902 - /**  
903 - * Triggers an assertion on the held test case.  
904 - * Should be overridden when using another test  
905 - * framework other than the SimpleTest one if the  
906 - * assertion method has a different name.  
907 - * @param boolean $assertion True will pass.  
908 - * @param string $message Message that will go with  
909 - * the test event.  
910 - * @access protected  
911 - */  
912 - function _assertTrue($assertion, $message) {  
913 - $test = &$this->_getCurrentTestCase();  
914 - $test->assertTrue($assertion, $message);  
915 - }  
916 } 867 }
917 868
918 /** 869 /**
@@ -928,7 +879,7 @@ @@ -928,7 +879,7 @@
928 * @access public 879 * @access public
929 */ 880 */
930 function Mock() { 881 function Mock() {
931 - trigger_error('Mock factory methods are class only.'); 882 + trigger_error('Mock factory methods are static.');
932 } 883 }
933 884
934 /** 885 /**
@@ -970,19 +921,12 @@ @@ -970,19 +921,12 @@
970 921
971 /** 922 /**
972 * Uses a stack trace to find the line of an assertion. 923 * Uses a stack trace to find the line of an assertion.
973 - * @param array $stack Stack frames top most first. Only  
974 - * needed if not using the PHP  
975 - * backtrace function.  
976 - * @return string Location of first expect*  
977 - * method embedded in format string.  
978 * @access public 924 * @access public
979 * @static 925 * @static
980 */ 926 */
981 - function getExpectationLine($stack = false) {  
982 - if ($stack === false) {  
983 - $stack = SimpleTestCompatibility::getStackTrace();  
984 - }  
985 - return SimpleDumper::getFormattedAssertionLine($stack); 927 + function getExpectationLine() {
  928 + $trace = new SimpleStackTrace(array('expect'));
  929 + return $trace->traceMethod();
986 } 930 }
987 } 931 }
988 932
@@ -1051,7 +995,7 @@ @@ -1051,7 +995,7 @@
1051 } 995 }
1052 $mock_reflection = new SimpleReflection($this->_mock_class); 996 $mock_reflection = new SimpleReflection($this->_mock_class);
1053 if ($mock_reflection->classExistsSansAutoload()) { 997 if ($mock_reflection->classExistsSansAutoload()) {
1054 - trigger_error("Partial mock class [$mock_class] already exists"); 998 + trigger_error('Partial mock class [' . $this->_mock_class . '] already exists');
1055 return false; 999 return false;
1056 } 1000 }
1057 return eval($this->_extendClassCode($methods)); 1001 return eval($this->_extendClassCode($methods));
thirdparty/simpletest/simpletest/parser.php
@@ -645,13 +645,15 @@ @@ -645,13 +645,15 @@
645 * @access public 645 * @access public
646 */ 646 */
647 function acceptAttributeToken($token, $event) { 647 function acceptAttributeToken($token, $event) {
648 - if ($event == LEXER_UNMATCHED) {  
649 - $this->_attributes[$this->_current_attribute] .=  
650 - SimpleHtmlSaxParser::decodeHtml($token);  
651 - }  
652 - if ($event == LEXER_SPECIAL) {  
653 - $this->_attributes[$this->_current_attribute] .=  
654 - preg_replace('/^=\s*/' , '', SimpleHtmlSaxParser::decodeHtml($token)); 648 + if ($this->_current_attribute) {
  649 + if ($event == LEXER_UNMATCHED) {
  650 + $this->_attributes[$this->_current_attribute] .=
  651 + SimpleHtmlSaxParser::decodeHtml($token);
  652 + }
  653 + if ($event == LEXER_SPECIAL) {
  654 + $this->_attributes[$this->_current_attribute] .=
  655 + preg_replace('/^=\s*/' , '', SimpleHtmlSaxParser::decodeHtml($token));
  656 + }
655 } 657 }
656 return true; 658 return true;
657 } 659 }
thirdparty/simpletest/simpletest/reflection_php5.php
@@ -8,8 +8,8 @@ @@ -8,8 +8,8 @@
8 8
9 /** 9 /**
10 * Version specific reflection API. 10 * Version specific reflection API.
11 - * @package SimpleTest  
12 - * @subpackage UnitTester 11 + * @package SimpleTest
  12 + * @subpackage UnitTester
13 */ 13 */
14 class SimpleReflection { 14 class SimpleReflection {
15 var $_interface; 15 var $_interface;
@@ -193,12 +193,17 @@ @@ -193,12 +193,17 @@
193 * @access public 193 * @access public
194 */ 194 */
195 function getSignature($name) { 195 function getSignature($name) {
196 - if ($name == '__get') {  
197 - return 'function __get($key)';  
198 - }  
199 if ($name == '__set') { 196 if ($name == '__set') {
200 return 'function __set($key, $value)'; 197 return 'function __set($key, $value)';
201 } 198 }
  199 + if ($name == '__call') {
  200 + return 'function __call($method, $arguments)';
  201 + }
  202 + if (version_compare(phpversion(), '5.1.0', '>=')) {
  203 + if (in_array($name, array('__get', '__isset', $name == '__unset'))) {
  204 + return "function {$name}(\$key)";
  205 + }
  206 + }
202 if (! is_callable(array($this->_interface, $name))) { 207 if (! is_callable(array($this->_interface, $name))) {
203 return "function $name()"; 208 return "function $name()";
204 } 209 }
@@ -217,31 +222,31 @@ @@ -217,31 +222,31 @@
217 * @access private 222 * @access private
218 */ 223 */
219 function _getFullSignature($name) { 224 function _getFullSignature($name) {
220 - $interface = new ReflectionClass($this->_interface);  
221 - $method = $interface->getMethod($name);  
222 - $reference = $method->returnsReference() ? '&' : '';  
223 - return "function $reference$name(" .  
224 - implode(', ', $this->_getParameterSignatures($method)) .  
225 - ")"; 225 + $interface = new ReflectionClass($this->_interface);
  226 + $method = $interface->getMethod($name);
  227 + $reference = $method->returnsReference() ? '&' : '';
  228 + return "function $reference$name(" .
  229 + implode(', ', $this->_getParameterSignatures($method)) .
  230 + ")";
226 } 231 }
227 232
228 /** 233 /**
229 * Gets the source code for each parameter. 234 * Gets the source code for each parameter.
230 * @param ReflectionMethod $method Method object from 235 * @param ReflectionMethod $method Method object from
231 - * reflection API 236 + * reflection API
232 * @return array List of strings, each 237 * @return array List of strings, each
233 * a snippet of code. 238 * a snippet of code.
234 * @access private 239 * @access private
235 */ 240 */
236 function _getParameterSignatures($method) { 241 function _getParameterSignatures($method) {
237 - $signatures = array(); 242 + $signatures = array();
238 foreach ($method->getParameters() as $parameter) { 243 foreach ($method->getParameters() as $parameter) {
239 $type = $parameter->getClass(); 244 $type = $parameter->getClass();
240 $signatures[] = 245 $signatures[] =
241 - (! is_null($type) ? $type->getName() . ' ' : '') .  
242 - ($parameter->isPassedByReference() ? '&' : '') .  
243 - '$' . $this->_suppressSpurious($parameter->getName()) .  
244 - ($this->_isOptional($parameter) ? ' = null' : ''); 246 + (! is_null($type) ? $type->getName() . ' ' : '') .
  247 + ($parameter->isPassedByReference() ? '&' : '') .
  248 + '$' . $this->_suppressSpurious($parameter->getName()) .
  249 + ($this->_isOptional($parameter) ? ' = null' : '');
245 } 250 }
246 return $signatures; 251 return $signatures;
247 } 252 }
thirdparty/simpletest/simpletest/remote.php
@@ -75,7 +75,8 @@ @@ -75,7 +75,8 @@
75 * @access protected 75 * @access protected
76 */ 76 */
77 function &_createBrowser() { 77 function &_createBrowser() {
78 - return new SimpleBrowser(); 78 + $browser = &new SimpleBrowser();
  79 + return $browser;
79 } 80 }
80 81
81 /** 82 /**
@@ -85,7 +86,8 @@ @@ -85,7 +86,8 @@
85 * @access protected 86 * @access protected
86 */ 87 */
87 function &_createParser(&$reporter) { 88 function &_createParser(&$reporter) {
88 - return new SimpleTestXmlParser($reporter); 89 + $parser = &new SimpleTestXmlParser($reporter);
  90 + return $parser;
89 } 91 }
90 92
91 /** 93 /**
thirdparty/simpletest/simpletest/reporter.php
@@ -40,6 +40,7 @@ @@ -40,6 +40,7 @@
40 */ 40 */
41 function paintHeader($test_name) { 41 function paintHeader($test_name) {
42 $this->sendNoCacheHeaders(); 42 $this->sendNoCacheHeaders();
  43 + print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
43 print "<html>\n<head>\n<title>$test_name</title>\n"; 44 print "<html>\n<head>\n<title>$test_name</title>\n";
44 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . 45 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" .
45 $this->_character_set . "\">\n"; 46 $this->_character_set . "\">\n";
@@ -74,7 +75,9 @@ @@ -74,7 +75,9 @@
74 * @access protected 75 * @access protected
75 */ 76 */
76 function _getCss() { 77 function _getCss() {
77 - return ".fail { color: red; } pre { background-color: lightgray; }"; 78 + return ".fail { background-color: inherit; color: red; }" .
  79 + ".pass { background-color: inherit; color: green; }" .
  80 + " pre { background-color: lightgray; color: inherit; }";
78 } 81 }
79 82
80 /** 83 /**
@@ -115,10 +118,9 @@ @@ -115,10 +118,9 @@
115 } 118 }
116 119
117 /** 120 /**
118 - * Paints a PHP error or exception. 121 + * Paints a PHP error.
119 * @param string $message Message is ignored. 122 * @param string $message Message is ignored.
120 * @access public 123 * @access public
121 - * @abstract  
122 */ 124 */
123 function paintError($message) { 125 function paintError($message) {
124 parent::paintError($message); 126 parent::paintError($message);
@@ -130,6 +132,38 @@ @@ -130,6 +132,38 @@
130 } 132 }
131 133
132 /** 134 /**
  135 + * Paints a PHP exception.
  136 + * @param Exception $exception Exception to display.
  137 + * @access public
  138 + */
  139 + function paintException($exception) {
  140 + parent::paintException($exception);
  141 + print "<span class=\"fail\">Exception</span>: ";
  142 + $breadcrumb = $this->getTestList();
  143 + array_shift($breadcrumb);
  144 + print implode(" -&gt; ", $breadcrumb);
  145 + $message = 'Unexpected exception of type [' . get_class($exception) .
  146 + '] with message ['. $exception->getMessage() .
  147 + '] in ['. $exception->getFile() .
  148 + ' line ' . $exception->getLine() . ']';
  149 + print " -&gt; <strong>" . $this->_htmlEntities($message) . "</strong><br />\n";
  150 + }
  151 +
  152 + /**
  153 + * Prints the message for skipping tests.
  154 + * @param string $message Text of skip condition.
  155 + * @access public
  156 + */
  157 + function paintSkip($message) {
  158 + parent::paintSkip($message);
  159 + print "<span class=\"pass\">Skipped</span>: ";
  160 + $breadcrumb = $this->getTestList();
  161 + array_shift($breadcrumb);
  162 + print implode(" -&gt; ", $breadcrumb);
  163 + print " -&gt; " . $this->_htmlEntities($message) . "<br />\n";
  164 + }
  165 +
  166 + /**
133 * Paints formatted text such as dumped variables. 167 * Paints formatted text such as dumped variables.
134 * @param string $message Text to show. 168 * @param string $message Text to show.
135 * @access public 169 * @access public
@@ -218,7 +252,7 @@ @@ -218,7 +252,7 @@
218 252
219 /** 253 /**
220 * Paints a PHP error or exception. 254 * Paints a PHP error or exception.
221 - * @param string $message Message is ignored. 255 + * @param string $message Message to be shown.
222 * @access public 256 * @access public
223 * @abstract 257 * @abstract
224 */ 258 */
@@ -228,6 +262,31 @@ @@ -228,6 +262,31 @@
228 } 262 }
229 263
230 /** 264 /**
  265 + * Paints a PHP error or exception.
  266 + * @param Exception $exception Exception to describe.
  267 + * @access public
  268 + * @abstract
  269 + */
  270 + function paintException($exception) {
  271 + parent::paintException($exception);
  272 + $message = 'Unexpected exception of type [' . get_class($exception) .
  273 + '] with message ['. $exception->getMessage() .
  274 + '] in ['. $exception->getFile() .
  275 + ' line ' . $exception->getLine() . ']';
  276 + print "Exception " . $this->getExceptionCount() . "!\n$message\n";
  277 + }
  278 +
  279 + /**
  280 + * Prints the message for skipping tests.
  281 + * @param string $message Text of skip condition.
  282 + * @access public
  283 + */
  284 + function paintSkip($message) {
  285 + parent::paintSkip($message);
  286 + print "Skip: $message\n";
  287 + }
  288 +
  289 + /**
231 * Paints formatted text such as dumped variables. 290 * Paints formatted text such as dumped variables.
232 * @param string $message Text to show. 291 * @param string $message Text to show.
233 * @access public 292 * @access public
thirdparty/simpletest/simpletest/scorer.php
@@ -149,8 +149,7 @@ @@ -149,8 +149,7 @@
149 } 149 }
150 150
151 /** 151 /**
152 - * Deals with PHP 4 throwing an error or PHP 5  
153 - * throwing an exception. 152 + * Deals with PHP 4 throwing an error.
154 * @param string $message Text of error formatted by 153 * @param string $message Text of error formatted by
155 * the test case. 154 * the test case.
156 * @access public 155 * @access public
@@ -160,6 +159,23 @@ @@ -160,6 +159,23 @@
160 } 159 }
161 160
162 /** 161 /**
  162 + * Deals with PHP 5 throwing an exception.
  163 + * @param Exception $exception The actual exception thrown.
  164 + * @access public
  165 + */
  166 + function paintException($exception) {
  167 + $this->_exceptions++;
  168 + }
  169 +
  170 + /**
  171 + * Prints the message for skipping tests.
  172 + * @param string $message Text of skip condition.
  173 + * @access public
  174 + */
  175 + function paintSkip($message) {
  176 + }
  177 +
  178 + /**
163 * Accessor for the number of passes so far. 179 * Accessor for the number of passes so far.
164 * @return integer Number of passes. 180 * @return integer Number of passes.
165 * @access public 181 * @access public
@@ -237,6 +253,16 @@ @@ -237,6 +253,16 @@
237 $this->_size = null; 253 $this->_size = null;
238 $this->_progress = 0; 254 $this->_progress = 0;
239 } 255 }
  256 +
  257 + /**
  258 + * Gets the formatter for variables and other small
  259 + * generic data items.
  260 + * @return SimpleDumper Formatter.
  261 + * @access public
  262 + */
  263 + function getDumper() {
  264 + return new SimpleDumper();
  265 + }
240 266
241 /** 267 /**
242 * Paints the start of a group test. Will also paint 268 * Paints the start of a group test. Will also paint
@@ -393,7 +419,7 @@ @@ -393,7 +419,7 @@
393 var $_reporter; 419 var $_reporter;
394 420
395 /** 421 /**
396 - * Mediates between teh reporter and the test case. 422 + * Mediates between the reporter and the test case.
397 * @param SimpleScorer $reporter Reporter to receive events. 423 * @param SimpleScorer $reporter Reporter to receive events.
398 */ 424 */
399 function SimpleReporterDecorator(&$reporter) { 425 function SimpleReporterDecorator(&$reporter) {
@@ -443,6 +469,16 @@ @@ -443,6 +469,16 @@
443 function &createInvoker(&$invoker) { 469 function &createInvoker(&$invoker) {
444 return $this->_reporter->createInvoker($invoker); 470 return $this->_reporter->createInvoker($invoker);
445 } 471 }
  472 +
  473 + /**
  474 + * Gets the formatter for variables and other small
  475 + * generic data items.
  476 + * @return SimpleDumper Formatter.
  477 + * @access public
  478 + */
  479 + function getDumper() {
  480 + return $this->_reporter->getDumper();
  481 + }
446 482
447 /** 483 /**
448 * Paints the start of a group test. 484 * Paints the start of a group test.
@@ -529,6 +565,24 @@ @@ -529,6 +565,24 @@
529 565
530 /** 566 /**
531 * Chains to the wrapped reporter. 567 * Chains to the wrapped reporter.
  568 + * @param Exception $exception Exception to show.
  569 + * @access public
  570 + */
  571 + function paintException($exception) {
  572 + $this->_reporter->paintException($exception);
  573 + }
  574 +
  575 + /**
  576 + * Prints the message for skipping tests.
  577 + * @param string $message Text of skip condition.
  578 + * @access public
  579 + */
  580 + function paintSkip($message) {
  581 + $this->_reporter->paintSkip($message);
  582 + }
  583 +
  584 + /**
  585 + * Chains to the wrapped reporter.
532 * @param string $message Text to display. 586 * @param string $message Text to display.
533 * @access public 587 * @access public
534 */ 588 */
@@ -635,6 +689,16 @@ @@ -635,6 +689,16 @@
635 } 689 }
636 return $invoker; 690 return $invoker;
637 } 691 }
  692 +
  693 + /**
  694 + * Gets the formatter for variables and other small
  695 + * generic data items.
  696 + * @return SimpleDumper Formatter.
  697 + * @access public
  698 + */
  699 + function getDumper() {
  700 + return new SimpleDumper();
  701 + }
638 702
639 /** 703 /**
640 * Paints the start of a group test. 704 * Paints the start of a group test.
@@ -736,6 +800,28 @@ @@ -736,6 +800,28 @@
736 $this->_reporters[$i]->paintError($message); 800 $this->_reporters[$i]->paintError($message);
737 } 801 }
738 } 802 }
  803 +
  804 + /**
  805 + * Chains to the wrapped reporter.
  806 + * @param Exception $exception Exception to display.
  807 + * @access public
  808 + */
  809 + function paintException($exception) {
  810 + for ($i = 0; $i < count($this->_reporters); $i++) {
  811 + $this->_reporters[$i]->paintException($exception);
  812 + }
  813 + }
  814 +
  815 + /**
  816 + * Prints the message for skipping tests.
  817 + * @param string $message Text of skip condition.
  818 + * @access public
  819 + */
  820 + function paintSkip($message) {
  821 + for ($i = 0; $i < count($this->_reporters); $i++) {
  822 + $this->_reporters[$i]->paintSkip($message);
  823 + }
  824 + }
739 825
740 /** 826 /**
741 * Chains to the wrapped reporter. 827 * Chains to the wrapped reporter.
thirdparty/simpletest/simpletest/shell_tester.php
@@ -63,7 +63,7 @@ @@ -63,7 +63,7 @@
63 63
64 /** 64 /**
65 * Test case for testing of command line scripts and 65 * Test case for testing of command line scripts and
66 - * utilities. Usually scripts taht are external to the 66 + * utilities. Usually scripts that are external to the
67 * PHP code, but support it in some way. 67 * PHP code, but support it in some way.
68 * @package SimpleTest 68 * @package SimpleTest
69 * @subpackage UnitTester 69 * @subpackage UnitTester
@@ -127,6 +127,33 @@ @@ -127,6 +127,33 @@
127 $shell = &$this->_getShell(); 127 $shell = &$this->_getShell();
128 return $shell->getOutputAsList(); 128 return $shell->getOutputAsList();
129 } 129 }
  130 +
  131 + /**
  132 + * Called from within the test methods to register
  133 + * passes and failures.
  134 + * @param boolean $result Pass on true.
  135 + * @param string $message Message to display describing
  136 + * the test state.
  137 + * @return boolean True on pass
  138 + * @access public
  139 + */
  140 + function assertTrue($result, $message = false) {
  141 + return $this->assert(new TrueExpectation(), $result, $message);
  142 + }
  143 +
  144 + /**
  145 + * Will be true on false and vice versa. False
  146 + * is the PHP definition of false, so that null,
  147 + * empty strings, zero and an empty array all count
  148 + * as false.
  149 + * @param boolean $result Pass on false.
  150 + * @param string $message Message to display.
  151 + * @return boolean True on pass
  152 + * @access public
  153 + */
  154 + function assertFalse($result, $message = '%s') {
  155 + return $this->assert(new FalseExpectation(), $result, $message);
  156 + }
130 157
131 /** 158 /**
132 * Will trigger a pass if the two parameters have 159 * Will trigger a pass if the two parameters have
@@ -303,4 +330,4 @@ @@ -303,4 +330,4 @@
303 return $shell; 330 return $shell;
304 } 331 }
305 } 332 }
306 -?>  
307 \ No newline at end of file 333 \ No newline at end of file
  334 +?>
thirdparty/simpletest/simpletest/simpletest.php
@@ -17,10 +17,8 @@ @@ -17,10 +17,8 @@
17 /**#@-*/ 17 /**#@-*/
18 18
19 /** 19 /**
20 - * Static global directives and options. I hate this  
21 - * class. It's a mixture of reference hacks, configuration  
22 - * and previous design screw-ups that I have to maintain  
23 - * to keep backward compatibility. 20 + * Registry and test context. Includes a few
  21 + * global options that I'm slowly getting rid of.
24 * @package SimpleTest 22 * @package SimpleTest
25 */ 23 */
26 class SimpleTest { 24 class SimpleTest {
@@ -59,8 +57,8 @@ @@ -59,8 +57,8 @@
59 * missing abstract declarations. This cannot 57 * missing abstract declarations. This cannot
60 * be done whilst loading classes wiithout forcing 58 * be done whilst loading classes wiithout forcing
61 * a particular order on the class declarations and 59 * a particular order on the class declarations and
62 - * the ignore() calls. It's nice to havethe ignore()  
63 - * calls at the top of teh file. 60 + * the ignore() calls. It's just nice to have the ignore()
  61 + * calls at the top of the file before the actual declarations.
64 * @param array $classes Class names of interest. 62 * @param array $classes Class names of interest.
65 * @static 63 * @static
66 * @access public 64 * @access public
@@ -157,30 +155,6 @@ @@ -157,30 +155,6 @@
157 } 155 }
158 156
159 /** 157 /**
160 - * Sets the current test case instance. This  
161 - * global instance can be used by the mock objects  
162 - * to send message to the test cases.  
163 - * @param SimpleTestCase $test Test case to register.  
164 - * @access public  
165 - * @static  
166 - */  
167 - function setCurrent(&$test) {  
168 - $registry = &SimpleTest::_getRegistry();  
169 - $registry['CurrentTestCase'] = &$test;  
170 - }  
171 -  
172 - /**  
173 - * Accessor for current test instance.  
174 - * @return SimpleTEstCase Currently running test.  
175 - * @access public  
176 - * @static  
177 - */  
178 - function &getCurrent() {  
179 - $registry = &SimpleTest::_getRegistry();  
180 - return $registry['CurrentTestCase'];  
181 - }  
182 -  
183 - /**  
184 * Accessor for global registry of options. 158 * Accessor for global registry of options.
185 * @return hash All stored values. 159 * @return hash All stored values.
186 * @access private 160 * @access private
@@ -195,6 +169,21 @@ @@ -195,6 +169,21 @@
195 } 169 }
196 170
197 /** 171 /**
  172 + * Accessor for the context of the current
  173 + * test run.
  174 + * @return SimpleTestContext Current test run.
  175 + * @access public
  176 + * @static
  177 + */
  178 + function &getContext() {
  179 + static $context = false;
  180 + if (! $context) {
  181 + $context = new SimpleTestContext();
  182 + }
  183 + return $context;
  184 + }
  185 +
  186 + /**
198 * Constant default values. 187 * Constant default values.
199 * @return hash All registry defaults. 188 * @return hash All registry defaults.
200 * @access private 189 * @access private
@@ -212,6 +201,168 @@ @@ -212,6 +201,168 @@
212 } 201 }
213 202
214 /** 203 /**
  204 + * Container for all components for a specific
  205 + * test run. Makes things like error queues
  206 + * available to PHP event handlers, and also
  207 + * gets around some nasty reference issues in
  208 + * the mocks.
  209 + * @package SimpleTest
  210 + */
  211 + class SimpleTestContext {
  212 + var $_test;
  213 + var $_reporter;
  214 + var $_resources;
  215 +
  216 + /**
  217 + * Clears down the current context.
  218 + * @access public
  219 + */
  220 + function clear() {
  221 + $this->_resources = array();
  222 + }
  223 +
  224 + /**
  225 + * Sets the current test case instance. This
  226 + * global instance can be used by the mock objects
  227 + * to send message to the test cases.
  228 + * @param SimpleTestCase $test Test case to register.
  229 + * @access public
  230 + */
  231 + function setTest(&$test) {
  232 + $this->clear();
  233 + $this->_test = &$test;
  234 + }
  235 +
  236 + /**
  237 + * Accessor for currently running test case.
  238 + * @return SimpleTestCase Current test.
  239 + * @acess pubic
  240 + */
  241 + function &getTest() {
  242 + return $this->_test;
  243 + }
  244 +
  245 + /**
  246 + * Sets the current reporter. This
  247 + * global instance can be used by the mock objects
  248 + * to send messages.
  249 + * @param SimpleReporter $reporter Reporter to register.
  250 + * @access public
  251 + */
  252 + function setReporter(&$reporter) {
  253 + $this->clear();
  254 + $this->_reporter = &$reporter;
  255 + }
  256 +
  257 + /**
  258 + * Accessor for current reporter.
  259 + * @return SimpleReporter Current reporter.
  260 + * @acess pubic
  261 + */
  262 + function &getReporter() {
  263 + return $this->_reporter;
  264 + }
  265 +
  266 + /**
  267 + * Accessor for the Singleton resource.
  268 + * @return object Global resource.
  269 + * @access public
  270 + * @static
  271 + */
  272 + function &get($resource) {
  273 + if (! isset($this->_resources[$resource])) {
  274 + $this->_resources[$resource] = &new $resource();
  275 + }
  276 + return $this->_resources[$resource];
  277 + }
  278 + }
  279 +
  280 + /**
  281 + * Interrogates the stack trace to recover the
  282 + * failure point.
  283 + * @package SimpleTest
  284 + * @subpackage UnitTester
  285 + */
  286 + class SimpleStackTrace {
  287 + var $_prefixes;
  288 +
  289 + /**
  290 + * Stashes the list of target prefixes.
  291 + * @param array $prefixes List of method prefixes
  292 + * to search for.
  293 + */
  294 + function SimpleStackTrace($prefixes) {
  295 + $this->_prefixes = $prefixes;
  296 + }
  297 +
  298 + /**
  299 + * Extracts the last method name that was not within
  300 + * Simpletest itself. Captures a stack trace if none given.
  301 + * @param array $stack List of stack frames.
  302 + * @return string Snippet of test report with line
  303 + * number and file.
  304 + * @access public
  305 + */
  306 + function traceMethod($stack = false) {
  307 + $stack = $stack ? $stack : $this->_captureTrace();
  308 + foreach ($stack as $frame) {
  309 + if ($this->_frameLiesWithinSimpleTestFolder($frame)) {
  310 + continue;
  311 + }
  312 + if ($this->_frameMatchesPrefix($frame)) {
  313 + return ' at [' . $frame['file'] . ' line ' . $frame['line'] . ']';
  314 + }
  315 + }
  316 + return '';
  317 + }
  318 +
  319 + /**
  320 + * Test to see if error is generated by SimpleTest itself.
  321 + * @param array $frame PHP stack frame.
  322 + * @return boolean True if a SimpleTest file.
  323 + * @access private
  324 + */
  325 + function _frameLiesWithinSimpleTestFolder($frame) {
  326 + if (isset($frame['file'])) {
  327 + $path = substr(SIMPLE_TEST, 0, -1);
  328 + if (strpos($frame['file'], $path) === 0) {
  329 + if (dirname($frame['file']) == $path) {
  330 + return true;
  331 + }
  332 + }
  333 + }
  334 + return false;
  335 + }
  336 +
  337 + /**
  338 + * Tries to determine if the method call is an assert, etc.
  339 + * @param array $frame PHP stack frame.
  340 + * @return boolean True if matches a target.
  341 + * @access private
  342 + */
  343 + function _frameMatchesPrefix($frame) {
  344 + foreach ($this->_prefixes as $prefix) {
  345 + if (strncmp($frame['function'], $prefix, strlen($prefix)) == 0) {
  346 + return true;
  347 + }
  348 + }
  349 + return false;
  350 + }
  351 +
  352 + /**
  353 + * Grabs a current stack trace.
  354 + * @return array Fulle trace.
  355 + * @access private
  356 + */
  357 + function _captureTrace() {
  358 + if (function_exists('debug_backtrace')) {
  359 + return array_reverse(debug_backtrace());
  360 + }
  361 + return array();
  362 + }
  363 + }
  364 +
  365 + /**
215 * @deprecated 366 * @deprecated
216 */ 367 */
217 class SimpleTestOptions extends SimpleTest { 368 class SimpleTestOptions extends SimpleTest {
@@ -279,4 +430,4 @@ @@ -279,4 +430,4 @@
279 return Simpletest::getDefaultProxyPassword(); 430 return Simpletest::getDefaultProxyPassword();
280 } 431 }
281 } 432 }
282 -?>  
283 \ No newline at end of file 433 \ No newline at end of file
  434 +?>
thirdparty/simpletest/simpletest/test_case.php
@@ -24,10 +24,8 @@ @@ -24,10 +24,8 @@
24 require_once(dirname(__FILE__) . '/reflection_php4.php'); 24 require_once(dirname(__FILE__) . '/reflection_php4.php');
25 } 25 }
26 if (! defined('SIMPLE_TEST')) { 26 if (! defined('SIMPLE_TEST')) {
27 - /**  
28 - * @ignore  
29 - */  
30 - define('SIMPLE_TEST', dirname(__FILE__) . '/'); 27 + /** @ignore */
  28 + define('SIMPLE_TEST', dirname(__FILE__) . DIRECTORY_SEPARATOR);
31 } 29 }
32 /**#@-*/ 30 /**#@-*/
33 31
@@ -43,6 +41,7 @@ @@ -43,6 +41,7 @@
43 var $_label = false; 41 var $_label = false;
44 var $_reporter; 42 var $_reporter;
45 var $_observers; 43 var $_observers;
  44 + var $_should_skip = false;
46 45
47 /** 46 /**
48 * Sets up the test with no display. 47 * Sets up the test with no display.
@@ -66,6 +65,41 @@ @@ -66,6 +65,41 @@
66 } 65 }
67 66
68 /** 67 /**
  68 + * This is a placeholder for skipping tests. In this
  69 + * method you place skipIf() and skipUnless() calls to
  70 + * set the skipping state.
  71 + * @access public
  72 + */
  73 + function skip() {
  74 + }
  75 +
  76 + /**
  77 + * Will issue a message to the reporter and tell the test
  78 + * case to skip if the incoming flag is true.
  79 + * @param string $should_skip Condition causing the tests to be skipped.
  80 + * @param string $message Text of skip condition.
  81 + * @access public
  82 + */
  83 + function skipIf($should_skip, $message = '%s') {
  84 + if ($should_skip && ! $this->_should_skip) {
  85 + $this->_should_skip = true;
  86 + $message = sprintf($message, 'Skipping [' . get_class($this) . ']');
  87 + $this->_reporter->paintSkip($message . $this->getAssertionLine());
  88 + }
  89 + }
  90 +
  91 + /**
  92 + * Will issue a message to the reporter and tell the test
  93 + * case to skip if the incoming flag is false.
  94 + * @param string $shouldnt_skip Condition causing the tests to be run.
  95 + * @param string $message Text of skip condition.
  96 + * @access public
  97 + */
  98 + function skipUnless($shouldnt_skip, $message = false) {
  99 + $this->skipIf(! $shouldnt_skip, $message);
  100 + }
  101 +
  102 + /**
69 * Used to invoke the single tests. 103 * Used to invoke the single tests.
70 * @return SimpleInvoker Individual test runner. 104 * @return SimpleInvoker Individual test runner.
71 * @access public 105 * @access public
@@ -83,21 +117,27 @@ @@ -83,21 +117,27 @@
83 * starting with the string "test" unless a method 117 * starting with the string "test" unless a method
84 * is specified. 118 * is specified.
85 * @param SimpleReporter $reporter Current test reporter. 119 * @param SimpleReporter $reporter Current test reporter.
  120 + * @return boolean True if all tests passed.
86 * @access public 121 * @access public
87 */ 122 */
88 function run(&$reporter) { 123 function run(&$reporter) {
89 - SimpleTest::setCurrent($this); 124 + $context = &SimpleTest::getContext();
  125 + $context->setTest($this);
  126 + $context->setReporter($reporter);
90 $this->_reporter = &$reporter; 127 $this->_reporter = &$reporter;
91 - $this->_reporter->paintCaseStart($this->getLabel());  
92 - foreach ($this->getTests() as $method) {  
93 - if ($this->_reporter->shouldInvoke($this->getLabel(), $method)) {  
94 - $invoker = &$this->_reporter->createInvoker($this->createInvoker());  
95 - $invoker->before($method);  
96 - $invoker->invoke($method);  
97 - $invoker->after($method); 128 + $reporter->paintCaseStart($this->getLabel());
  129 + $this->skip();
  130 + if (! $this->_should_skip) {
  131 + foreach ($this->getTests() as $method) {
  132 + if ($reporter->shouldInvoke($this->getLabel(), $method)) {
  133 + $invoker = &$this->_reporter->createInvoker($this->createInvoker());
  134 + $invoker->before($method);
  135 + $invoker->invoke($method);
  136 + $invoker->after($method);
  137 + }
98 } 138 }
99 } 139 }
100 - $this->_reporter->paintCaseEnd($this->getLabel()); 140 + $reporter->paintCaseEnd($this->getLabel());
101 unset($this->_reporter); 141 unset($this->_reporter);
102 return $reporter->getStatus(); 142 return $reporter->getStatus();
103 } 143 }
@@ -169,7 +209,7 @@ @@ -169,7 +209,7 @@
169 */ 209 */
170 function after($method) { 210 function after($method) {
171 for ($i = 0; $i < count($this->_observers); $i++) { 211 for ($i = 0; $i < count($this->_observers); $i++) {
172 - $this->_observers[$i]->atTestEnd($method); 212 + $this->_observers[$i]->atTestEnd($method, $this);
173 } 213 }
174 $this->_reporter->paintMethodEnd($method); 214 $this->_reporter->paintMethodEnd($method);
175 } 215 }
@@ -185,9 +225,7 @@ @@ -185,9 +225,7 @@
185 } 225 }
186 226
187 /** 227 /**
188 - * Sends a pass event with a message.  
189 - * @param string $message Message to send.  
190 - * @access public 228 + * @deprecated
191 */ 229 */
192 function pass($message = "Pass") { 230 function pass($message = "Pass") {
193 if (! isset($this->_reporter)) { 231 if (! isset($this->_reporter)) {
@@ -226,7 +264,7 @@ @@ -226,7 +264,7 @@
226 trigger_error('Can only make assertions within test methods'); 264 trigger_error('Can only make assertions within test methods');
227 } 265 }
228 $this->_reporter->paintError( 266 $this->_reporter->paintError(
229 - "Unexpected PHP error [$message] severity [$severity] in [$file] line [$line]"); 267 + "Unexpected PHP error [$message] severity [$severity] in [$file line $line]");
230 } 268 }
231 269
232 /** 270 /**
@@ -236,21 +274,11 @@ @@ -236,21 +274,11 @@
236 * @access public 274 * @access public
237 */ 275 */
238 function exception($exception) { 276 function exception($exception) {
239 - $this->_reporter->paintError(  
240 - 'Unexpected exception of type [' . get_class($exception) .  
241 - '] with message ['. $exception->getMessage() .  
242 - '] in ['. $exception->getFile() .  
243 - '] line [' . $exception->getLine() . ']'); 277 + $this->_reporter->paintException($exception);
244 } 278 }
245 279
246 /** 280 /**
247 - * Sends a user defined event to the test reporter.  
248 - * This is for small scale extension where  
249 - * both the test case and either the reporter or  
250 - * display are subclassed.  
251 - * @param string $type Type of event.  
252 - * @param mixed $payload Object or message to deliver.  
253 - * @access public 281 + * @deprecated
254 */ 282 */
255 function signal($type, &$payload) { 283 function signal($type, &$payload) {
256 if (! isset($this->_reporter)) { 284 if (! isset($this->_reporter)) {
@@ -260,15 +288,6 @@ @@ -260,15 +288,6 @@
260 } 288 }
261 289
262 /** 290 /**
263 - * Cancels any outstanding errors.  
264 - * @access public  
265 - */  
266 - function swallowErrors() {  
267 - $queue = &SimpleErrorQueue::instance();  
268 - $queue->clear();  
269 - }  
270 -  
271 - /**  
272 * Runs an expectation directly, for extending the 291 * Runs an expectation directly, for extending the
273 * tests with new expectation classes. 292 * tests with new expectation classes.
274 * @param SimpleExpectation $expectation Expectation subclass. 293 * @param SimpleExpectation $expectation Expectation subclass.
@@ -278,9 +297,15 @@ @@ -278,9 +297,15 @@
278 * @access public 297 * @access public
279 */ 298 */
280 function assert(&$expectation, $compare, $message = '%s') { 299 function assert(&$expectation, $compare, $message = '%s') {
281 - return $this->assertTrue(  
282 - $expectation->test($compare),  
283 - sprintf($message, $expectation->overlayMessage($compare))); 300 + if ($expectation->test($compare)) {
  301 + return $this->pass(sprintf(
  302 + $message,
  303 + $expectation->overlayMessage($compare, $this->_reporter->getDumper())));
  304 + } else {
  305 + return $this->fail(sprintf(
  306 + $message,
  307 + $expectation->overlayMessage($compare, $this->_reporter->getDumper())));
  308 + }
284 } 309 }
285 310
286 /** 311 /**
@@ -291,57 +316,14 @@ @@ -291,57 +316,14 @@
291 } 316 }
292 317
293 /** 318 /**
294 - * Called from within the test methods to register  
295 - * passes and failures.  
296 - * @param boolean $result Pass on true.  
297 - * @param string $message Message to display describing  
298 - * the test state.  
299 - * @return boolean True on pass  
300 - * @access public  
301 - */  
302 - function assertTrue($result, $message = false) {  
303 - if (! $message) {  
304 - $message = 'True assertion got ' . ($result ? 'True' : 'False');  
305 - }  
306 - if ($result) {  
307 - return $this->pass($message);  
308 - } else {  
309 - return $this->fail($message);  
310 - }  
311 - }  
312 -  
313 - /**  
314 - * Will be true on false and vice versa. False  
315 - * is the PHP definition of false, so that null,  
316 - * empty strings, zero and an empty array all count  
317 - * as false.  
318 - * @param boolean $result Pass on false.  
319 - * @param string $message Message to display.  
320 - * @return boolean True on pass  
321 - * @access public  
322 - */  
323 - function assertFalse($result, $message = false) {  
324 - if (! $message) {  
325 - $message = 'False assertion got ' . ($result ? 'True' : 'False');  
326 - }  
327 - return $this->assertTrue(! $result, $message);  
328 - }  
329 -  
330 - /**  
331 * Uses a stack trace to find the line of an assertion. 319 * Uses a stack trace to find the line of an assertion.
332 - * @param string $format String formatting.  
333 - * @param array $stack Stack frames top most first. Only  
334 - * needed if not using the PHP  
335 - * backtrace function.  
336 * @return string Line number of first assert* 320 * @return string Line number of first assert*
337 * method embedded in format string. 321 * method embedded in format string.
338 * @access public 322 * @access public
339 */ 323 */
340 - function getAssertionLine($stack = false) {  
341 - if ($stack === false) {  
342 - $stack = SimpleTestCompatibility::getStackTrace();  
343 - }  
344 - return SimpleDumper::getFormattedAssertionLine($stack); 324 + function getAssertionLine() {
  325 + $trace = new SimpleStackTrace(array('assert', 'expect', 'pass', 'fail', 'skip'));
  326 + return $trace->traceMethod();
345 } 327 }
346 328
347 /** 329 /**
@@ -354,7 +336,8 @@ @@ -354,7 +336,8 @@
354 * @access public 336 * @access public
355 */ 337 */
356 function dump($variable, $message = false) { 338 function dump($variable, $message = false) {
357 - $formatted = SimpleDumper::dump($variable); 339 + $dumper = $this->_reporter->getDumper();
  340 + $formatted = $dumper->dump($variable);
358 if ($message) { 341 if ($message) {
359 $formatted = $message . "\n" . $formatted; 342 $formatted = $message . "\n" . $formatted;
360 } 343 }
@@ -363,10 +346,7 @@ @@ -363,10 +346,7 @@
363 } 346 }
364 347
365 /** 348 /**
366 - * Dispatches a text message straight to the  
367 - * test suite. Useful for status bar displays.  
368 - * @param string $message Message to show.  
369 - * @access public 349 + * @deprecated
370 */ 350 */
371 function sendMessage($message) { 351 function sendMessage($message) {
372 $this->_reporter->PaintMessage($message); 352 $this->_reporter->PaintMessage($message);
@@ -390,7 +370,7 @@ @@ -390,7 +370,7 @@
390 * @package SimpleTest 370 * @package SimpleTest
391 * @subpackage UnitTester 371 * @subpackage UnitTester
392 */ 372 */
393 - class GroupTest { 373 + class TestSuite {
394 var $_label; 374 var $_label;
395 var $_test_cases; 375 var $_test_cases;
396 var $_old_track_errors; 376 var $_old_track_errors;
@@ -402,7 +382,7 @@ @@ -402,7 +382,7 @@
402 * of the test. 382 * of the test.
403 * @access public 383 * @access public
404 */ 384 */
405 - function GroupTest($label = false) { 385 + function TestSuite($label = false) {
406 $this->_label = $label ? $label : get_class($this); 386 $this->_label = $label ? $label : get_class($this);
407 $this->_test_cases = array(); 387 $this->_test_cases = array();
408 $this->_old_track_errors = ini_get('track_errors'); 388 $this->_old_track_errors = ini_get('track_errors');
@@ -440,7 +420,7 @@ @@ -440,7 +420,7 @@
440 * @access public 420 * @access public
441 */ 421 */
442 function addTestClass($class) { 422 function addTestClass($class) {
443 - if ($this->_getBaseTestCase($class) == 'grouptest') { 423 + if ($this->_getBaseTestCase($class) == 'testsuite' || $this->_getBaseTestCase($class) == 'grouptest') {
444 $this->_test_cases[] = &new $class(); 424 $this->_test_cases[] = &new $class();
445 } else { 425 } else {
446 $this->_test_cases[] = $class; 426 $this->_test_cases[] = $class;
@@ -457,12 +437,12 @@ @@ -457,12 +437,12 @@
457 function addTestFile($test_file) { 437 function addTestFile($test_file) {
458 $existing_classes = get_declared_classes(); 438 $existing_classes = get_declared_classes();
459 if ($error = $this->_requireWithError($test_file)) { 439 if ($error = $this->_requireWithError($test_file)) {
460 - $this->addTestCase(new BadGroupTest($test_file, $error)); 440 + $this->addTestCase(new BadTestSuite($test_file, $error));
461 return; 441 return;
462 } 442 }
463 $classes = $this->_selectRunnableTests($existing_classes, get_declared_classes()); 443 $classes = $this->_selectRunnableTests($existing_classes, get_declared_classes());
464 if (count($classes) == 0) { 444 if (count($classes) == 0) {
465 - $this->addTestCase(new BadGroupTest($test_file, "No runnable test cases in [$test_file]")); 445 + $this->addTestCase(new BadTestSuite($test_file, "No runnable test cases in [$test_file]"));
466 return; 446 return;
467 } 447 }
468 $group = &$this->_createGroupFromClasses($test_file, $classes); 448 $group = &$this->_createGroupFromClasses($test_file, $classes);
@@ -482,11 +462,14 @@ @@ -482,11 +462,14 @@
482 $error = isset($php_errormsg) ? $php_errormsg : false; 462 $error = isset($php_errormsg) ? $php_errormsg : false;
483 $this->_disableErrorReporting(); 463 $this->_disableErrorReporting();
484 $self_inflicted_errors = array( 464 $self_inflicted_errors = array(
485 - 'Assigning the return value of new by reference is deprecated',  
486 - 'var: Deprecated. Please use the public/private/protected modifiers');  
487 - if (in_array($error, $self_inflicted_errors)) {  
488 - return false;  
489 - } 465 + '/Assigning the return value of new by reference/i',
  466 + '/var: Deprecated/i',
  467 + '/Non-static method/i');
  468 + foreach ($self_inflicted_errors as $pattern) {
  469 + if (preg_match($pattern, $error)) {
  470 + return false;
  471 + }
  472 + }
490 return $error; 473 return $error;
491 } 474 }
492 475
@@ -548,13 +531,13 @@ @@ -548,13 +531,13 @@
548 * Builds a group test from a class list. 531 * Builds a group test from a class list.
549 * @param string $title Title of new group. 532 * @param string $title Title of new group.
550 * @param array $classes Test classes. 533 * @param array $classes Test classes.
551 - * @return GroupTest Group loaded with the new 534 + * @return TestSuite Group loaded with the new
552 * test cases. 535 * test cases.
553 * @access private 536 * @access private
554 */ 537 */
555 function &_createGroupFromClasses($title, $classes) { 538 function &_createGroupFromClasses($title, $classes) {
556 SimpleTest::ignoreParentsIfIgnored($classes); 539 SimpleTest::ignoreParentsIfIgnored($classes);
557 - $group = &new GroupTest($title); 540 + $group = &new TestSuite($title);
558 foreach ($classes as $class) { 541 foreach ($classes as $class) {
559 if (! SimpleTest::isIgnored($class)) { 542 if (! SimpleTest::isIgnored($class)) {
560 $group->addTestClass($class); 543 $group->addTestClass($class);
@@ -572,7 +555,7 @@ @@ -572,7 +555,7 @@
572 function _getBaseTestCase($class) { 555 function _getBaseTestCase($class) {
573 while ($class = get_parent_class($class)) { 556 while ($class = get_parent_class($class)) {
574 $class = strtolower($class); 557 $class = strtolower($class);
575 - if ($class == "simpletestcase" || $class == "grouptest") { 558 + if ($class == 'simpletestcase' || $class == 'testsuite' || $class == 'grouptest') {
576 return $class; 559 return $class;
577 } 560 }
578 } 561 }
@@ -603,6 +586,7 @@ @@ -603,6 +586,7 @@
603 $class = $this->_test_cases[$i]; 586 $class = $this->_test_cases[$i];
604 $test = &new $class(); 587 $test = &new $class();
605 $test->run($reporter); 588 $test->run($reporter);
  589 + unset($test);
606 } else { 590 } else {
607 $this->_test_cases[$i]->run($reporter); 591 $this->_test_cases[$i]->run($reporter);
608 } 592 }
@@ -628,6 +612,11 @@ @@ -628,6 +612,11 @@
628 return $count; 612 return $count;
629 } 613 }
630 } 614 }
  615 +
  616 + /**
  617 + * @deprecated
  618 + */
  619 + class GroupTest extends TestSuite { }
631 620
632 /** 621 /**
633 * This is a failing group test for when a test suite hasn't 622 * This is a failing group test for when a test suite hasn't
@@ -635,7 +624,7 @@ @@ -635,7 +624,7 @@
635 * @package SimpleTest 624 * @package SimpleTest
636 * @subpackage UnitTester 625 * @subpackage UnitTester
637 */ 626 */
638 - class BadGroupTest { 627 + class BadTestSuite {
639 var $_label; 628 var $_label;
640 var $_error; 629 var $_error;
641 630
@@ -645,7 +634,7 @@ @@ -645,7 +634,7 @@
645 * of the test. 634 * of the test.
646 * @access public 635 * @access public
647 */ 636 */
648 - function BadGroupTest($label, $error) { 637 + function BadTestSuite($label, $error) {
649 $this->_label = $label; 638 $this->_label = $label;
650 $this->_error = $error; 639 $this->_error = $error;
651 } 640 }
@@ -666,7 +655,7 @@ @@ -666,7 +655,7 @@
666 */ 655 */
667 function run(&$reporter) { 656 function run(&$reporter) {
668 $reporter->paintGroupStart($this->getLabel(), $this->getSize()); 657 $reporter->paintGroupStart($this->getLabel(), $this->getSize());
669 - $reporter->paintFail('Bad GroupTest [' . $this->getLabel() . 658 + $reporter->paintFail('Bad TestSuite [' . $this->getLabel() .
670 '] with error [' . $this->_error . ']'); 659 '] with error [' . $this->_error . ']');
671 $reporter->paintGroupEnd($this->getLabel()); 660 $reporter->paintGroupEnd($this->getLabel());
672 return $reporter->getStatus(); 661 return $reporter->getStatus();
@@ -681,4 +670,9 @@ @@ -681,4 +670,9 @@
681 return 0; 670 return 0;
682 } 671 }
683 } 672 }
684 -?> 673 +
  674 + /**
  675 + * @deprecated
  676 + */
  677 + class BadGroupTest extends BadTestSuite { }
  678 +?>
685 \ No newline at end of file 679 \ No newline at end of file
thirdparty/simpletest/simpletest/unit_tester.php
@@ -37,17 +37,44 @@ @@ -37,17 +37,44 @@
37 } 37 }
38 38
39 /** 39 /**
  40 + * Called from within the test methods to register
  41 + * passes and failures.
  42 + * @param boolean $result Pass on true.
  43 + * @param string $message Message to display describing
  44 + * the test state.
  45 + * @return boolean True on pass
  46 + * @access public
  47 + */
  48 + function assertTrue($result, $message = false) {
  49 + return $this->assert(new TrueExpectation(), $result, $message);
  50 + }
  51 +
  52 + /**
  53 + * Will be true on false and vice versa. False
  54 + * is the PHP definition of false, so that null,
  55 + * empty strings, zero and an empty array all count
  56 + * as false.
  57 + * @param boolean $result Pass on false.
  58 + * @param string $message Message to display.
  59 + * @return boolean True on pass
  60 + * @access public
  61 + */
  62 + function assertFalse($result, $message = '%s') {
  63 + return $this->assert(new FalseExpectation(), $result, $message);
  64 + }
  65 +
  66 + /**
40 * Will be true if the value is null. 67 * Will be true if the value is null.
41 * @param null $value Supposedly null value. 68 * @param null $value Supposedly null value.
42 * @param string $message Message to display. 69 * @param string $message Message to display.
43 * @return boolean True on pass 70 * @return boolean True on pass
44 * @access public 71 * @access public
45 */ 72 */
46 - function assertNull($value, $message = "%s") { 73 + function assertNull($value, $message = '%s') {
47 $dumper = &new SimpleDumper(); 74 $dumper = &new SimpleDumper();
48 $message = sprintf( 75 $message = sprintf(
49 $message, 76 $message,
50 - "[" . $dumper->describeValue($value) . "] should be null"); 77 + '[' . $dumper->describeValue($value) . '] should be null');
51 return $this->assertTrue(! isset($value), $message); 78 return $this->assertTrue(! isset($value), $message);
52 } 79 }
53 80
@@ -58,11 +85,11 @@ @@ -58,11 +85,11 @@
58 * @return boolean True on pass. 85 * @return boolean True on pass.
59 * @access public 86 * @access public
60 */ 87 */
61 - function assertNotNull($value, $message = "%s") { 88 + function assertNotNull($value, $message = '%s') {
62 $dumper = &new SimpleDumper(); 89 $dumper = &new SimpleDumper();
63 $message = sprintf( 90 $message = sprintf(
64 $message, 91 $message,
65 - "[" . $dumper->describeValue($value) . "] should not be null"); 92 + '[' . $dumper->describeValue($value) . '] should not be null');
66 return $this->assertTrue(isset($value), $message); 93 return $this->assertTrue(isset($value), $message);
67 } 94 }
68 95
@@ -76,7 +103,7 @@ @@ -76,7 +103,7 @@
76 * @return boolean True on pass. 103 * @return boolean True on pass.
77 * @access public 104 * @access public
78 */ 105 */
79 - function assertIsA($object, $type, $message = "%s") { 106 + function assertIsA($object, $type, $message = '%s') {
80 return $this->assert( 107 return $this->assert(
81 new IsAExpectation($type), 108 new IsAExpectation($type),
82 $object, 109 $object,
@@ -93,7 +120,7 @@ @@ -93,7 +120,7 @@
93 * @return boolean True on pass. 120 * @return boolean True on pass.
94 * @access public 121 * @access public
95 */ 122 */
96 - function assertNotA($object, $type, $message = "%s") { 123 + function assertNotA($object, $type, $message = '%s') {
97 return $this->assert( 124 return $this->assert(
98 new NotAExpectation($type), 125 new NotAExpectation($type),
99 $object, 126 $object,
@@ -109,7 +136,7 @@ @@ -109,7 +136,7 @@
109 * @return boolean True on pass 136 * @return boolean True on pass
110 * @access public 137 * @access public
111 */ 138 */
112 - function assertEqual($first, $second, $message = "%s") { 139 + function assertEqual($first, $second, $message = '%s') {
113 return $this->assert( 140 return $this->assert(
114 new EqualExpectation($first), 141 new EqualExpectation($first),
115 $second, 142 $second,
@@ -125,7 +152,7 @@ @@ -125,7 +152,7 @@
125 * @return boolean True on pass 152 * @return boolean True on pass
126 * @access public 153 * @access public
127 */ 154 */
128 - function assertNotEqual($first, $second, $message = "%s") { 155 + function assertNotEqual($first, $second, $message = '%s') {
129 return $this->assert( 156 return $this->assert(
130 new NotEqualExpectation($first), 157 new NotEqualExpectation($first),
131 $second, 158 $second,
@@ -142,7 +169,7 @@ @@ -142,7 +169,7 @@
142 * @return boolean True on pass 169 * @return boolean True on pass
143 * @access public 170 * @access public
144 */ 171 */
145 - function assertWithinMargin($first, $second, $margin, $message = "%s") { 172 + function assertWithinMargin($first, $second, $margin, $message = '%s') {
146 return $this->assert( 173 return $this->assert(
147 new WithinMarginExpectation($first, $margin), 174 new WithinMarginExpectation($first, $margin),
148 $second, 175 $second,
@@ -159,7 +186,7 @@ @@ -159,7 +186,7 @@
159 * @return boolean True on pass 186 * @return boolean True on pass
160 * @access public 187 * @access public
161 */ 188 */
162 - function assertOutsideMargin($first, $second, $margin, $message = "%s") { 189 + function assertOutsideMargin($first, $second, $margin, $message = '%s') {
163 return $this->assert( 190 return $this->assert(
164 new OutsideMarginExpectation($first, $margin), 191 new OutsideMarginExpectation($first, $margin),
165 $second, 192 $second,
@@ -175,7 +202,7 @@ @@ -175,7 +202,7 @@
175 * @return boolean True on pass 202 * @return boolean True on pass
176 * @access public 203 * @access public
177 */ 204 */
178 - function assertIdentical($first, $second, $message = "%s") { 205 + function assertIdentical($first, $second, $message = '%s') {
179 return $this->assert( 206 return $this->assert(
180 new IdenticalExpectation($first), 207 new IdenticalExpectation($first),
181 $second, 208 $second,
@@ -191,7 +218,7 @@ @@ -191,7 +218,7 @@
191 * @return boolean True on pass 218 * @return boolean True on pass
192 * @access public 219 * @access public
193 */ 220 */
194 - function assertNotIdentical($first, $second, $message = "%s") { 221 + function assertNotIdentical($first, $second, $message = '%s') {
195 return $this->assert( 222 return $this->assert(
196 new NotIdenticalExpectation($first), 223 new NotIdenticalExpectation($first),
197 $second, 224 $second,
@@ -207,13 +234,13 @@ @@ -207,13 +234,13 @@
207 * @return boolean True on pass 234 * @return boolean True on pass
208 * @access public 235 * @access public
209 */ 236 */
210 - function assertReference(&$first, &$second, $message = "%s") { 237 + function assertReference(&$first, &$second, $message = '%s') {
211 $dumper = &new SimpleDumper(); 238 $dumper = &new SimpleDumper();
212 $message = sprintf( 239 $message = sprintf(
213 $message, 240 $message,
214 - "[" . $dumper->describeValue($first) .  
215 - "] and [" . $dumper->describeValue($second) .  
216 - "] should reference the same object"); 241 + '[' . $dumper->describeValue($first) .
  242 + '] and [' . $dumper->describeValue($second) .
  243 + '] should reference the same object');
217 return $this->assertTrue( 244 return $this->assertTrue(
218 SimpleTestCompatibility::isReference($first, $second), 245 SimpleTestCompatibility::isReference($first, $second),
219 $message); 246 $message);
@@ -229,13 +256,13 @@ @@ -229,13 +256,13 @@
229 * @return boolean True on pass 256 * @return boolean True on pass
230 * @access public 257 * @access public
231 */ 258 */
232 - function assertClone(&$first, &$second, $message = "%s") { 259 + function assertClone(&$first, &$second, $message = '%s') {
233 $dumper = &new SimpleDumper(); 260 $dumper = &new SimpleDumper();
234 $message = sprintf( 261 $message = sprintf(
235 $message, 262 $message,
236 - "[" . $dumper->describeValue($first) .  
237 - "] and [" . $dumper->describeValue($second) .  
238 - "] should not be the same object"); 263 + '[' . $dumper->describeValue($first) .
  264 + '] and [' . $dumper->describeValue($second) .
  265 + '] should not be the same object');
239 $identical = &new IdenticalExpectation($first); 266 $identical = &new IdenticalExpectation($first);
240 return $this->assertTrue( 267 return $this->assertTrue(
241 $identical->test($second) && 268 $identical->test($second) &&
@@ -268,7 +295,7 @@ @@ -268,7 +295,7 @@
268 * @return boolean True on pass 295 * @return boolean True on pass
269 * @access public 296 * @access public
270 */ 297 */
271 - function assertPattern($pattern, $subject, $message = "%s") { 298 + function assertPattern($pattern, $subject, $message = '%s') {
272 return $this->assert( 299 return $this->assert(
273 new PatternExpectation($pattern), 300 new PatternExpectation($pattern),
274 $subject, 301 $subject,
@@ -278,7 +305,7 @@ @@ -278,7 +305,7 @@
278 /** 305 /**
279 * @deprecated 306 * @deprecated
280 */ 307 */
281 - function assertWantedPattern($pattern, $subject, $message = "%s") { 308 + function assertWantedPattern($pattern, $subject, $message = '%s') {
282 return $this->assertPattern($pattern, $subject, $message); 309 return $this->assertPattern($pattern, $subject, $message);
283 } 310 }
284 311
@@ -292,7 +319,7 @@ @@ -292,7 +319,7 @@
292 * @return boolean True on pass 319 * @return boolean True on pass
293 * @access public 320 * @access public
294 */ 321 */
295 - function assertNoPattern($pattern, $subject, $message = "%s") { 322 + function assertNoPattern($pattern, $subject, $message = '%s') {
296 return $this->assert( 323 return $this->assert(
297 new NoPatternExpectation($pattern), 324 new NoPatternExpectation($pattern),
298 $subject, 325 $subject,
@@ -302,50 +329,63 @@ @@ -302,50 +329,63 @@
302 /** 329 /**
303 * @deprecated 330 * @deprecated
304 */ 331 */
305 - function assertNoUnwantedPattern($pattern, $subject, $message = "%s") { 332 + function assertNoUnwantedPattern($pattern, $subject, $message = '%s') {
306 return $this->assertNoPattern($pattern, $subject, $message); 333 return $this->assertNoPattern($pattern, $subject, $message);
307 } 334 }
308 335
309 /** 336 /**
310 - * Confirms that no errors have occoured so  
311 - * far in the test method.  
312 - * @param string $message Message to display.  
313 - * @return boolean True on pass 337 + * @deprecated
  338 + */
  339 + function swallowErrors() {
  340 + $context = &SimpleTest::getContext();
  341 + $queue = &$context->get('SimpleErrorQueue');
  342 + $queue->clear();
  343 + }
  344 +
  345 + /**
  346 + * @deprecated
  347 + */
  348 + function assertNoErrors($message = '%s') {
  349 + $context = &SimpleTest::getContext();
  350 + $queue = &$context->get('SimpleErrorQueue');
  351 + return $queue->assertNoErrors($message);
  352 + }
  353 +
  354 + /**
  355 + * @deprecated
  356 + */
  357 + function assertError($expected = false, $message = '%s') {
  358 + $context = &SimpleTest::getContext();
  359 + $queue = &$context->get('SimpleErrorQueue');
  360 + return $queue->assertError($this->_coerceExpectation($expected), $message);
  361 + }
  362 +
  363 + /**
  364 + * Prepares for an error. If the error mismatches it
  365 + * passes through, otherwise it is swallowed. Any
  366 + * left over errors trigger failures.
  367 + * @param SimpleExpectation/string $expected The error to match.
  368 + * @param string $message Message on failure.
314 * @access public 369 * @access public
315 */ 370 */
316 - function assertNoErrors($message = "%s") {  
317 - $queue = &SimpleErrorQueue::instance();  
318 - return $this->assertTrue(  
319 - $queue->isEmpty(),  
320 - sprintf($message, "Should be no errors")); 371 + function expectError($expected = false, $message = '%s') {
  372 + $context = &SimpleTest::getContext();
  373 + $queue = &$context->get('SimpleErrorQueue');
  374 + $queue->expectError($this->_coerceExpectation($expected), $message);
321 } 375 }
322 376
323 /** 377 /**
324 - * Confirms that an error has occoured and  
325 - * optionally that the error text matches exactly.  
326 - * @param string $expected Expected error text or  
327 - * false for no check.  
328 - * @param string $message Message to display.  
329 - * @return boolean True on pass 378 + * Prepares for an exception. If the error mismatches it
  379 + * passes through, otherwise it is swallowed. Any
  380 + * left over errors trigger failures.
  381 + * @param SimpleExpectation/Exception $expected The error to match.
  382 + * @param string $message Message on failure.
330 * @access public 383 * @access public
331 */ 384 */
332 - function assertError($expected = false, $message = "%s") {  
333 - $queue = &SimpleErrorQueue::instance();  
334 - if ($queue->isEmpty()) {  
335 - $this->fail(sprintf($message, "Expected error not found"));  
336 - return;  
337 - }  
338 - list($severity, $content, $file, $line, $globals) = $queue->extract();  
339 - $severity = SimpleErrorQueue::getSeverityAsString($severity);  
340 - if (! $expected) {  
341 - return $this->pass(  
342 - "Captured a PHP error of [$content] severity [$severity] in [$file] line [$line] -> %s");  
343 - }  
344 - $expected = $this->_coerceToExpectation($expected);  
345 - return $this->assert(  
346 - $expected,  
347 - $content,  
348 - "Expected PHP error [$content] severity [$severity] in [$file] line [$line] -> %s"); 385 + function expectException($expected = false, $message = '%s') {
  386 + $context = &SimpleTest::getContext();
  387 + $queue = &$context->get('SimpleExceptionTrap');
  388 + $queue->expectException($expected, $message . $this->getAssertionLine());
349 } 389 }
350 390
351 /** 391 /**
@@ -356,18 +396,24 @@ @@ -356,18 +396,24 @@
356 * @return SimpleExpectation Expectation object. 396 * @return SimpleExpectation Expectation object.
357 * @access private 397 * @access private
358 */ 398 */
359 - function _coerceToExpectation($expected) { 399 + function _coerceExpectation($expected) {
  400 + if ($expected == false) {
  401 + return new AnythingExpectation();
  402 + }
360 if (SimpleTestCompatibility::isA($expected, 'SimpleExpectation')) { 403 if (SimpleTestCompatibility::isA($expected, 'SimpleExpectation')) {
361 return $expected; 404 return $expected;
362 } 405 }
  406 + if(is_string($expected)) {
  407 + $expected = str_replace('%', '%%', $expected);
  408 + }
363 return new EqualExpectation($expected); 409 return new EqualExpectation($expected);
364 } 410 }
365 411
366 /** 412 /**
367 * @deprecated 413 * @deprecated
368 */ 414 */
369 - function assertErrorPattern($pattern, $message = "%s") { 415 + function assertErrorPattern($pattern, $message = '%s') {
370 return $this->assertError(new PatternExpectation($pattern), $message); 416 return $this->assertError(new PatternExpectation($pattern), $message);
371 } 417 }
372 } 418 }
373 -?> 419 -?>
  420 +?>
374 \ No newline at end of file 421 \ No newline at end of file
thirdparty/simpletest/simpletest/url.php
@@ -507,8 +507,8 @@ @@ -507,8 +507,8 @@
507 * @access public 507 * @access public
508 */ 508 */
509 function normalisePath($path) { 509 function normalisePath($path) {
510 - $path = preg_replace('|/[^/]+/\.\./|', '/', $path);  
511 - return preg_replace('|/\./|', '/', $path); 510 + $path = preg_replace('|/\./|', '/', $path);
  511 + return preg_replace('|/[^/]+/\.\./|', '/', $path);
512 } 512 }
513 513
514 /** 514 /**
thirdparty/simpletest/simpletest/web_tester.php
@@ -120,8 +120,8 @@ @@ -120,8 +120,8 @@
120 } else { 120 } else {
121 return "Field expectation [" . $dumper->describeValue($this->_value) . 121 return "Field expectation [" . $dumper->describeValue($this->_value) .
122 "] fails with [" . 122 "] fails with [" .
123 - $this->_dumper->describeValue($compare) . "] " .  
124 - $this->_dumper->describeDifference($this->_value, $compare); 123 + $dumper->describeValue($compare) . "] " .
  124 + $dumper->describeDifference($this->_value, $compare);
125 } 125 }
126 } 126 }
127 } 127 }
@@ -242,7 +242,7 @@ @@ -242,7 +242,7 @@
242 */ 242 */
243 function testMessage($compare) { 243 function testMessage($compare) {
244 if (SimpleExpectation::isExpectation($this->_expected_value)) { 244 if (SimpleExpectation::isExpectation($this->_expected_value)) {
245 - $message = $this->_expected_value->testMessage($compare); 245 + $message = $this->_expected_value->overlayMessage($compare, $this->_getDumper());
246 } else { 246 } else {
247 $message = $this->_expected_header . 247 $message = $this->_expected_header .
248 ($this->_expected_value ? ': ' . $this->_expected_value : ''); 248 ($this->_expected_value ? ': ' . $this->_expected_value : '');
@@ -784,7 +784,7 @@ @@ -784,7 +784,7 @@
784 * @param string $expiry Expiry date. 784 * @param string $expiry Expiry date.
785 * @access public 785 * @access public
786 */ 786 */
787 - function setCookie($name, $value, $host = false, $path = "/", $expiry = false) { 787 + function setCookie($name, $value, $host = false, $path = '/', $expiry = false) {
788 $this->_browser->setCookie($name, $value, $host, $path, $expiry); 788 $this->_browser->setCookie($name, $value, $host, $path, $expiry);
789 } 789 }
790 790
@@ -841,6 +841,18 @@ @@ -841,6 +841,18 @@
841 } 841 }
842 842
843 /** 843 /**
  844 + * Checks for a click target.
  845 + * @param string $label Visible text or alt text.
  846 + * @return boolean True if click target.
  847 + * @access public
  848 + */
  849 + function assertClickable($label, $message = '%s') {
  850 + return $this->assertTrue(
  851 + $this->_browser->isClickable($label),
  852 + sprintf($message, "Click target [$label] should exist"));
  853 + }
  854 +
  855 + /**
844 * Clicks the submit button by label. The owning 856 * Clicks the submit button by label. The owning
845 * form will be submitted by this. 857 * form will be submitted by this.
846 * @param string $label Button label. An unlabeled 858 * @param string $label Button label. An unlabeled
@@ -881,6 +893,18 @@ @@ -881,6 +893,18 @@
881 } 893 }
882 894
883 /** 895 /**
  896 + * Checks for a valid button label.
  897 + * @param string $label Visible text.
  898 + * @return boolean True if click target.
  899 + * @access public
  900 + */
  901 + function assertSubmit($label, $message = '%s') {
  902 + return $this->assertTrue(
  903 + $this->_browser->isSubmit($label),
  904 + sprintf($message, "Submit button [$label] should exist"));
  905 + }
  906 +
  907 + /**
884 * Clicks the submit image by some kind of label. Usually 908 * Clicks the submit image by some kind of label. Usually
885 * the alt tag or the nearest equivalent. The owning 909 * the alt tag or the nearest equivalent. The owning
886 * form will be submitted by this. Clicking outside of 910 * form will be submitted by this. Clicking outside of
@@ -934,6 +958,18 @@ @@ -934,6 +958,18 @@
934 } 958 }
935 959
936 /** 960 /**
  961 + * Checks for a valid image with atht alt text or title.
  962 + * @param string $label Visible text.
  963 + * @return boolean True if click target.
  964 + * @access public
  965 + */
  966 + function assertImage($label, $message = '%s') {
  967 + return $this->assertTrue(
  968 + $this->_browser->isImage($label),
  969 + sprintf($message, "Image with text [$label] should exist"));
  970 + }
  971 +
  972 + /**
937 * Submits a form by the ID. 973 * Submits a form by the ID.
938 * @param string $id Form ID. No button information 974 * @param string $id Form ID. No button information
939 * is submitted this way. 975 * is submitted this way.
@@ -969,52 +1005,24 @@ @@ -969,52 +1005,24 @@
969 } 1005 }
970 1006
971 /** 1007 /**
972 - * Will trigger a pass if the two parameters have  
973 - * the same value only. Otherwise a fail. This  
974 - * is for testing hand extracted text, etc.  
975 - * @param mixed $first Value to compare.  
976 - * @param mixed $second Value to compare.  
977 - * @param string $message Message to display.  
978 - * @return boolean True on pass  
979 - * @access public  
980 - */  
981 - function assertEqual($first, $second, $message = "%s") {  
982 - return $this->assert(  
983 - new EqualExpectation($first),  
984 - $second,  
985 - $message);  
986 - }  
987 -  
988 - /**  
989 - * Will trigger a pass if the two parameters have  
990 - * a different value. Otherwise a fail. This  
991 - * is for testing hand extracted text, etc.  
992 - * @param mixed $first Value to compare.  
993 - * @param mixed $second Value to compare.  
994 - * @param string $message Message to display.  
995 - * @return boolean True on pass  
996 - * @access public  
997 - */  
998 - function assertNotEqual($first, $second, $message = "%s") {  
999 - return $this->assert(  
1000 - new NotEqualExpectation($first),  
1001 - $second,  
1002 - $message);  
1003 - }  
1004 -  
1005 - /**  
1006 * Tests for the presence of a link label. Match is 1008 * Tests for the presence of a link label. Match is
1007 * case insensitive with normalised space. 1009 * case insensitive with normalised space.
1008 * @param string $label Text between the anchor tags. 1010 * @param string $label Text between the anchor tags.
  1011 + * @param mixed $expected Expected URL or expectation object.
1009 * @param string $message Message to display. Default 1012 * @param string $message Message to display. Default
1010 * can be embedded with %s. 1013 * can be embedded with %s.
1011 * @return boolean True if link present. 1014 * @return boolean True if link present.
1012 * @access public 1015 * @access public
1013 */ 1016 */
1014 - function assertLink($label, $message = "%s") {  
1015 - return $this->assertTrue(  
1016 - $this->_browser->isLink($label),  
1017 - sprintf($message, "Link [$label] should exist")); 1017 + function assertLink($label, $expected = true, $message = '%s') {
  1018 + $url = $this->_browser->getLink($label);
  1019 + if ($expected === true) {
  1020 + return $this->assertTrue($url !== false, sprintf($message, "Link [$label] should exist"));
  1021 + }
  1022 + if (! SimpleExpectation::isExpectation($expected)) {
  1023 + $expected = new IdenticalExpectation($expected);
  1024 + }
  1025 + return $this->assert($expected, $url->asString(), sprintf($message, "Link [$label] should match"));
1018 } 1026 }
1019 1027
1020 /** 1028 /**
@@ -1027,24 +1035,30 @@ @@ -1027,24 +1035,30 @@
1027 * @return boolean True if link missing. 1035 * @return boolean True if link missing.
1028 * @access public 1036 * @access public
1029 */ 1037 */
1030 - function assertNoLink($label, $message = "%s") {  
1031 - return $this->assertFalse(  
1032 - $this->_browser->isLink($label), 1038 + function assertNoLink($label, $message = '%s') {
  1039 + return $this->assertTrue(
  1040 + $this->_browser->getLink($label) === false,
1033 sprintf($message, "Link [$label] should not exist")); 1041 sprintf($message, "Link [$label] should not exist"));
1034 } 1042 }
1035 1043
1036 /** 1044 /**
1037 * Tests for the presence of a link id attribute. 1045 * Tests for the presence of a link id attribute.
1038 * @param string $id Id attribute value. 1046 * @param string $id Id attribute value.
  1047 + * @param mixed $expected Expected URL or expectation object.
1039 * @param string $message Message to display. Default 1048 * @param string $message Message to display. Default
1040 * can be embedded with %s. 1049 * can be embedded with %s.
1041 * @return boolean True if link present. 1050 * @return boolean True if link present.
1042 * @access public 1051 * @access public
1043 */ 1052 */
1044 - function assertLinkById($id, $message = "%s") {  
1045 - return $this->assertTrue(  
1046 - $this->_browser->isLinkById($id),  
1047 - sprintf($message, "Link ID [$id] should exist")); 1053 + function assertLinkById($id, $expected = true, $message = '%s') {
  1054 + $url = $this->_browser->getLinkById($id);
  1055 + if ($expected === true) {
  1056 + return $this->assertTrue($url !== false, sprintf($message, "Link ID [$id] should exist"));
  1057 + }
  1058 + if (! SimpleExpectation::isExpectation($expected)) {
  1059 + $expected = new IdenticalExpectation($expected);
  1060 + }
  1061 + return $this->assert($expected, $url->asString(), sprintf($message, "Link ID [$id] should match"));
1048 } 1062 }
1049 1063
1050 /** 1064 /**
@@ -1056,9 +1070,9 @@ @@ -1056,9 +1070,9 @@
1056 * @return boolean True if link missing. 1070 * @return boolean True if link missing.
1057 * @access public 1071 * @access public
1058 */ 1072 */
1059 - function assertNoLinkById($id, $message = "%s") {  
1060 - return $this->assertFalse(  
1061 - $this->_browser->isLinkById($id), 1073 + function assertNoLinkById($id, $message = '%s') {
  1074 + return $this->assertTrue(
  1075 + $this->_browser->getLinkById($id) === false,
1062 sprintf($message, "Link ID [$id] should not exist")); 1076 sprintf($message, "Link ID [$id] should not exist"));
1063 } 1077 }
1064 1078
@@ -1313,9 +1327,9 @@ @@ -1313,9 +1327,9 @@
1313 1327
1314 /** 1328 /**
1315 * Tests the text between the title tags. 1329 * Tests the text between the title tags.
1316 - * @param string $title Expected title.  
1317 - * @param string $message Message to display.  
1318 - * @return boolean True if pass. 1330 + * @param string/SimpleExpectation $title Expected title.
  1331 + * @param string $message Message to display.
  1332 + * @return boolean True if pass.
1319 * @access public 1333 * @access public
1320 */ 1334 */
1321 function assertTitle($title = false, $message = '%s') { 1335 function assertTitle($title = false, $message = '%s') {
@@ -1451,5 +1465,77 @@ @@ -1451,5 +1465,77 @@
1451 $this->getCookie($name) === false, 1465 $this->getCookie($name) === false,
1452 sprintf($message, "Not expecting cookie [$name]")); 1466 sprintf($message, "Not expecting cookie [$name]"));
1453 } 1467 }
  1468 +
  1469 + /**
  1470 + * Called from within the test methods to register
  1471 + * passes and failures.
  1472 + * @param boolean $result Pass on true.
  1473 + * @param string $message Message to display describing
  1474 + * the test state.
  1475 + * @return boolean True on pass
  1476 + * @access public
  1477 + */
  1478 + function assertTrue($result, $message = false) {
  1479 + return $this->assert(new TrueExpectation(), $result, $message);
  1480 + }
  1481 +
  1482 + /**
  1483 + * Will be true on false and vice versa. False
  1484 + * is the PHP definition of false, so that null,
  1485 + * empty strings, zero and an empty array all count
  1486 + * as false.
  1487 + * @param boolean $result Pass on false.
  1488 + * @param string $message Message to display.
  1489 + * @return boolean True on pass
  1490 + * @access public
  1491 + */
  1492 + function assertFalse($result, $message = '%s') {
  1493 + return $this->assert(new FalseExpectation(), $result, $message);
  1494 + }
  1495 +
  1496 + /**
  1497 + * Will trigger a pass if the two parameters have
  1498 + * the same value only. Otherwise a fail. This
  1499 + * is for testing hand extracted text, etc.
  1500 + * @param mixed $first Value to compare.
  1501 + * @param mixed $second Value to compare.
  1502 + * @param string $message Message to display.
  1503 + * @return boolean True on pass
  1504 + * @access public
  1505 + */
  1506 + function assertEqual($first, $second, $message = '%s') {
  1507 + return $this->assert(
  1508 + new EqualExpectation($first),
  1509 + $second,
  1510 + $message);
  1511 + }
  1512 +
  1513 + /**
  1514 + * Will trigger a pass if the two parameters have
  1515 + * a different value. Otherwise a fail. This
  1516 + * is for testing hand extracted text, etc.
  1517 + * @param mixed $first Value to compare.
  1518 + * @param mixed $second Value to compare.
  1519 + * @param string $message Message to display.
  1520 + * @return boolean True on pass
  1521 + * @access public
  1522 + */
  1523 + function assertNotEqual($first, $second, $message = '%s') {
  1524 + return $this->assert(
  1525 + new NotEqualExpectation($first),
  1526 + $second,
  1527 + $message);
  1528 + }
  1529 +
  1530 + /**
  1531 + * Uses a stack trace to find the line of an assertion.
  1532 + * @return string Line number of first assert*
  1533 + * method embedded in format string.
  1534 + * @access public
  1535 + */
  1536 + function getAssertionLine() {
  1537 + $trace = new SimpleStackTrace(array('assert', 'click', 'pass', 'fail'));
  1538 + return $trace->traceMethod();
  1539 + }
1454 } 1540 }
1455 ?> 1541 ?>
1456 \ No newline at end of file 1542 \ No newline at end of file
thirdparty/simpletest/simpletest/xml.php
@@ -23,7 +23,9 @@ @@ -23,7 +23,9 @@
23 var $_namespace; 23 var $_namespace;
24 24
25 /** 25 /**
26 - * Does nothing yet. 26 + * Sets up indentation and namespace.
  27 + * @param string $namespace Namespace to add to each tag.
  28 + * @param string $indent Indenting to add on each nesting.
27 * @access public 29 * @access public
28 */ 30 */
29 function XmlReporter($namespace = false, $indent = ' ') { 31 function XmlReporter($namespace = false, $indent = ' ') {
@@ -140,8 +142,8 @@ @@ -140,8 +142,8 @@
140 } 142 }
141 143
142 /** 144 /**
143 - * Increments the pass count.  
144 - * @param string $message Message is ignored. 145 + * Paints pass as XML.
  146 + * @param string $message Message to encode.
145 * @access public 147 * @access public
146 */ 148 */
147 function paintPass($message) { 149 function paintPass($message) {
@@ -153,8 +155,8 @@ @@ -153,8 +155,8 @@
153 } 155 }
154 156
155 /** 157 /**
156 - * Increments the fail count.  
157 - * @param string $message Message is ignored. 158 + * Paints failure as XML.
  159 + * @param string $message Message to encode.
158 * @access public 160 * @access public
159 */ 161 */
160 function paintFail($message) { 162 function paintFail($message) {
@@ -166,10 +168,9 @@ @@ -166,10 +168,9 @@
166 } 168 }
167 169
168 /** 170 /**
169 - * Paints a PHP error or exception.  
170 - * @param string $message Message is ignored. 171 + * Paints error as XML.
  172 + * @param string $message Message to encode.
171 * @access public 173 * @access public
172 - * @abstract  
173 */ 174 */
174 function paintError($message) { 175 function paintError($message) {
175 parent::paintError($message); 176 parent::paintError($message);
@@ -180,6 +181,36 @@ @@ -180,6 +181,36 @@
180 } 181 }
181 182
182 /** 183 /**
  184 + * Paints exception as XML.
  185 + * @param Exception $exception Exception to encode.
  186 + * @access public
  187 + */
  188 + function paintException($exception) {
  189 + parent::paintException($exception);
  190 + print $this->_getIndent(1);
  191 + print "<" . $this->_namespace . "exception>";
  192 + $message = 'Unexpected exception of type [' . get_class($exception) .
  193 + '] with message ['. $exception->getMessage() .
  194 + '] in ['. $exception->getFile() .
  195 + ' line ' . $exception->getLine() . ']';
  196 + print $this->toParsedXml($message);
  197 + print "</" . $this->_namespace . "exception>\n";
  198 + }
  199 +
  200 + /**
  201 + * Paints the skipping message and tag.
  202 + * @param string $message Text to display in skip tag.
  203 + * @access public
  204 + */
  205 + function paintSkip($message) {
  206 + parent::paintSkip($message);
  207 + print $this->_getIndent(1);
  208 + print "<" . $this->_namespace . "skip>";
  209 + print $this->toParsedXml($message);
  210 + print "</" . $this->_namespace . "skip>\n";
  211 + }
  212 +
  213 + /**
183 * Paints a simple supplementary message. 214 * Paints a simple supplementary message.
184 * @param string $message Text to display. 215 * @param string $message Text to display.
185 * @access public 216 * @access public
@@ -531,7 +562,7 @@ @@ -531,7 +562,7 @@
531 */ 562 */
532 function _isLeaf($tag) { 563 function _isLeaf($tag) {
533 return in_array($tag, array( 564 return in_array($tag, array(
534 - 'NAME', 'PASS', 'FAIL', 'EXCEPTION', 'MESSAGE', 'FORMATTED', 'SIGNAL')); 565 + 'NAME', 'PASS', 'FAIL', 'EXCEPTION', 'SKIP', 'MESSAGE', 'FORMATTED', 'SIGNAL'));
535 } 566 }
536 567
537 /** 568 /**
@@ -578,6 +609,8 @@ @@ -578,6 +609,8 @@
578 $this->_listener->paintFail($this->_content); 609 $this->_listener->paintFail($this->_content);
579 } elseif ($tag == 'EXCEPTION') { 610 } elseif ($tag == 'EXCEPTION') {
580 $this->_listener->paintError($this->_content); 611 $this->_listener->paintError($this->_content);
  612 + } elseif ($tag == 'SKIP') {
  613 + $this->_listener->paintSkip($this->_content);
581 } elseif ($tag == 'SIGNAL') { 614 } elseif ($tag == 'SIGNAL') {
582 $this->_listener->paintSignal( 615 $this->_listener->paintSignal(
583 $this->_attributes['TYPE'], 616 $this->_attributes['TYPE'],