@@ -16,7 +16,7 @@ |
||
16 | 16 | date_default_timezone_set('UTC'); |
17 | 17 | |
18 | 18 | if (!@include_once VENDOR_DIR.'/autoload.php') { |
19 | - die('You must set up the project dependencies, run the following commands: |
|
19 | + die('You must set up the project dependencies, run the following commands: |
|
20 | 20 | wget http://getcomposer.org/composer.phar |
21 | 21 | php composer.phar install'); |
22 | 22 | } |
@@ -1,366 +1,366 @@ |
||
1 | 1 | <?php |
2 | - /** |
|
3 | - * base include file for SimpleTest |
|
4 | - * @package SimpleTest |
|
5 | - * @subpackage UnitTester |
|
6 | - * @version $Id: reporter.php 1532 2006-12-01 12:28:55Z xue $ |
|
7 | - */ |
|
2 | + /** |
|
3 | + * base include file for SimpleTest |
|
4 | + * @package SimpleTest |
|
5 | + * @subpackage UnitTester |
|
6 | + * @version $Id: reporter.php 1532 2006-12-01 12:28:55Z xue $ |
|
7 | + */ |
|
8 | 8 | |
9 | - /**#@+ |
|
9 | + /**#@+ |
|
10 | 10 | * include other SimpleTest class files |
11 | 11 | */ |
12 | - require_once(dirname(__FILE__) . '/scorer.php'); |
|
13 | - /**#@-*/ |
|
12 | + require_once(dirname(__FILE__) . '/scorer.php'); |
|
13 | + /**#@-*/ |
|
14 | 14 | |
15 | - /** |
|
16 | - * Sample minimal test displayer. Generates only |
|
17 | - * failure messages and a pass count. |
|
15 | + /** |
|
16 | + * Sample minimal test displayer. Generates only |
|
17 | + * failure messages and a pass count. |
|
18 | 18 | * @package SimpleTest |
19 | 19 | * @subpackage UnitTester |
20 | - */ |
|
21 | - class HtmlReporter extends SimpleReporter { |
|
22 | - protected $_character_set; |
|
20 | + */ |
|
21 | + class HtmlReporter extends SimpleReporter { |
|
22 | + protected $_character_set; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Does nothing yet. The first output will |
|
26 | - * be sent on the first test start. For use |
|
27 | - * by a web browser. |
|
28 | - * @access public |
|
29 | - */ |
|
30 | - function HtmlReporter($character_set = 'ISO-8859-1') { |
|
31 | - $this->SimpleReporter(); |
|
32 | - $this->_character_set = $character_set; |
|
33 | - } |
|
24 | + /** |
|
25 | + * Does nothing yet. The first output will |
|
26 | + * be sent on the first test start. For use |
|
27 | + * by a web browser. |
|
28 | + * @access public |
|
29 | + */ |
|
30 | + function HtmlReporter($character_set = 'ISO-8859-1') { |
|
31 | + $this->SimpleReporter(); |
|
32 | + $this->_character_set = $character_set; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Paints the top of the web page setting the |
|
37 | - * title to the name of the starting test. |
|
38 | - * @param string $test_name Name class of test. |
|
39 | - * @access public |
|
40 | - */ |
|
41 | - function paintHeader($test_name) { |
|
42 | - $this->sendNoCacheHeaders(); |
|
43 | - print "<html>\n<head>\n<title>$test_name</title>\n"; |
|
44 | - print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . |
|
45 | - $this->_character_set . "\">\n"; |
|
46 | - print "<style type=\"text/css\">\n"; |
|
47 | - print $this->_getCss() . "\n"; |
|
48 | - print "</style>\n"; |
|
49 | - print "</head>\n<body>\n"; |
|
50 | - print "<h1>$test_name</h1>\n"; |
|
51 | - flush(); |
|
52 | - } |
|
35 | + /** |
|
36 | + * Paints the top of the web page setting the |
|
37 | + * title to the name of the starting test. |
|
38 | + * @param string $test_name Name class of test. |
|
39 | + * @access public |
|
40 | + */ |
|
41 | + function paintHeader($test_name) { |
|
42 | + $this->sendNoCacheHeaders(); |
|
43 | + print "<html>\n<head>\n<title>$test_name</title>\n"; |
|
44 | + print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . |
|
45 | + $this->_character_set . "\">\n"; |
|
46 | + print "<style type=\"text/css\">\n"; |
|
47 | + print $this->_getCss() . "\n"; |
|
48 | + print "</style>\n"; |
|
49 | + print "</head>\n<body>\n"; |
|
50 | + print "<h1>$test_name</h1>\n"; |
|
51 | + flush(); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Send the headers necessary to ensure the page is |
|
56 | - * reloaded on every request. Otherwise you could be |
|
57 | - * scratching your head over out of date test data. |
|
58 | - * @access public |
|
59 | - * @static |
|
60 | - */ |
|
61 | - static function sendNoCacheHeaders() { |
|
62 | - if (! headers_sent()) { |
|
63 | - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
|
64 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
65 | - header("Cache-Control: no-store, no-cache, must-revalidate"); |
|
66 | - header("Cache-Control: post-check=0, pre-check=0", false); |
|
67 | - header("Pragma: no-cache"); |
|
68 | - } |
|
69 | - } |
|
54 | + /** |
|
55 | + * Send the headers necessary to ensure the page is |
|
56 | + * reloaded on every request. Otherwise you could be |
|
57 | + * scratching your head over out of date test data. |
|
58 | + * @access public |
|
59 | + * @static |
|
60 | + */ |
|
61 | + static function sendNoCacheHeaders() { |
|
62 | + if (! headers_sent()) { |
|
63 | + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
|
64 | + header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
65 | + header("Cache-Control: no-store, no-cache, must-revalidate"); |
|
66 | + header("Cache-Control: post-check=0, pre-check=0", false); |
|
67 | + header("Pragma: no-cache"); |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Paints the CSS. Add additional styles here. |
|
73 | - * @return string CSS code as text. |
|
74 | - * @access protected |
|
75 | - */ |
|
76 | - function _getCss() { |
|
77 | - return ".fail { color: red; } pre { background-color: lightgray; }"; |
|
78 | - } |
|
71 | + /** |
|
72 | + * Paints the CSS. Add additional styles here. |
|
73 | + * @return string CSS code as text. |
|
74 | + * @access protected |
|
75 | + */ |
|
76 | + function _getCss() { |
|
77 | + return ".fail { color: red; } pre { background-color: lightgray; }"; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Paints the end of the test with a summary of |
|
82 | - * the passes and failures. |
|
83 | - * @param string $test_name Name class of test. |
|
84 | - * @access public |
|
85 | - */ |
|
86 | - function paintFooter($test_name) { |
|
87 | - $colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green"); |
|
88 | - print "<div style=\""; |
|
89 | - print "padding: 8px; margin-top: 1em; background-color: $colour; color: white;"; |
|
90 | - print "\">"; |
|
91 | - print $this->getTestCaseProgress() . "/" . $this->getTestCaseCount(); |
|
92 | - print " test cases complete:\n"; |
|
93 | - print "<strong>" . $this->getPassCount() . "</strong> passes, "; |
|
94 | - print "<strong>" . $this->getFailCount() . "</strong> fails and "; |
|
95 | - print "<strong>" . $this->getExceptionCount() . "</strong> exceptions."; |
|
96 | - print "</div>\n"; |
|
97 | - print "</body>\n</html>\n"; |
|
98 | - } |
|
80 | + /** |
|
81 | + * Paints the end of the test with a summary of |
|
82 | + * the passes and failures. |
|
83 | + * @param string $test_name Name class of test. |
|
84 | + * @access public |
|
85 | + */ |
|
86 | + function paintFooter($test_name) { |
|
87 | + $colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green"); |
|
88 | + print "<div style=\""; |
|
89 | + print "padding: 8px; margin-top: 1em; background-color: $colour; color: white;"; |
|
90 | + print "\">"; |
|
91 | + print $this->getTestCaseProgress() . "/" . $this->getTestCaseCount(); |
|
92 | + print " test cases complete:\n"; |
|
93 | + print "<strong>" . $this->getPassCount() . "</strong> passes, "; |
|
94 | + print "<strong>" . $this->getFailCount() . "</strong> fails and "; |
|
95 | + print "<strong>" . $this->getExceptionCount() . "</strong> exceptions."; |
|
96 | + print "</div>\n"; |
|
97 | + print "</body>\n</html>\n"; |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * Paints the test failure with a breadcrumbs |
|
102 | - * trail of the nesting test suites below the |
|
103 | - * top level test. |
|
104 | - * @param string $message Failure message displayed in |
|
105 | - * the context of the other tests. |
|
106 | - * @access public |
|
107 | - */ |
|
108 | - function paintFail($message) { |
|
109 | - parent::paintFail($message); |
|
110 | - print "<span class=\"fail\">Fail</span>: "; |
|
111 | - $breadcrumb = $this->getTestList(); |
|
112 | - array_shift($breadcrumb); |
|
113 | - print implode(" -> ", $breadcrumb); |
|
114 | - print " -> " . $this->_htmlEntities($message) . "<br />\n"; |
|
115 | - } |
|
100 | + /** |
|
101 | + * Paints the test failure with a breadcrumbs |
|
102 | + * trail of the nesting test suites below the |
|
103 | + * top level test. |
|
104 | + * @param string $message Failure message displayed in |
|
105 | + * the context of the other tests. |
|
106 | + * @access public |
|
107 | + */ |
|
108 | + function paintFail($message) { |
|
109 | + parent::paintFail($message); |
|
110 | + print "<span class=\"fail\">Fail</span>: "; |
|
111 | + $breadcrumb = $this->getTestList(); |
|
112 | + array_shift($breadcrumb); |
|
113 | + print implode(" -> ", $breadcrumb); |
|
114 | + print " -> " . $this->_htmlEntities($message) . "<br />\n"; |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * Paints a PHP error or exception. |
|
119 | - * @param string $message Message is ignored. |
|
120 | - * @access public |
|
121 | - * @abstract |
|
122 | - */ |
|
123 | - function paintError($message) { |
|
124 | - parent::paintError($message); |
|
125 | - print "<span class=\"fail\">Exception</span>: "; |
|
126 | - $breadcrumb = $this->getTestList(); |
|
127 | - array_shift($breadcrumb); |
|
128 | - print implode(" -> ", $breadcrumb); |
|
129 | - print " -> <strong>" . $this->_htmlEntities($message) . "</strong><br />\n"; |
|
130 | - } |
|
117 | + /** |
|
118 | + * Paints a PHP error or exception. |
|
119 | + * @param string $message Message is ignored. |
|
120 | + * @access public |
|
121 | + * @abstract |
|
122 | + */ |
|
123 | + function paintError($message) { |
|
124 | + parent::paintError($message); |
|
125 | + print "<span class=\"fail\">Exception</span>: "; |
|
126 | + $breadcrumb = $this->getTestList(); |
|
127 | + array_shift($breadcrumb); |
|
128 | + print implode(" -> ", $breadcrumb); |
|
129 | + print " -> <strong>" . $this->_htmlEntities($message) . "</strong><br />\n"; |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * Paints formatted text such as dumped variables. |
|
134 | - * @param string $message Text to show. |
|
135 | - * @access public |
|
136 | - */ |
|
137 | - function paintFormattedMessage($message) { |
|
138 | - print '<pre>' . $this->_htmlEntities($message) . '</pre>'; |
|
139 | - } |
|
132 | + /** |
|
133 | + * Paints formatted text such as dumped variables. |
|
134 | + * @param string $message Text to show. |
|
135 | + * @access public |
|
136 | + */ |
|
137 | + function paintFormattedMessage($message) { |
|
138 | + print '<pre>' . $this->_htmlEntities($message) . '</pre>'; |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * Character set adjusted entity conversion. |
|
143 | - * @param string $message Plain text or Unicode message. |
|
144 | - * @return string Browser readable message. |
|
145 | - * @access protected |
|
146 | - */ |
|
147 | - function _htmlEntities($message) { |
|
148 | - return htmlentities($message, ENT_COMPAT, $this->_character_set); |
|
149 | - } |
|
150 | - } |
|
141 | + /** |
|
142 | + * Character set adjusted entity conversion. |
|
143 | + * @param string $message Plain text or Unicode message. |
|
144 | + * @return string Browser readable message. |
|
145 | + * @access protected |
|
146 | + */ |
|
147 | + function _htmlEntities($message) { |
|
148 | + return htmlentities($message, ENT_COMPAT, $this->_character_set); |
|
149 | + } |
|
150 | + } |
|
151 | 151 | |
152 | - /** |
|
153 | - * Sample minimal test displayer. Generates only |
|
154 | - * failure messages and a pass count. For command |
|
155 | - * line use. I've tried to make it look like JUnit, |
|
156 | - * but I wanted to output the errors as they arrived |
|
157 | - * which meant dropping the dots. |
|
152 | + /** |
|
153 | + * Sample minimal test displayer. Generates only |
|
154 | + * failure messages and a pass count. For command |
|
155 | + * line use. I've tried to make it look like JUnit, |
|
156 | + * but I wanted to output the errors as they arrived |
|
157 | + * which meant dropping the dots. |
|
158 | 158 | * @package SimpleTest |
159 | 159 | * @subpackage UnitTester |
160 | - */ |
|
161 | - class TextReporter extends SimpleReporter { |
|
160 | + */ |
|
161 | + class TextReporter extends SimpleReporter { |
|
162 | 162 | |
163 | - /** |
|
164 | - * Does nothing yet. The first output will |
|
165 | - * be sent on the first test start. |
|
166 | - * @access public |
|
167 | - */ |
|
168 | - function TextReporter() { |
|
169 | - $this->SimpleReporter(); |
|
170 | - } |
|
163 | + /** |
|
164 | + * Does nothing yet. The first output will |
|
165 | + * be sent on the first test start. |
|
166 | + * @access public |
|
167 | + */ |
|
168 | + function TextReporter() { |
|
169 | + $this->SimpleReporter(); |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * Paints the title only. |
|
174 | - * @param string $test_name Name class of test. |
|
175 | - * @access public |
|
176 | - */ |
|
177 | - function paintHeader($test_name) { |
|
178 | - if (! SimpleReporter::inCli()) { |
|
179 | - header('Content-type: text/plain'); |
|
180 | - } |
|
181 | - print "$test_name\n"; |
|
182 | - flush(); |
|
183 | - } |
|
172 | + /** |
|
173 | + * Paints the title only. |
|
174 | + * @param string $test_name Name class of test. |
|
175 | + * @access public |
|
176 | + */ |
|
177 | + function paintHeader($test_name) { |
|
178 | + if (! SimpleReporter::inCli()) { |
|
179 | + header('Content-type: text/plain'); |
|
180 | + } |
|
181 | + print "$test_name\n"; |
|
182 | + flush(); |
|
183 | + } |
|
184 | 184 | |
185 | - /** |
|
186 | - * Paints the end of the test with a summary of |
|
187 | - * the passes and failures. |
|
188 | - * @param string $test_name Name class of test. |
|
189 | - * @access public |
|
190 | - */ |
|
191 | - function paintFooter($test_name) { |
|
192 | - if ($this->getFailCount() + $this->getExceptionCount() == 0) { |
|
193 | - print "OK\n"; |
|
194 | - } else { |
|
195 | - print "FAILURES!!!\n"; |
|
196 | - } |
|
197 | - print "Test cases run: " . $this->getTestCaseProgress() . |
|
198 | - "/" . $this->getTestCaseCount() . |
|
199 | - ", Passes: " . $this->getPassCount() . |
|
200 | - ", Failures: " . $this->getFailCount() . |
|
201 | - ", Exceptions: " . $this->getExceptionCount() . "\n"; |
|
202 | - } |
|
185 | + /** |
|
186 | + * Paints the end of the test with a summary of |
|
187 | + * the passes and failures. |
|
188 | + * @param string $test_name Name class of test. |
|
189 | + * @access public |
|
190 | + */ |
|
191 | + function paintFooter($test_name) { |
|
192 | + if ($this->getFailCount() + $this->getExceptionCount() == 0) { |
|
193 | + print "OK\n"; |
|
194 | + } else { |
|
195 | + print "FAILURES!!!\n"; |
|
196 | + } |
|
197 | + print "Test cases run: " . $this->getTestCaseProgress() . |
|
198 | + "/" . $this->getTestCaseCount() . |
|
199 | + ", Passes: " . $this->getPassCount() . |
|
200 | + ", Failures: " . $this->getFailCount() . |
|
201 | + ", Exceptions: " . $this->getExceptionCount() . "\n"; |
|
202 | + } |
|
203 | 203 | |
204 | - /** |
|
205 | - * Paints the test failure as a stack trace. |
|
206 | - * @param string $message Failure message displayed in |
|
207 | - * the context of the other tests. |
|
208 | - * @access public |
|
209 | - */ |
|
210 | - function paintFail($message) { |
|
211 | - parent::paintFail($message); |
|
212 | - print $this->getFailCount() . ") $message\n"; |
|
213 | - $breadcrumb = $this->getTestList(); |
|
214 | - array_shift($breadcrumb); |
|
215 | - print "\tin " . implode("\n\tin ", array_reverse($breadcrumb)); |
|
216 | - print "\n"; |
|
217 | - } |
|
204 | + /** |
|
205 | + * Paints the test failure as a stack trace. |
|
206 | + * @param string $message Failure message displayed in |
|
207 | + * the context of the other tests. |
|
208 | + * @access public |
|
209 | + */ |
|
210 | + function paintFail($message) { |
|
211 | + parent::paintFail($message); |
|
212 | + print $this->getFailCount() . ") $message\n"; |
|
213 | + $breadcrumb = $this->getTestList(); |
|
214 | + array_shift($breadcrumb); |
|
215 | + print "\tin " . implode("\n\tin ", array_reverse($breadcrumb)); |
|
216 | + print "\n"; |
|
217 | + } |
|
218 | 218 | |
219 | - /** |
|
220 | - * Paints a PHP error or exception. |
|
221 | - * @param string $message Message is ignored. |
|
222 | - * @access public |
|
223 | - * @abstract |
|
224 | - */ |
|
225 | - function paintError($message) { |
|
226 | - parent::paintError($message); |
|
227 | - print "Exception " . $this->getExceptionCount() . "!\n$message\n"; |
|
228 | - } |
|
219 | + /** |
|
220 | + * Paints a PHP error or exception. |
|
221 | + * @param string $message Message is ignored. |
|
222 | + * @access public |
|
223 | + * @abstract |
|
224 | + */ |
|
225 | + function paintError($message) { |
|
226 | + parent::paintError($message); |
|
227 | + print "Exception " . $this->getExceptionCount() . "!\n$message\n"; |
|
228 | + } |
|
229 | 229 | |
230 | - /** |
|
231 | - * Paints formatted text such as dumped variables. |
|
232 | - * @param string $message Text to show. |
|
233 | - * @access public |
|
234 | - */ |
|
235 | - function paintFormattedMessage($message) { |
|
236 | - print "$message\n"; |
|
237 | - flush(); |
|
238 | - } |
|
239 | - } |
|
230 | + /** |
|
231 | + * Paints formatted text such as dumped variables. |
|
232 | + * @param string $message Text to show. |
|
233 | + * @access public |
|
234 | + */ |
|
235 | + function paintFormattedMessage($message) { |
|
236 | + print "$message\n"; |
|
237 | + flush(); |
|
238 | + } |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Runs just a single test group, a single case or |
|
243 | - * even a single test within that case. |
|
241 | + /** |
|
242 | + * Runs just a single test group, a single case or |
|
243 | + * even a single test within that case. |
|
244 | 244 | * @package SimpleTest |
245 | 245 | * @subpackage UnitTester |
246 | - */ |
|
247 | - class SelectiveReporter extends SimpleReporterDecorator { |
|
248 | - protected $_just_this_case =false; |
|
249 | - protected $_just_this_test = false; |
|
250 | - protected $_within_test_case = true; |
|
246 | + */ |
|
247 | + class SelectiveReporter extends SimpleReporterDecorator { |
|
248 | + protected $_just_this_case =false; |
|
249 | + protected $_just_this_test = false; |
|
250 | + protected $_within_test_case = true; |
|
251 | 251 | |
252 | - /** |
|
253 | - * Selects the test case or group to be run, |
|
254 | - * and optionally a specific test. |
|
255 | - * @param SimpleScorer $reporter Reporter to receive events. |
|
256 | - * @param string $just_this_case Only this case or group will run. |
|
257 | - * @param string $just_this_test Only this test method will run. |
|
258 | - */ |
|
259 | - function SelectiveReporter($reporter, $just_this_case = false, $just_this_test = false) { |
|
260 | - if (isset($just_this_case) && $just_this_case) { |
|
261 | - $this->_just_this_case = strtolower($just_this_case); |
|
262 | - $this->_within_test_case = false; |
|
263 | - } |
|
264 | - if (isset($just_this_test) && $just_this_test) { |
|
265 | - $this->_just_this_test = strtolower($just_this_test); |
|
266 | - } |
|
267 | - $this->SimpleReporterDecorator($reporter); |
|
268 | - } |
|
252 | + /** |
|
253 | + * Selects the test case or group to be run, |
|
254 | + * and optionally a specific test. |
|
255 | + * @param SimpleScorer $reporter Reporter to receive events. |
|
256 | + * @param string $just_this_case Only this case or group will run. |
|
257 | + * @param string $just_this_test Only this test method will run. |
|
258 | + */ |
|
259 | + function SelectiveReporter($reporter, $just_this_case = false, $just_this_test = false) { |
|
260 | + if (isset($just_this_case) && $just_this_case) { |
|
261 | + $this->_just_this_case = strtolower($just_this_case); |
|
262 | + $this->_within_test_case = false; |
|
263 | + } |
|
264 | + if (isset($just_this_test) && $just_this_test) { |
|
265 | + $this->_just_this_test = strtolower($just_this_test); |
|
266 | + } |
|
267 | + $this->SimpleReporterDecorator($reporter); |
|
268 | + } |
|
269 | 269 | |
270 | - /** |
|
271 | - * Compares criteria to actual the case/group name. |
|
272 | - * @param string $test_case The incoming test. |
|
273 | - * @return boolean True if matched. |
|
274 | - * @access protected |
|
275 | - */ |
|
276 | - function _isCaseMatch($test_case) { |
|
277 | - if ($this->_just_this_case) { |
|
278 | - return $this->_just_this_case == strtolower($test_case); |
|
279 | - } |
|
280 | - return false; |
|
281 | - } |
|
270 | + /** |
|
271 | + * Compares criteria to actual the case/group name. |
|
272 | + * @param string $test_case The incoming test. |
|
273 | + * @return boolean True if matched. |
|
274 | + * @access protected |
|
275 | + */ |
|
276 | + function _isCaseMatch($test_case) { |
|
277 | + if ($this->_just_this_case) { |
|
278 | + return $this->_just_this_case == strtolower($test_case); |
|
279 | + } |
|
280 | + return false; |
|
281 | + } |
|
282 | 282 | |
283 | - /** |
|
284 | - * Compares criteria to actual the test name. |
|
285 | - * @param string $method The incoming test method. |
|
286 | - * @return boolean True if matched. |
|
287 | - * @access protected |
|
288 | - */ |
|
289 | - function _isTestMatch($method) { |
|
290 | - if ($this->_just_this_test) { |
|
291 | - return $this->_just_this_test == strtolower($method); |
|
292 | - } |
|
293 | - return true; |
|
294 | - } |
|
283 | + /** |
|
284 | + * Compares criteria to actual the test name. |
|
285 | + * @param string $method The incoming test method. |
|
286 | + * @return boolean True if matched. |
|
287 | + * @access protected |
|
288 | + */ |
|
289 | + function _isTestMatch($method) { |
|
290 | + if ($this->_just_this_test) { |
|
291 | + return $this->_just_this_test == strtolower($method); |
|
292 | + } |
|
293 | + return true; |
|
294 | + } |
|
295 | 295 | |
296 | - /** |
|
297 | - * Veto everything that doesn't match the method wanted. |
|
298 | - * @param string $test_case Name of test case. |
|
299 | - * @param string $method Name of test method. |
|
300 | - * @return boolean True if test should be run. |
|
301 | - * @access public |
|
302 | - */ |
|
303 | - function shouldInvoke($test_case, $method) { |
|
304 | - if ($this->_within_test_case && $this->_isTestMatch($method)) { |
|
305 | - return $this->_reporter->shouldInvoke($test_case, $method); |
|
306 | - } |
|
307 | - return false; |
|
308 | - } |
|
296 | + /** |
|
297 | + * Veto everything that doesn't match the method wanted. |
|
298 | + * @param string $test_case Name of test case. |
|
299 | + * @param string $method Name of test method. |
|
300 | + * @return boolean True if test should be run. |
|
301 | + * @access public |
|
302 | + */ |
|
303 | + function shouldInvoke($test_case, $method) { |
|
304 | + if ($this->_within_test_case && $this->_isTestMatch($method)) { |
|
305 | + return $this->_reporter->shouldInvoke($test_case, $method); |
|
306 | + } |
|
307 | + return false; |
|
308 | + } |
|
309 | 309 | |
310 | - /** |
|
311 | - * Paints the start of a group test. |
|
312 | - * @param string $test_case Name of test or other label. |
|
313 | - * @param integer $size Number of test cases starting. |
|
314 | - * @access public |
|
315 | - */ |
|
316 | - function paintGroupStart($test_case, $size) { |
|
317 | - if ($this->_isCaseMatch($test_case)) { |
|
318 | - $this->_within_test_case = true; |
|
319 | - } |
|
320 | - if ($this->_within_test_case) { |
|
321 | - $this->_reporter->paintGroupStart($test_case, $size); |
|
322 | - } |
|
323 | - } |
|
310 | + /** |
|
311 | + * Paints the start of a group test. |
|
312 | + * @param string $test_case Name of test or other label. |
|
313 | + * @param integer $size Number of test cases starting. |
|
314 | + * @access public |
|
315 | + */ |
|
316 | + function paintGroupStart($test_case, $size) { |
|
317 | + if ($this->_isCaseMatch($test_case)) { |
|
318 | + $this->_within_test_case = true; |
|
319 | + } |
|
320 | + if ($this->_within_test_case) { |
|
321 | + $this->_reporter->paintGroupStart($test_case, $size); |
|
322 | + } |
|
323 | + } |
|
324 | 324 | |
325 | - /** |
|
326 | - * Paints the end of a group test. |
|
327 | - * @param string $test_case Name of test or other label. |
|
328 | - * @access public |
|
329 | - */ |
|
330 | - function paintGroupEnd($test_case) { |
|
331 | - if ($this->_within_test_case) { |
|
332 | - $this->_reporter->paintGroupEnd($test_case); |
|
333 | - } |
|
334 | - if ($this->_isCaseMatch($test_case)) { |
|
335 | - $this->_within_test_case = false; |
|
336 | - } |
|
337 | - } |
|
325 | + /** |
|
326 | + * Paints the end of a group test. |
|
327 | + * @param string $test_case Name of test or other label. |
|
328 | + * @access public |
|
329 | + */ |
|
330 | + function paintGroupEnd($test_case) { |
|
331 | + if ($this->_within_test_case) { |
|
332 | + $this->_reporter->paintGroupEnd($test_case); |
|
333 | + } |
|
334 | + if ($this->_isCaseMatch($test_case)) { |
|
335 | + $this->_within_test_case = false; |
|
336 | + } |
|
337 | + } |
|
338 | 338 | |
339 | - /** |
|
340 | - * Paints the start of a test case. |
|
341 | - * @param string $test_case Name of test or other label. |
|
342 | - * @access public |
|
343 | - */ |
|
344 | - function paintCaseStart($test_case) { |
|
345 | - if ($this->_isCaseMatch($test_case)) { |
|
346 | - $this->_within_test_case = true; |
|
347 | - } |
|
348 | - if ($this->_within_test_case) { |
|
349 | - $this->_reporter->paintCaseStart($test_case); |
|
350 | - } |
|
351 | - } |
|
339 | + /** |
|
340 | + * Paints the start of a test case. |
|
341 | + * @param string $test_case Name of test or other label. |
|
342 | + * @access public |
|
343 | + */ |
|
344 | + function paintCaseStart($test_case) { |
|
345 | + if ($this->_isCaseMatch($test_case)) { |
|
346 | + $this->_within_test_case = true; |
|
347 | + } |
|
348 | + if ($this->_within_test_case) { |
|
349 | + $this->_reporter->paintCaseStart($test_case); |
|
350 | + } |
|
351 | + } |
|
352 | 352 | |
353 | - /** |
|
354 | - * Paints the end of a test case. |
|
355 | - * @param string $test_case Name of test or other label. |
|
356 | - * @access public |
|
357 | - */ |
|
358 | - function paintCaseEnd($test_case) { |
|
359 | - if ($this->_within_test_case) { |
|
360 | - $this->_reporter->paintCaseEnd($test_case); |
|
361 | - } |
|
362 | - if ($this->_isCaseMatch($test_case)) { |
|
363 | - $this->_within_test_case = false; |
|
364 | - } |
|
365 | - } |
|
366 | - } |
|
367 | 353 | \ No newline at end of file |
354 | + /** |
|
355 | + * Paints the end of a test case. |
|
356 | + * @param string $test_case Name of test or other label. |
|
357 | + * @access public |
|
358 | + */ |
|
359 | + function paintCaseEnd($test_case) { |
|
360 | + if ($this->_within_test_case) { |
|
361 | + $this->_reporter->paintCaseEnd($test_case); |
|
362 | + } |
|
363 | + if ($this->_isCaseMatch($test_case)) { |
|
364 | + $this->_within_test_case = false; |
|
365 | + } |
|
366 | + } |
|
367 | + } |
|
368 | 368 | \ No newline at end of file |
@@ -1,587 +1,587 @@ |
||
1 | 1 | <?php |
2 | - /** |
|
3 | - * Base include file for SimpleTest |
|
4 | - * @package SimpleTest |
|
5 | - * @subpackage WebTester |
|
6 | - * @version $Id: frames.php 1398 2006-09-08 19:31:03Z xue $ |
|
7 | - */ |
|
8 | - |
|
9 | - /**#@+ |
|
2 | + /** |
|
3 | + * Base include file for SimpleTest |
|
4 | + * @package SimpleTest |
|
5 | + * @subpackage WebTester |
|
6 | + * @version $Id: frames.php 1398 2006-09-08 19:31:03Z xue $ |
|
7 | + */ |
|
8 | + |
|
9 | + /**#@+ |
|
10 | 10 | * include other SimpleTest class files |
11 | 11 | */ |
12 | - require_once(dirname(__FILE__) . '/page.php'); |
|
13 | - require_once(dirname(__FILE__) . '/user_agent.php'); |
|
14 | - /**#@-*/ |
|
15 | - |
|
16 | - /** |
|
17 | - * A composite page. Wraps a frameset page and |
|
18 | - * adds subframes. The original page will be |
|
19 | - * mostly ignored. Implements the SimplePage |
|
20 | - * interface so as to be interchangeable. |
|
12 | + require_once(dirname(__FILE__) . '/page.php'); |
|
13 | + require_once(dirname(__FILE__) . '/user_agent.php'); |
|
14 | + /**#@-*/ |
|
15 | + |
|
16 | + /** |
|
17 | + * A composite page. Wraps a frameset page and |
|
18 | + * adds subframes. The original page will be |
|
19 | + * mostly ignored. Implements the SimplePage |
|
20 | + * interface so as to be interchangeable. |
|
21 | 21 | * @package SimpleTest |
22 | 22 | * @subpackage WebTester |
23 | - */ |
|
24 | - class SimpleFrameset { |
|
25 | - protected $_frameset; |
|
26 | - protected $_frames; |
|
27 | - protected $_focus; |
|
28 | - protected $_names; |
|
29 | - |
|
30 | - /** |
|
31 | - * Stashes the frameset page. Will make use of the |
|
32 | - * browser to fetch the sub frames recursively. |
|
33 | - * @param SimplePage $page Frameset page. |
|
34 | - */ |
|
35 | - function SimpleFrameset($page) { |
|
36 | - $this->_frameset = $page; |
|
37 | - $this->_frames = array(); |
|
38 | - $this->_focus = false; |
|
39 | - $this->_names = array(); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Adds a parsed page to the frameset. |
|
44 | - * @param SimplePage $page Frame page. |
|
45 | - * @param string $name Name of frame in frameset. |
|
46 | - * @access public |
|
47 | - */ |
|
48 | - function addFrame($page, $name = false) { |
|
49 | - $this->_frames[] = $page; |
|
50 | - if ($name) { |
|
51 | - $this->_names[$name] = count($this->_frames) - 1; |
|
52 | - } |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Replaces existing frame with another. If the |
|
57 | - * frame is nested, then the call is passed down |
|
58 | - * one level. |
|
59 | - * @param array $path Path of frame in frameset. |
|
60 | - * @param SimplePage $page Frame source. |
|
61 | - * @access public |
|
62 | - */ |
|
63 | - function setFrame($path, $page) { |
|
64 | - $name = array_shift($path); |
|
65 | - if (isset($this->_names[$name])) { |
|
66 | - $index = $this->_names[$name]; |
|
67 | - } else { |
|
68 | - $index = $name - 1; |
|
69 | - } |
|
70 | - if (count($path) == 0) { |
|
71 | - $this->_frames[$index] = $page; |
|
72 | - return; |
|
73 | - } |
|
74 | - $this->_frames[$index]->setFrame($path, $page); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Accessor for current frame focus. Will be |
|
79 | - * false if no frame has focus. Will have the nested |
|
80 | - * frame focus if any. |
|
81 | - * @return array Labels or indexes of nested frames. |
|
82 | - * @access public |
|
83 | - */ |
|
84 | - function getFrameFocus() { |
|
85 | - if ($this->_focus === false) { |
|
86 | - return array(); |
|
87 | - } |
|
88 | - return array_merge( |
|
89 | - array($this->_getPublicNameFromIndex($this->_focus)), |
|
90 | - $this->_frames[$this->_focus]->getFrameFocus()); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Turns an internal array index into the frames list |
|
95 | - * into a public name, or if none, then a one offset |
|
96 | - * index. |
|
97 | - * @param integer $subject Internal index. |
|
98 | - * @return integer/string Public name. |
|
99 | - * @access private |
|
100 | - */ |
|
101 | - function _getPublicNameFromIndex($subject) { |
|
102 | - foreach ($this->_names as $name => $index) { |
|
103 | - if ($subject == $index) { |
|
104 | - return $name; |
|
105 | - } |
|
106 | - } |
|
107 | - return $subject + 1; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Sets the focus by index. The integer index starts from 1. |
|
112 | - * If already focused and the target frame also has frames, |
|
113 | - * then the nested frame will be focused. |
|
114 | - * @param integer $choice Chosen frame. |
|
115 | - * @return boolean True if frame exists. |
|
116 | - * @access public |
|
117 | - */ |
|
118 | - function setFrameFocusByIndex($choice) { |
|
119 | - if (is_integer($this->_focus)) { |
|
120 | - if ($this->_frames[$this->_focus]->hasFrames()) { |
|
121 | - return $this->_frames[$this->_focus]->setFrameFocusByIndex($choice); |
|
122 | - } |
|
123 | - } |
|
124 | - if (($choice < 1) || ($choice > count($this->_frames))) { |
|
125 | - return false; |
|
126 | - } |
|
127 | - $this->_focus = $choice - 1; |
|
128 | - return true; |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Sets the focus by name. If already focused and the |
|
133 | - * target frame also has frames, then the nested frame |
|
134 | - * will be focused. |
|
135 | - * @param string $name Chosen frame. |
|
136 | - * @return boolean True if frame exists. |
|
137 | - * @access public |
|
138 | - */ |
|
139 | - function setFrameFocus($name) { |
|
140 | - if (is_integer($this->_focus)) { |
|
141 | - if ($this->_frames[$this->_focus]->hasFrames()) { |
|
142 | - return $this->_frames[$this->_focus]->setFrameFocus($name); |
|
143 | - } |
|
144 | - } |
|
145 | - if (in_array($name, array_keys($this->_names))) { |
|
146 | - $this->_focus = $this->_names[$name]; |
|
147 | - return true; |
|
148 | - } |
|
149 | - return false; |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * Clears the frame focus. |
|
154 | - * @access public |
|
155 | - */ |
|
156 | - function clearFrameFocus() { |
|
157 | - $this->_focus = false; |
|
158 | - $this->_clearNestedFramesFocus(); |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * Clears the frame focus for any nested frames. |
|
163 | - * @access private |
|
164 | - */ |
|
165 | - function _clearNestedFramesFocus() { |
|
166 | - for ($i = 0; $i < count($this->_frames); $i++) { |
|
167 | - $this->_frames[$i]->clearFrameFocus(); |
|
168 | - } |
|
169 | - } |
|
170 | - |
|
171 | - /** |
|
172 | - * Test for the presence of a frameset. |
|
173 | - * @return boolean Always true. |
|
174 | - * @access public |
|
175 | - */ |
|
176 | - function hasFrames() { |
|
177 | - return true; |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * Accessor for frames information. |
|
182 | - * @return array/string Recursive hash of frame URL strings. |
|
183 | - * The key is either a numerical |
|
184 | - * index or the name attribute. |
|
185 | - * @access public |
|
186 | - */ |
|
187 | - function getFrames() { |
|
188 | - $report = array(); |
|
189 | - for ($i = 0; $i < count($this->_frames); $i++) { |
|
190 | - $report[$this->_getPublicNameFromIndex($i)] = |
|
191 | - $this->_frames[$i]->getFrames(); |
|
192 | - } |
|
193 | - return $report; |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * Accessor for raw text of either all the pages or |
|
198 | - * the frame in focus. |
|
199 | - * @return string Raw unparsed content. |
|
200 | - * @access public |
|
201 | - */ |
|
202 | - function getRaw() { |
|
203 | - if (is_integer($this->_focus)) { |
|
204 | - return $this->_frames[$this->_focus]->getRaw(); |
|
205 | - } |
|
206 | - $raw = ''; |
|
207 | - for ($i = 0; $i < count($this->_frames); $i++) { |
|
208 | - $raw .= $this->_frames[$i]->getRaw(); |
|
209 | - } |
|
210 | - return $raw; |
|
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * Accessor for plain text of either all the pages or |
|
215 | - * the frame in focus. |
|
216 | - * @return string Plain text content. |
|
217 | - * @access public |
|
218 | - */ |
|
219 | - function getText() { |
|
220 | - if (is_integer($this->_focus)) { |
|
221 | - return $this->_frames[$this->_focus]->getText(); |
|
222 | - } |
|
223 | - $raw = ''; |
|
224 | - for ($i = 0; $i < count($this->_frames); $i++) { |
|
225 | - $raw .= ' ' . $this->_frames[$i]->getText(); |
|
226 | - } |
|
227 | - return trim($raw); |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Accessor for last error. |
|
232 | - * @return string Error from last response. |
|
233 | - * @access public |
|
234 | - */ |
|
235 | - function getTransportError() { |
|
236 | - if (is_integer($this->_focus)) { |
|
237 | - return $this->_frames[$this->_focus]->getTransportError(); |
|
238 | - } |
|
239 | - return $this->_frameset->getTransportError(); |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * Request method used to fetch this frame. |
|
244 | - * @return string GET, POST or HEAD. |
|
245 | - * @access public |
|
246 | - */ |
|
247 | - function getMethod() { |
|
248 | - if (is_integer($this->_focus)) { |
|
249 | - return $this->_frames[$this->_focus]->getMethod(); |
|
250 | - } |
|
251 | - return $this->_frameset->getMethod(); |
|
252 | - } |
|
253 | - |
|
254 | - /** |
|
255 | - * Original resource name. |
|
256 | - * @return SimpleUrl Current url. |
|
257 | - * @access public |
|
258 | - */ |
|
259 | - function getUrl() { |
|
260 | - if (is_integer($this->_focus)) { |
|
261 | - $url = $this->_frames[$this->_focus]->getUrl(); |
|
262 | - $url->setTarget($this->_getPublicNameFromIndex($this->_focus)); |
|
263 | - } else { |
|
264 | - $url = $this->_frameset->getUrl(); |
|
265 | - } |
|
266 | - return $url; |
|
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * Original request data. |
|
271 | - * @return mixed Sent content. |
|
272 | - * @access public |
|
273 | - */ |
|
274 | - function getRequestData() { |
|
275 | - if (is_integer($this->_focus)) { |
|
276 | - return $this->_frames[$this->_focus]->getRequestData(); |
|
277 | - } |
|
278 | - return $this->_frameset->getRequestData(); |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * Accessor for current MIME type. |
|
283 | - * @return string MIME type as string; e.g. 'text/html' |
|
284 | - * @access public |
|
285 | - */ |
|
286 | - function getMimeType() { |
|
287 | - if (is_integer($this->_focus)) { |
|
288 | - return $this->_frames[$this->_focus]->getMimeType(); |
|
289 | - } |
|
290 | - return $this->_frameset->getMimeType(); |
|
291 | - } |
|
292 | - |
|
293 | - /** |
|
294 | - * Accessor for last response code. |
|
295 | - * @return integer Last HTTP response code received. |
|
296 | - * @access public |
|
297 | - */ |
|
298 | - function getResponseCode() { |
|
299 | - if (is_integer($this->_focus)) { |
|
300 | - return $this->_frames[$this->_focus]->getResponseCode(); |
|
301 | - } |
|
302 | - return $this->_frameset->getResponseCode(); |
|
303 | - } |
|
304 | - |
|
305 | - /** |
|
306 | - * Accessor for last Authentication type. Only valid |
|
307 | - * straight after a challenge (401). |
|
308 | - * @return string Description of challenge type. |
|
309 | - * @access public |
|
310 | - */ |
|
311 | - function getAuthentication() { |
|
312 | - if (is_integer($this->_focus)) { |
|
313 | - return $this->_frames[$this->_focus]->getAuthentication(); |
|
314 | - } |
|
315 | - return $this->_frameset->getAuthentication(); |
|
316 | - } |
|
317 | - |
|
318 | - /** |
|
319 | - * Accessor for last Authentication realm. Only valid |
|
320 | - * straight after a challenge (401). |
|
321 | - * @return string Name of security realm. |
|
322 | - * @access public |
|
323 | - */ |
|
324 | - function getRealm() { |
|
325 | - if (is_integer($this->_focus)) { |
|
326 | - return $this->_frames[$this->_focus]->getRealm(); |
|
327 | - } |
|
328 | - return $this->_frameset->getRealm(); |
|
329 | - } |
|
330 | - |
|
331 | - /** |
|
332 | - * Accessor for outgoing header information. |
|
333 | - * @return string Header block. |
|
334 | - * @access public |
|
335 | - */ |
|
336 | - function getRequest() { |
|
337 | - if (is_integer($this->_focus)) { |
|
338 | - return $this->_frames[$this->_focus]->getRequest(); |
|
339 | - } |
|
340 | - return $this->_frameset->getRequest(); |
|
341 | - } |
|
342 | - |
|
343 | - /** |
|
344 | - * Accessor for raw header information. |
|
345 | - * @return string Header block. |
|
346 | - * @access public |
|
347 | - */ |
|
348 | - function getHeaders() { |
|
349 | - if (is_integer($this->_focus)) { |
|
350 | - return $this->_frames[$this->_focus]->getHeaders(); |
|
351 | - } |
|
352 | - return $this->_frameset->getHeaders(); |
|
353 | - } |
|
354 | - |
|
355 | - /** |
|
356 | - * Accessor for parsed title. |
|
357 | - * @return string Title or false if no title is present. |
|
358 | - * @access public |
|
359 | - */ |
|
360 | - function getTitle() { |
|
361 | - return $this->_frameset->getTitle(); |
|
362 | - } |
|
363 | - |
|
364 | - /** |
|
365 | - * Accessor for a list of all fixed links. |
|
366 | - * @return array List of urls with scheme of |
|
367 | - * http or https and hostname. |
|
368 | - * @access public |
|
369 | - */ |
|
370 | - function getAbsoluteUrls() { |
|
371 | - if (is_integer($this->_focus)) { |
|
372 | - return $this->_frames[$this->_focus]->getAbsoluteUrls(); |
|
373 | - } |
|
374 | - $urls = array(); |
|
375 | - foreach ($this->_frames as $frame) { |
|
376 | - $urls = array_merge($urls, $frame->getAbsoluteUrls()); |
|
377 | - } |
|
378 | - return array_values(array_unique($urls)); |
|
379 | - } |
|
380 | - |
|
381 | - /** |
|
382 | - * Accessor for a list of all relative links. |
|
383 | - * @return array List of urls without hostname. |
|
384 | - * @access public |
|
385 | - */ |
|
386 | - function getRelativeUrls() { |
|
387 | - if (is_integer($this->_focus)) { |
|
388 | - return $this->_frames[$this->_focus]->getRelativeUrls(); |
|
389 | - } |
|
390 | - $urls = array(); |
|
391 | - foreach ($this->_frames as $frame) { |
|
392 | - $urls = array_merge($urls, $frame->getRelativeUrls()); |
|
393 | - } |
|
394 | - return array_values(array_unique($urls)); |
|
395 | - } |
|
396 | - |
|
397 | - /** |
|
398 | - * Accessor for URLs by the link label. Label will match |
|
399 | - * regardess of whitespace issues and case. |
|
400 | - * @param string $label Text of link. |
|
401 | - * @return array List of links with that label. |
|
402 | - * @access public |
|
403 | - */ |
|
404 | - function getUrlsByLabel($label) { |
|
405 | - if (is_integer($this->_focus)) { |
|
406 | - return $this->_tagUrlsWithFrame( |
|
407 | - $this->_frames[$this->_focus]->getUrlsByLabel($label), |
|
408 | - $this->_focus); |
|
409 | - } |
|
410 | - $urls = array(); |
|
411 | - foreach ($this->_frames as $index => $frame) { |
|
412 | - $urls = array_merge( |
|
413 | - $urls, |
|
414 | - $this->_tagUrlsWithFrame( |
|
415 | - $frame->getUrlsByLabel($label), |
|
416 | - $index)); |
|
417 | - } |
|
418 | - return $urls; |
|
419 | - } |
|
420 | - |
|
421 | - /** |
|
422 | - * Accessor for a URL by the id attribute. If in a frameset |
|
423 | - * then the first link found with that ID attribute is |
|
424 | - * returned only. Focus on a frame if you want one from |
|
425 | - * a specific part of the frameset. |
|
426 | - * @param string $id Id attribute of link. |
|
427 | - * @return string URL with that id. |
|
428 | - * @access public |
|
429 | - */ |
|
430 | - function getUrlById($id) { |
|
431 | - foreach ($this->_frames as $index => $frame) { |
|
432 | - if ($url = $frame->getUrlById($id)) { |
|
433 | - if (! $url->gettarget()) { |
|
434 | - $url->setTarget($this->_getPublicNameFromIndex($index)); |
|
435 | - } |
|
436 | - return $url; |
|
437 | - } |
|
438 | - } |
|
439 | - return false; |
|
440 | - } |
|
441 | - |
|
442 | - /** |
|
443 | - * Attaches the intended frame index to a list of URLs. |
|
444 | - * @param array $urls List of SimpleUrls. |
|
445 | - * @param string $frame Name of frame or index. |
|
446 | - * @return array List of tagged URLs. |
|
447 | - * @access private |
|
448 | - */ |
|
449 | - function _tagUrlsWithFrame($urls, $frame) { |
|
450 | - $tagged = array(); |
|
451 | - foreach ($urls as $url) { |
|
452 | - if (! $url->getTarget()) { |
|
453 | - $url->setTarget($this->_getPublicNameFromIndex($frame)); |
|
454 | - } |
|
455 | - $tagged[] = $url; |
|
456 | - } |
|
457 | - return $tagged; |
|
458 | - } |
|
459 | - |
|
460 | - /** |
|
461 | - * Finds a held form by button label. Will only |
|
462 | - * search correctly built forms. |
|
463 | - * @param SimpleSelector $selector Button finder. |
|
464 | - * @return SimpleForm Form object containing |
|
465 | - * the button. |
|
466 | - * @access public |
|
467 | - */ |
|
468 | - function &getFormBySubmit($selector) { |
|
469 | - $form = $this->_findForm('getFormBySubmit', $selector); |
|
470 | - return $form; |
|
471 | - } |
|
472 | - |
|
473 | - /** |
|
474 | - * Finds a held form by image using a selector. |
|
475 | - * Will only search correctly built forms. The first |
|
476 | - * form found either within the focused frame, or |
|
477 | - * across frames, will be the one returned. |
|
478 | - * @param SimpleSelector $selector Image finder. |
|
479 | - * @return SimpleForm Form object containing |
|
480 | - * the image. |
|
481 | - * @access public |
|
482 | - */ |
|
483 | - function &getFormByImage($selector) { |
|
484 | - $form = $this->_findForm('getFormByImage', $selector); |
|
485 | - return $form; |
|
486 | - } |
|
487 | - |
|
488 | - /** |
|
489 | - * Finds a held form by the form ID. A way of |
|
490 | - * identifying a specific form when we have control |
|
491 | - * of the HTML code. The first form found |
|
492 | - * either within the focused frame, or across frames, |
|
493 | - * will be the one returned. |
|
494 | - * @param string $id Form label. |
|
495 | - * @return SimpleForm Form object containing the matching ID. |
|
496 | - * @access public |
|
497 | - */ |
|
498 | - function &getFormById($id) { |
|
499 | - $form = $this->_findForm('getFormById', $id); |
|
500 | - return $form; |
|
501 | - } |
|
502 | - |
|
503 | - /** |
|
504 | - * General form finder. Will search all the frames or |
|
505 | - * just the one in focus. |
|
506 | - * @param string $method Method to use to find in a page. |
|
507 | - * @param string $attribute Label, name or ID. |
|
508 | - * @return SimpleForm Form object containing the matching ID. |
|
509 | - * @access private |
|
510 | - */ |
|
511 | - function &_findForm($method, $attribute) { |
|
512 | - if (is_integer($this->_focus)) { |
|
513 | - $form = $this->_findFormInFrame( |
|
514 | - $this->_frames[$this->_focus], |
|
515 | - $this->_focus, |
|
516 | - $method, |
|
517 | - $attribute); |
|
518 | - return $form; |
|
519 | - } |
|
520 | - for ($i = 0; $i < count($this->_frames); $i++) { |
|
521 | - $form = $this->_findFormInFrame( |
|
522 | - $this->_frames[$i], |
|
523 | - $i, |
|
524 | - $method, |
|
525 | - $attribute); |
|
526 | - if ($form) { |
|
527 | - return $form; |
|
528 | - } |
|
529 | - } |
|
530 | - $null = null; |
|
531 | - return $null; |
|
532 | - } |
|
533 | - |
|
534 | - /** |
|
535 | - * Finds a form in a page using a form finding method. Will |
|
536 | - * also tag the form with the frame name it belongs in. |
|
537 | - * @param SimplePage $page Page content of frame. |
|
538 | - * @param integer $index Internal frame representation. |
|
539 | - * @param string $method Method to use to find in a page. |
|
540 | - * @param string $attribute Label, name or ID. |
|
541 | - * @return SimpleForm Form object containing the matching ID. |
|
542 | - * @access private |
|
543 | - */ |
|
544 | - function &_findFormInFrame($page, $index, $method, $attribute) { |
|
545 | - $form = $this->_frames[$index]->$method($attribute); |
|
546 | - if (isset($form)) { |
|
547 | - $form->setDefaultTarget($this->_getPublicNameFromIndex($index)); |
|
548 | - } |
|
549 | - return $form; |
|
550 | - } |
|
551 | - |
|
552 | - /** |
|
553 | - * Sets a field on each form in which the field is |
|
554 | - * available. |
|
555 | - * @param SimpleSelector $selector Field finder. |
|
556 | - * @param string $value Value to set field to. |
|
557 | - * @return boolean True if value is valid. |
|
558 | - * @access public |
|
559 | - */ |
|
560 | - function setField($selector, $value) { |
|
561 | - if (is_integer($this->_focus)) { |
|
562 | - $this->_frames[$this->_focus]->setField($selector, $value); |
|
563 | - } else { |
|
564 | - for ($i = 0; $i < count($this->_frames); $i++) { |
|
565 | - $this->_frames[$i]->setField($selector, $value); |
|
566 | - } |
|
567 | - } |
|
568 | - } |
|
569 | - |
|
570 | - /** |
|
571 | - * Accessor for a form element value within a page. |
|
572 | - * @param SimpleSelector $selector Field finder. |
|
573 | - * @return string/boolean A string if the field is |
|
574 | - * present, false if unchecked |
|
575 | - * and null if missing. |
|
576 | - * @access public |
|
577 | - */ |
|
578 | - function getField($selector) { |
|
579 | - for ($i = 0; $i < count($this->_frames); $i++) { |
|
580 | - $value = $this->_frames[$i]->getField($selector); |
|
581 | - if (isset($value)) { |
|
582 | - return $value; |
|
583 | - } |
|
584 | - } |
|
585 | - return null; |
|
586 | - } |
|
587 | - } |
|
588 | 23 | \ No newline at end of file |
24 | + */ |
|
25 | + class SimpleFrameset { |
|
26 | + protected $_frameset; |
|
27 | + protected $_frames; |
|
28 | + protected $_focus; |
|
29 | + protected $_names; |
|
30 | + |
|
31 | + /** |
|
32 | + * Stashes the frameset page. Will make use of the |
|
33 | + * browser to fetch the sub frames recursively. |
|
34 | + * @param SimplePage $page Frameset page. |
|
35 | + */ |
|
36 | + function SimpleFrameset($page) { |
|
37 | + $this->_frameset = $page; |
|
38 | + $this->_frames = array(); |
|
39 | + $this->_focus = false; |
|
40 | + $this->_names = array(); |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * Adds a parsed page to the frameset. |
|
45 | + * @param SimplePage $page Frame page. |
|
46 | + * @param string $name Name of frame in frameset. |
|
47 | + * @access public |
|
48 | + */ |
|
49 | + function addFrame($page, $name = false) { |
|
50 | + $this->_frames[] = $page; |
|
51 | + if ($name) { |
|
52 | + $this->_names[$name] = count($this->_frames) - 1; |
|
53 | + } |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * Replaces existing frame with another. If the |
|
58 | + * frame is nested, then the call is passed down |
|
59 | + * one level. |
|
60 | + * @param array $path Path of frame in frameset. |
|
61 | + * @param SimplePage $page Frame source. |
|
62 | + * @access public |
|
63 | + */ |
|
64 | + function setFrame($path, $page) { |
|
65 | + $name = array_shift($path); |
|
66 | + if (isset($this->_names[$name])) { |
|
67 | + $index = $this->_names[$name]; |
|
68 | + } else { |
|
69 | + $index = $name - 1; |
|
70 | + } |
|
71 | + if (count($path) == 0) { |
|
72 | + $this->_frames[$index] = $page; |
|
73 | + return; |
|
74 | + } |
|
75 | + $this->_frames[$index]->setFrame($path, $page); |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Accessor for current frame focus. Will be |
|
80 | + * false if no frame has focus. Will have the nested |
|
81 | + * frame focus if any. |
|
82 | + * @return array Labels or indexes of nested frames. |
|
83 | + * @access public |
|
84 | + */ |
|
85 | + function getFrameFocus() { |
|
86 | + if ($this->_focus === false) { |
|
87 | + return array(); |
|
88 | + } |
|
89 | + return array_merge( |
|
90 | + array($this->_getPublicNameFromIndex($this->_focus)), |
|
91 | + $this->_frames[$this->_focus]->getFrameFocus()); |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Turns an internal array index into the frames list |
|
96 | + * into a public name, or if none, then a one offset |
|
97 | + * index. |
|
98 | + * @param integer $subject Internal index. |
|
99 | + * @return integer/string Public name. |
|
100 | + * @access private |
|
101 | + */ |
|
102 | + function _getPublicNameFromIndex($subject) { |
|
103 | + foreach ($this->_names as $name => $index) { |
|
104 | + if ($subject == $index) { |
|
105 | + return $name; |
|
106 | + } |
|
107 | + } |
|
108 | + return $subject + 1; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Sets the focus by index. The integer index starts from 1. |
|
113 | + * If already focused and the target frame also has frames, |
|
114 | + * then the nested frame will be focused. |
|
115 | + * @param integer $choice Chosen frame. |
|
116 | + * @return boolean True if frame exists. |
|
117 | + * @access public |
|
118 | + */ |
|
119 | + function setFrameFocusByIndex($choice) { |
|
120 | + if (is_integer($this->_focus)) { |
|
121 | + if ($this->_frames[$this->_focus]->hasFrames()) { |
|
122 | + return $this->_frames[$this->_focus]->setFrameFocusByIndex($choice); |
|
123 | + } |
|
124 | + } |
|
125 | + if (($choice < 1) || ($choice > count($this->_frames))) { |
|
126 | + return false; |
|
127 | + } |
|
128 | + $this->_focus = $choice - 1; |
|
129 | + return true; |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * Sets the focus by name. If already focused and the |
|
134 | + * target frame also has frames, then the nested frame |
|
135 | + * will be focused. |
|
136 | + * @param string $name Chosen frame. |
|
137 | + * @return boolean True if frame exists. |
|
138 | + * @access public |
|
139 | + */ |
|
140 | + function setFrameFocus($name) { |
|
141 | + if (is_integer($this->_focus)) { |
|
142 | + if ($this->_frames[$this->_focus]->hasFrames()) { |
|
143 | + return $this->_frames[$this->_focus]->setFrameFocus($name); |
|
144 | + } |
|
145 | + } |
|
146 | + if (in_array($name, array_keys($this->_names))) { |
|
147 | + $this->_focus = $this->_names[$name]; |
|
148 | + return true; |
|
149 | + } |
|
150 | + return false; |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * Clears the frame focus. |
|
155 | + * @access public |
|
156 | + */ |
|
157 | + function clearFrameFocus() { |
|
158 | + $this->_focus = false; |
|
159 | + $this->_clearNestedFramesFocus(); |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * Clears the frame focus for any nested frames. |
|
164 | + * @access private |
|
165 | + */ |
|
166 | + function _clearNestedFramesFocus() { |
|
167 | + for ($i = 0; $i < count($this->_frames); $i++) { |
|
168 | + $this->_frames[$i]->clearFrameFocus(); |
|
169 | + } |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Test for the presence of a frameset. |
|
174 | + * @return boolean Always true. |
|
175 | + * @access public |
|
176 | + */ |
|
177 | + function hasFrames() { |
|
178 | + return true; |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * Accessor for frames information. |
|
183 | + * @return array/string Recursive hash of frame URL strings. |
|
184 | + * The key is either a numerical |
|
185 | + * index or the name attribute. |
|
186 | + * @access public |
|
187 | + */ |
|
188 | + function getFrames() { |
|
189 | + $report = array(); |
|
190 | + for ($i = 0; $i < count($this->_frames); $i++) { |
|
191 | + $report[$this->_getPublicNameFromIndex($i)] = |
|
192 | + $this->_frames[$i]->getFrames(); |
|
193 | + } |
|
194 | + return $report; |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * Accessor for raw text of either all the pages or |
|
199 | + * the frame in focus. |
|
200 | + * @return string Raw unparsed content. |
|
201 | + * @access public |
|
202 | + */ |
|
203 | + function getRaw() { |
|
204 | + if (is_integer($this->_focus)) { |
|
205 | + return $this->_frames[$this->_focus]->getRaw(); |
|
206 | + } |
|
207 | + $raw = ''; |
|
208 | + for ($i = 0; $i < count($this->_frames); $i++) { |
|
209 | + $raw .= $this->_frames[$i]->getRaw(); |
|
210 | + } |
|
211 | + return $raw; |
|
212 | + } |
|
213 | + |
|
214 | + /** |
|
215 | + * Accessor for plain text of either all the pages or |
|
216 | + * the frame in focus. |
|
217 | + * @return string Plain text content. |
|
218 | + * @access public |
|
219 | + */ |
|
220 | + function getText() { |
|
221 | + if (is_integer($this->_focus)) { |
|
222 | + return $this->_frames[$this->_focus]->getText(); |
|
223 | + } |
|
224 | + $raw = ''; |
|
225 | + for ($i = 0; $i < count($this->_frames); $i++) { |
|
226 | + $raw .= ' ' . $this->_frames[$i]->getText(); |
|
227 | + } |
|
228 | + return trim($raw); |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Accessor for last error. |
|
233 | + * @return string Error from last response. |
|
234 | + * @access public |
|
235 | + */ |
|
236 | + function getTransportError() { |
|
237 | + if (is_integer($this->_focus)) { |
|
238 | + return $this->_frames[$this->_focus]->getTransportError(); |
|
239 | + } |
|
240 | + return $this->_frameset->getTransportError(); |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Request method used to fetch this frame. |
|
245 | + * @return string GET, POST or HEAD. |
|
246 | + * @access public |
|
247 | + */ |
|
248 | + function getMethod() { |
|
249 | + if (is_integer($this->_focus)) { |
|
250 | + return $this->_frames[$this->_focus]->getMethod(); |
|
251 | + } |
|
252 | + return $this->_frameset->getMethod(); |
|
253 | + } |
|
254 | + |
|
255 | + /** |
|
256 | + * Original resource name. |
|
257 | + * @return SimpleUrl Current url. |
|
258 | + * @access public |
|
259 | + */ |
|
260 | + function getUrl() { |
|
261 | + if (is_integer($this->_focus)) { |
|
262 | + $url = $this->_frames[$this->_focus]->getUrl(); |
|
263 | + $url->setTarget($this->_getPublicNameFromIndex($this->_focus)); |
|
264 | + } else { |
|
265 | + $url = $this->_frameset->getUrl(); |
|
266 | + } |
|
267 | + return $url; |
|
268 | + } |
|
269 | + |
|
270 | + /** |
|
271 | + * Original request data. |
|
272 | + * @return mixed Sent content. |
|
273 | + * @access public |
|
274 | + */ |
|
275 | + function getRequestData() { |
|
276 | + if (is_integer($this->_focus)) { |
|
277 | + return $this->_frames[$this->_focus]->getRequestData(); |
|
278 | + } |
|
279 | + return $this->_frameset->getRequestData(); |
|
280 | + } |
|
281 | + |
|
282 | + /** |
|
283 | + * Accessor for current MIME type. |
|
284 | + * @return string MIME type as string; e.g. 'text/html' |
|
285 | + * @access public |
|
286 | + */ |
|
287 | + function getMimeType() { |
|
288 | + if (is_integer($this->_focus)) { |
|
289 | + return $this->_frames[$this->_focus]->getMimeType(); |
|
290 | + } |
|
291 | + return $this->_frameset->getMimeType(); |
|
292 | + } |
|
293 | + |
|
294 | + /** |
|
295 | + * Accessor for last response code. |
|
296 | + * @return integer Last HTTP response code received. |
|
297 | + * @access public |
|
298 | + */ |
|
299 | + function getResponseCode() { |
|
300 | + if (is_integer($this->_focus)) { |
|
301 | + return $this->_frames[$this->_focus]->getResponseCode(); |
|
302 | + } |
|
303 | + return $this->_frameset->getResponseCode(); |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * Accessor for last Authentication type. Only valid |
|
308 | + * straight after a challenge (401). |
|
309 | + * @return string Description of challenge type. |
|
310 | + * @access public |
|
311 | + */ |
|
312 | + function getAuthentication() { |
|
313 | + if (is_integer($this->_focus)) { |
|
314 | + return $this->_frames[$this->_focus]->getAuthentication(); |
|
315 | + } |
|
316 | + return $this->_frameset->getAuthentication(); |
|
317 | + } |
|
318 | + |
|
319 | + /** |
|
320 | + * Accessor for last Authentication realm. Only valid |
|
321 | + * straight after a challenge (401). |
|
322 | + * @return string Name of security realm. |
|
323 | + * @access public |
|
324 | + */ |
|
325 | + function getRealm() { |
|
326 | + if (is_integer($this->_focus)) { |
|
327 | + return $this->_frames[$this->_focus]->getRealm(); |
|
328 | + } |
|
329 | + return $this->_frameset->getRealm(); |
|
330 | + } |
|
331 | + |
|
332 | + /** |
|
333 | + * Accessor for outgoing header information. |
|
334 | + * @return string Header block. |
|
335 | + * @access public |
|
336 | + */ |
|
337 | + function getRequest() { |
|
338 | + if (is_integer($this->_focus)) { |
|
339 | + return $this->_frames[$this->_focus]->getRequest(); |
|
340 | + } |
|
341 | + return $this->_frameset->getRequest(); |
|
342 | + } |
|
343 | + |
|
344 | + /** |
|
345 | + * Accessor for raw header information. |
|
346 | + * @return string Header block. |
|
347 | + * @access public |
|
348 | + */ |
|
349 | + function getHeaders() { |
|
350 | + if (is_integer($this->_focus)) { |
|
351 | + return $this->_frames[$this->_focus]->getHeaders(); |
|
352 | + } |
|
353 | + return $this->_frameset->getHeaders(); |
|
354 | + } |
|
355 | + |
|
356 | + /** |
|
357 | + * Accessor for parsed title. |
|
358 | + * @return string Title or false if no title is present. |
|
359 | + * @access public |
|
360 | + */ |
|
361 | + function getTitle() { |
|
362 | + return $this->_frameset->getTitle(); |
|
363 | + } |
|
364 | + |
|
365 | + /** |
|
366 | + * Accessor for a list of all fixed links. |
|
367 | + * @return array List of urls with scheme of |
|
368 | + * http or https and hostname. |
|
369 | + * @access public |
|
370 | + */ |
|
371 | + function getAbsoluteUrls() { |
|
372 | + if (is_integer($this->_focus)) { |
|
373 | + return $this->_frames[$this->_focus]->getAbsoluteUrls(); |
|
374 | + } |
|
375 | + $urls = array(); |
|
376 | + foreach ($this->_frames as $frame) { |
|
377 | + $urls = array_merge($urls, $frame->getAbsoluteUrls()); |
|
378 | + } |
|
379 | + return array_values(array_unique($urls)); |
|
380 | + } |
|
381 | + |
|
382 | + /** |
|
383 | + * Accessor for a list of all relative links. |
|
384 | + * @return array List of urls without hostname. |
|
385 | + * @access public |
|
386 | + */ |
|
387 | + function getRelativeUrls() { |
|
388 | + if (is_integer($this->_focus)) { |
|
389 | + return $this->_frames[$this->_focus]->getRelativeUrls(); |
|
390 | + } |
|
391 | + $urls = array(); |
|
392 | + foreach ($this->_frames as $frame) { |
|
393 | + $urls = array_merge($urls, $frame->getRelativeUrls()); |
|
394 | + } |
|
395 | + return array_values(array_unique($urls)); |
|
396 | + } |
|
397 | + |
|
398 | + /** |
|
399 | + * Accessor for URLs by the link label. Label will match |
|
400 | + * regardess of whitespace issues and case. |
|
401 | + * @param string $label Text of link. |
|
402 | + * @return array List of links with that label. |
|
403 | + * @access public |
|
404 | + */ |
|
405 | + function getUrlsByLabel($label) { |
|
406 | + if (is_integer($this->_focus)) { |
|
407 | + return $this->_tagUrlsWithFrame( |
|
408 | + $this->_frames[$this->_focus]->getUrlsByLabel($label), |
|
409 | + $this->_focus); |
|
410 | + } |
|
411 | + $urls = array(); |
|
412 | + foreach ($this->_frames as $index => $frame) { |
|
413 | + $urls = array_merge( |
|
414 | + $urls, |
|
415 | + $this->_tagUrlsWithFrame( |
|
416 | + $frame->getUrlsByLabel($label), |
|
417 | + $index)); |
|
418 | + } |
|
419 | + return $urls; |
|
420 | + } |
|
421 | + |
|
422 | + /** |
|
423 | + * Accessor for a URL by the id attribute. If in a frameset |
|
424 | + * then the first link found with that ID attribute is |
|
425 | + * returned only. Focus on a frame if you want one from |
|
426 | + * a specific part of the frameset. |
|
427 | + * @param string $id Id attribute of link. |
|
428 | + * @return string URL with that id. |
|
429 | + * @access public |
|
430 | + */ |
|
431 | + function getUrlById($id) { |
|
432 | + foreach ($this->_frames as $index => $frame) { |
|
433 | + if ($url = $frame->getUrlById($id)) { |
|
434 | + if (! $url->gettarget()) { |
|
435 | + $url->setTarget($this->_getPublicNameFromIndex($index)); |
|
436 | + } |
|
437 | + return $url; |
|
438 | + } |
|
439 | + } |
|
440 | + return false; |
|
441 | + } |
|
442 | + |
|
443 | + /** |
|
444 | + * Attaches the intended frame index to a list of URLs. |
|
445 | + * @param array $urls List of SimpleUrls. |
|
446 | + * @param string $frame Name of frame or index. |
|
447 | + * @return array List of tagged URLs. |
|
448 | + * @access private |
|
449 | + */ |
|
450 | + function _tagUrlsWithFrame($urls, $frame) { |
|
451 | + $tagged = array(); |
|
452 | + foreach ($urls as $url) { |
|
453 | + if (! $url->getTarget()) { |
|
454 | + $url->setTarget($this->_getPublicNameFromIndex($frame)); |
|
455 | + } |
|
456 | + $tagged[] = $url; |
|
457 | + } |
|
458 | + return $tagged; |
|
459 | + } |
|
460 | + |
|
461 | + /** |
|
462 | + * Finds a held form by button label. Will only |
|
463 | + * search correctly built forms. |
|
464 | + * @param SimpleSelector $selector Button finder. |
|
465 | + * @return SimpleForm Form object containing |
|
466 | + * the button. |
|
467 | + * @access public |
|
468 | + */ |
|
469 | + function &getFormBySubmit($selector) { |
|
470 | + $form = $this->_findForm('getFormBySubmit', $selector); |
|
471 | + return $form; |
|
472 | + } |
|
473 | + |
|
474 | + /** |
|
475 | + * Finds a held form by image using a selector. |
|
476 | + * Will only search correctly built forms. The first |
|
477 | + * form found either within the focused frame, or |
|
478 | + * across frames, will be the one returned. |
|
479 | + * @param SimpleSelector $selector Image finder. |
|
480 | + * @return SimpleForm Form object containing |
|
481 | + * the image. |
|
482 | + * @access public |
|
483 | + */ |
|
484 | + function &getFormByImage($selector) { |
|
485 | + $form = $this->_findForm('getFormByImage', $selector); |
|
486 | + return $form; |
|
487 | + } |
|
488 | + |
|
489 | + /** |
|
490 | + * Finds a held form by the form ID. A way of |
|
491 | + * identifying a specific form when we have control |
|
492 | + * of the HTML code. The first form found |
|
493 | + * either within the focused frame, or across frames, |
|
494 | + * will be the one returned. |
|
495 | + * @param string $id Form label. |
|
496 | + * @return SimpleForm Form object containing the matching ID. |
|
497 | + * @access public |
|
498 | + */ |
|
499 | + function &getFormById($id) { |
|
500 | + $form = $this->_findForm('getFormById', $id); |
|
501 | + return $form; |
|
502 | + } |
|
503 | + |
|
504 | + /** |
|
505 | + * General form finder. Will search all the frames or |
|
506 | + * just the one in focus. |
|
507 | + * @param string $method Method to use to find in a page. |
|
508 | + * @param string $attribute Label, name or ID. |
|
509 | + * @return SimpleForm Form object containing the matching ID. |
|
510 | + * @access private |
|
511 | + */ |
|
512 | + function &_findForm($method, $attribute) { |
|
513 | + if (is_integer($this->_focus)) { |
|
514 | + $form = $this->_findFormInFrame( |
|
515 | + $this->_frames[$this->_focus], |
|
516 | + $this->_focus, |
|
517 | + $method, |
|
518 | + $attribute); |
|
519 | + return $form; |
|
520 | + } |
|
521 | + for ($i = 0; $i < count($this->_frames); $i++) { |
|
522 | + $form = $this->_findFormInFrame( |
|
523 | + $this->_frames[$i], |
|
524 | + $i, |
|
525 | + $method, |
|
526 | + $attribute); |
|
527 | + if ($form) { |
|
528 | + return $form; |
|
529 | + } |
|
530 | + } |
|
531 | + $null = null; |
|
532 | + return $null; |
|
533 | + } |
|
534 | + |
|
535 | + /** |
|
536 | + * Finds a form in a page using a form finding method. Will |
|
537 | + * also tag the form with the frame name it belongs in. |
|
538 | + * @param SimplePage $page Page content of frame. |
|
539 | + * @param integer $index Internal frame representation. |
|
540 | + * @param string $method Method to use to find in a page. |
|
541 | + * @param string $attribute Label, name or ID. |
|
542 | + * @return SimpleForm Form object containing the matching ID. |
|
543 | + * @access private |
|
544 | + */ |
|
545 | + function &_findFormInFrame($page, $index, $method, $attribute) { |
|
546 | + $form = $this->_frames[$index]->$method($attribute); |
|
547 | + if (isset($form)) { |
|
548 | + $form->setDefaultTarget($this->_getPublicNameFromIndex($index)); |
|
549 | + } |
|
550 | + return $form; |
|
551 | + } |
|
552 | + |
|
553 | + /** |
|
554 | + * Sets a field on each form in which the field is |
|
555 | + * available. |
|
556 | + * @param SimpleSelector $selector Field finder. |
|
557 | + * @param string $value Value to set field to. |
|
558 | + * @return boolean True if value is valid. |
|
559 | + * @access public |
|
560 | + */ |
|
561 | + function setField($selector, $value) { |
|
562 | + if (is_integer($this->_focus)) { |
|
563 | + $this->_frames[$this->_focus]->setField($selector, $value); |
|
564 | + } else { |
|
565 | + for ($i = 0; $i < count($this->_frames); $i++) { |
|
566 | + $this->_frames[$i]->setField($selector, $value); |
|
567 | + } |
|
568 | + } |
|
569 | + } |
|
570 | + |
|
571 | + /** |
|
572 | + * Accessor for a form element value within a page. |
|
573 | + * @param SimpleSelector $selector Field finder. |
|
574 | + * @return string/boolean A string if the field is |
|
575 | + * present, false if unchecked |
|
576 | + * and null if missing. |
|
577 | + * @access public |
|
578 | + */ |
|
579 | + function getField($selector) { |
|
580 | + for ($i = 0; $i < count($this->_frames); $i++) { |
|
581 | + $value = $this->_frames[$i]->getField($selector); |
|
582 | + if (isset($value)) { |
|
583 | + return $value; |
|
584 | + } |
|
585 | + } |
|
586 | + return null; |
|
587 | + } |
|
588 | + } |
|
589 | 589 | \ No newline at end of file |
@@ -1,183 +1,183 @@ |
||
1 | 1 | <?php |
2 | - /** |
|
3 | - * base include file for SimpleTest |
|
4 | - * @package SimpleTest |
|
5 | - * @version $Id: compatibility.php 1532 2006-12-01 12:28:55Z xue $ |
|
6 | - */ |
|
2 | + /** |
|
3 | + * base include file for SimpleTest |
|
4 | + * @package SimpleTest |
|
5 | + * @version $Id: compatibility.php 1532 2006-12-01 12:28:55Z xue $ |
|
6 | + */ |
|
7 | 7 | |
8 | - /** |
|
9 | - * Static methods for compatibility between different |
|
10 | - * PHP versions. |
|
11 | - * @package SimpleTest |
|
12 | - */ |
|
13 | - class SimpleTestCompatibility { |
|
8 | + /** |
|
9 | + * Static methods for compatibility between different |
|
10 | + * PHP versions. |
|
11 | + * @package SimpleTest |
|
12 | + */ |
|
13 | + class SimpleTestCompatibility { |
|
14 | 14 | |
15 | - /** |
|
16 | - * Creates a copy whether in PHP5 or PHP4. |
|
17 | - * @param object $object Thing to copy. |
|
18 | - * @return object A copy. |
|
19 | - * @access public |
|
20 | - * @static |
|
21 | - */ |
|
22 | - static function copy($object) { |
|
23 | - if (version_compare(phpversion(), '5') >= 0) { |
|
24 | - eval('$copy = clone $object;'); |
|
25 | - return $copy; |
|
26 | - } |
|
27 | - return $object; |
|
28 | - } |
|
15 | + /** |
|
16 | + * Creates a copy whether in PHP5 or PHP4. |
|
17 | + * @param object $object Thing to copy. |
|
18 | + * @return object A copy. |
|
19 | + * @access public |
|
20 | + * @static |
|
21 | + */ |
|
22 | + static function copy($object) { |
|
23 | + if (version_compare(phpversion(), '5') >= 0) { |
|
24 | + eval('$copy = clone $object;'); |
|
25 | + return $copy; |
|
26 | + } |
|
27 | + return $object; |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Identity test. Drops back to equality + types for PHP5 |
|
32 | - * objects as the === operator counts as the |
|
33 | - * stronger reference constraint. |
|
34 | - * @param mixed $first Test subject. |
|
35 | - * @param mixed $second Comparison object. |
|
36 | - * @return boolean True if identical. |
|
37 | - * @access public |
|
38 | - * @static |
|
39 | - */ |
|
40 | - static function isIdentical($first, $second) { |
|
41 | - if ($first != $second) { |
|
42 | - return false; |
|
43 | - } |
|
44 | - if (version_compare(phpversion(), '5') >= 0) { |
|
45 | - return SimpleTestCompatibility::_isIdenticalType($first, $second); |
|
46 | - } |
|
47 | - return ($first === $second); |
|
48 | - } |
|
30 | + /** |
|
31 | + * Identity test. Drops back to equality + types for PHP5 |
|
32 | + * objects as the === operator counts as the |
|
33 | + * stronger reference constraint. |
|
34 | + * @param mixed $first Test subject. |
|
35 | + * @param mixed $second Comparison object. |
|
36 | + * @return boolean True if identical. |
|
37 | + * @access public |
|
38 | + * @static |
|
39 | + */ |
|
40 | + static function isIdentical($first, $second) { |
|
41 | + if ($first != $second) { |
|
42 | + return false; |
|
43 | + } |
|
44 | + if (version_compare(phpversion(), '5') >= 0) { |
|
45 | + return SimpleTestCompatibility::_isIdenticalType($first, $second); |
|
46 | + } |
|
47 | + return ($first === $second); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Recursive type test. |
|
52 | - * @param mixed $first Test subject. |
|
53 | - * @param mixed $second Comparison object. |
|
54 | - * @return boolean True if same type. |
|
55 | - * @access private |
|
56 | - * @static |
|
57 | - */ |
|
58 | - static function _isIdenticalType($first, $second) { |
|
59 | - if (gettype($first) != gettype($second)) { |
|
60 | - return false; |
|
61 | - } |
|
62 | - if (is_object($first) && is_object($second)) { |
|
63 | - if (get_class($first) != get_class($second)) { |
|
64 | - return false; |
|
65 | - } |
|
66 | - return SimpleTestCompatibility::_isArrayOfIdenticalTypes( |
|
67 | - get_object_vars($first), |
|
68 | - get_object_vars($second)); |
|
69 | - } |
|
70 | - if (is_array($first) && is_array($second)) { |
|
71 | - return SimpleTestCompatibility::_isArrayOfIdenticalTypes($first, $second); |
|
72 | - } |
|
73 | - return true; |
|
74 | - } |
|
50 | + /** |
|
51 | + * Recursive type test. |
|
52 | + * @param mixed $first Test subject. |
|
53 | + * @param mixed $second Comparison object. |
|
54 | + * @return boolean True if same type. |
|
55 | + * @access private |
|
56 | + * @static |
|
57 | + */ |
|
58 | + static function _isIdenticalType($first, $second) { |
|
59 | + if (gettype($first) != gettype($second)) { |
|
60 | + return false; |
|
61 | + } |
|
62 | + if (is_object($first) && is_object($second)) { |
|
63 | + if (get_class($first) != get_class($second)) { |
|
64 | + return false; |
|
65 | + } |
|
66 | + return SimpleTestCompatibility::_isArrayOfIdenticalTypes( |
|
67 | + get_object_vars($first), |
|
68 | + get_object_vars($second)); |
|
69 | + } |
|
70 | + if (is_array($first) && is_array($second)) { |
|
71 | + return SimpleTestCompatibility::_isArrayOfIdenticalTypes($first, $second); |
|
72 | + } |
|
73 | + return true; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Recursive type test for each element of an array. |
|
78 | - * @param mixed $first Test subject. |
|
79 | - * @param mixed $second Comparison object. |
|
80 | - * @return boolean True if identical. |
|
81 | - * @access private |
|
82 | - * @static |
|
83 | - */ |
|
84 | - static function _isArrayOfIdenticalTypes($first, $second) { |
|
85 | - if (array_keys($first) != array_keys($second)) { |
|
86 | - return false; |
|
87 | - } |
|
88 | - foreach (array_keys($first) as $key) { |
|
89 | - $is_identical = SimpleTestCompatibility::_isIdenticalType( |
|
90 | - $first[$key], |
|
91 | - $second[$key]); |
|
92 | - if (! $is_identical) { |
|
93 | - return false; |
|
94 | - } |
|
95 | - } |
|
96 | - return true; |
|
97 | - } |
|
76 | + /** |
|
77 | + * Recursive type test for each element of an array. |
|
78 | + * @param mixed $first Test subject. |
|
79 | + * @param mixed $second Comparison object. |
|
80 | + * @return boolean True if identical. |
|
81 | + * @access private |
|
82 | + * @static |
|
83 | + */ |
|
84 | + static function _isArrayOfIdenticalTypes($first, $second) { |
|
85 | + if (array_keys($first) != array_keys($second)) { |
|
86 | + return false; |
|
87 | + } |
|
88 | + foreach (array_keys($first) as $key) { |
|
89 | + $is_identical = SimpleTestCompatibility::_isIdenticalType( |
|
90 | + $first[$key], |
|
91 | + $second[$key]); |
|
92 | + if (! $is_identical) { |
|
93 | + return false; |
|
94 | + } |
|
95 | + } |
|
96 | + return true; |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * Test for two variables being aliases. |
|
101 | - * @param mixed $first Test subject. |
|
102 | - * @param mixed $second Comparison object. |
|
103 | - * @return boolean True if same. |
|
104 | - * @access public |
|
105 | - * @static |
|
106 | - */ |
|
107 | - static function isReference($first, $second) { |
|
108 | - if (version_compare(phpversion(), '5', '>=') |
|
109 | - && is_object($first)) { |
|
110 | - return ($first === $second); |
|
111 | - } |
|
112 | - if (is_object($first) && is_object($second)) { |
|
113 | - $id = uniqid("test"); |
|
114 | - $first->$id = true; |
|
115 | - $is_ref = isset($second->$id); |
|
116 | - unset($first->$id); |
|
117 | - return $is_ref; |
|
118 | - } |
|
119 | - $temp = $first; |
|
120 | - $first = uniqid("test"); |
|
121 | - $is_ref = ($first === $second); |
|
122 | - $first = $temp; |
|
123 | - return $is_ref; |
|
124 | - } |
|
99 | + /** |
|
100 | + * Test for two variables being aliases. |
|
101 | + * @param mixed $first Test subject. |
|
102 | + * @param mixed $second Comparison object. |
|
103 | + * @return boolean True if same. |
|
104 | + * @access public |
|
105 | + * @static |
|
106 | + */ |
|
107 | + static function isReference($first, $second) { |
|
108 | + if (version_compare(phpversion(), '5', '>=') |
|
109 | + && is_object($first)) { |
|
110 | + return ($first === $second); |
|
111 | + } |
|
112 | + if (is_object($first) && is_object($second)) { |
|
113 | + $id = uniqid("test"); |
|
114 | + $first->$id = true; |
|
115 | + $is_ref = isset($second->$id); |
|
116 | + unset($first->$id); |
|
117 | + return $is_ref; |
|
118 | + } |
|
119 | + $temp = $first; |
|
120 | + $first = uniqid("test"); |
|
121 | + $is_ref = ($first === $second); |
|
122 | + $first = $temp; |
|
123 | + return $is_ref; |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * Test to see if an object is a member of a |
|
128 | - * class hiearchy. |
|
129 | - * @param object $object Object to test. |
|
130 | - * @param string $class Root name of hiearchy. |
|
131 | - * @return boolean True if class in hiearchy. |
|
132 | - * @access public |
|
133 | - * @static |
|
134 | - */ |
|
135 | - static function isA($object, $class) { |
|
136 | - if (version_compare(phpversion(), '5') >= 0) { |
|
137 | - if (! class_exists($class, false)) { |
|
138 | - if (function_exists('interface_exists')) { |
|
139 | - if (! interface_exists($class, false)) { |
|
140 | - return false; |
|
141 | - } |
|
142 | - } |
|
143 | - } |
|
144 | - eval("\$is_a = \$object instanceof $class;"); |
|
145 | - return $is_a; |
|
146 | - } |
|
147 | - if (function_exists('is_a')) { |
|
148 | - return is_a($object, $class); |
|
149 | - } |
|
150 | - return ((strtolower($class) == get_class($object)) |
|
151 | - or (is_subclass_of($object, $class))); |
|
152 | - } |
|
126 | + /** |
|
127 | + * Test to see if an object is a member of a |
|
128 | + * class hiearchy. |
|
129 | + * @param object $object Object to test. |
|
130 | + * @param string $class Root name of hiearchy. |
|
131 | + * @return boolean True if class in hiearchy. |
|
132 | + * @access public |
|
133 | + * @static |
|
134 | + */ |
|
135 | + static function isA($object, $class) { |
|
136 | + if (version_compare(phpversion(), '5') >= 0) { |
|
137 | + if (! class_exists($class, false)) { |
|
138 | + if (function_exists('interface_exists')) { |
|
139 | + if (! interface_exists($class, false)) { |
|
140 | + return false; |
|
141 | + } |
|
142 | + } |
|
143 | + } |
|
144 | + eval("\$is_a = \$object instanceof $class;"); |
|
145 | + return $is_a; |
|
146 | + } |
|
147 | + if (function_exists('is_a')) { |
|
148 | + return is_a($object, $class); |
|
149 | + } |
|
150 | + return ((strtolower($class) == get_class($object)) |
|
151 | + or (is_subclass_of($object, $class))); |
|
152 | + } |
|
153 | 153 | |
154 | - /** |
|
155 | - * Sets a socket timeout for each chunk. |
|
156 | - * @param resource $handle Socket handle. |
|
157 | - * @param integer $timeout Limit in seconds. |
|
158 | - * @access public |
|
159 | - * @static |
|
160 | - */ |
|
161 | - static function setTimeout($handle, $timeout) { |
|
162 | - if (function_exists('stream_set_timeout')) { |
|
163 | - stream_set_timeout($handle, $timeout, 0); |
|
164 | - } elseif (function_exists('socket_set_timeout')) { |
|
165 | - socket_set_timeout($handle, $timeout, 0); |
|
166 | - } elseif (function_exists('set_socket_timeout')) { |
|
167 | - set_socket_timeout($handle, $timeout, 0); |
|
168 | - } |
|
169 | - } |
|
154 | + /** |
|
155 | + * Sets a socket timeout for each chunk. |
|
156 | + * @param resource $handle Socket handle. |
|
157 | + * @param integer $timeout Limit in seconds. |
|
158 | + * @access public |
|
159 | + * @static |
|
160 | + */ |
|
161 | + static function setTimeout($handle, $timeout) { |
|
162 | + if (function_exists('stream_set_timeout')) { |
|
163 | + stream_set_timeout($handle, $timeout, 0); |
|
164 | + } elseif (function_exists('socket_set_timeout')) { |
|
165 | + socket_set_timeout($handle, $timeout, 0); |
|
166 | + } elseif (function_exists('set_socket_timeout')) { |
|
167 | + set_socket_timeout($handle, $timeout, 0); |
|
168 | + } |
|
169 | + } |
|
170 | 170 | |
171 | - /** |
|
172 | - * Gets the current stack trace topmost first. |
|
173 | - * @return array List of stack frames. |
|
174 | - * @access public |
|
175 | - * @static |
|
176 | - */ |
|
177 | - static function getStackTrace() { |
|
178 | - if (function_exists('debug_backtrace')) { |
|
179 | - return array_reverse(debug_backtrace()); |
|
180 | - } |
|
181 | - return array(); |
|
182 | - } |
|
183 | - } |
|
171 | + /** |
|
172 | + * Gets the current stack trace topmost first. |
|
173 | + * @return array List of stack frames. |
|
174 | + * @access public |
|
175 | + * @static |
|
176 | + */ |
|
177 | + static function getStackTrace() { |
|
178 | + if (function_exists('debug_backtrace')) { |
|
179 | + return array_reverse(debug_backtrace()); |
|
180 | + } |
|
181 | + return array(); |
|
182 | + } |
|
183 | + } |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * This file contains the following classes: {@link SimpleCollector}, |
|
4 | - * {@link SimplePatternCollector}. |
|
5 | - * |
|
6 | - * @author Travis Swicegood <[email protected]> |
|
7 | - * @package SimpleTest |
|
8 | - * @subpackage UnitTester |
|
9 | - */ |
|
3 | + * This file contains the following classes: {@link SimpleCollector}, |
|
4 | + * {@link SimplePatternCollector}. |
|
5 | + * |
|
6 | + * @author Travis Swicegood <[email protected]> |
|
7 | + * @package SimpleTest |
|
8 | + * @subpackage UnitTester |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * The basic collector for {@link GroupTest} |
@@ -17,61 +17,61 @@ discard block |
||
17 | 17 | */ |
18 | 18 | class SimpleCollector { |
19 | 19 | |
20 | - /** |
|
21 | - * Strips off any kind of slash at the end so as to normalise the path |
|
22 | - * |
|
23 | - * @param string $path Path to normalise. |
|
24 | - */ |
|
25 | - function _removeTrailingSlash($path) { |
|
26 | - return preg_replace('|[\\/]$|', '', $path); |
|
20 | + /** |
|
21 | + * Strips off any kind of slash at the end so as to normalise the path |
|
22 | + * |
|
23 | + * @param string $path Path to normalise. |
|
24 | + */ |
|
25 | + function _removeTrailingSlash($path) { |
|
26 | + return preg_replace('|[\\/]$|', '', $path); |
|
27 | 27 | |
28 | - /** |
|
29 | - * @internal |
|
30 | - * Try benchmarking the following. It's more code, but by not using the |
|
31 | - * regex, it may be faster? Also, shouldn't be looking for |
|
32 | - * DIRECTORY_SEPERATOR instead of a manual "/"? |
|
33 | - */ |
|
34 | - if (substr($path, -1) == DIRECTORY_SEPERATOR) { |
|
35 | - return substr($path, 0, -1); |
|
36 | - } else { |
|
37 | - return $path; |
|
38 | - } |
|
39 | - } |
|
28 | + /** |
|
29 | + * @internal |
|
30 | + * Try benchmarking the following. It's more code, but by not using the |
|
31 | + * regex, it may be faster? Also, shouldn't be looking for |
|
32 | + * DIRECTORY_SEPERATOR instead of a manual "/"? |
|
33 | + */ |
|
34 | + if (substr($path, -1) == DIRECTORY_SEPERATOR) { |
|
35 | + return substr($path, 0, -1); |
|
36 | + } else { |
|
37 | + return $path; |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Scans the directory and adds what it can. |
|
43 | - * @param object $test Group test with {@link GroupTest::addTestFile()} method. |
|
44 | - * @param string $path Directory to scan. |
|
45 | - * @see _attemptToAdd() |
|
46 | - */ |
|
47 | - function collect($test, $path) { |
|
48 | - $path = $this->_removeTrailingSlash($path); |
|
49 | - if ($handle = opendir($path)) { |
|
50 | - while (($entry = readdir($handle)) !== false) { |
|
51 | - $this->_handle($test, $path . DIRECTORY_SEPARATOR . $entry); |
|
52 | - } |
|
53 | - closedir($handle); |
|
54 | - } |
|
55 | - } |
|
41 | + /** |
|
42 | + * Scans the directory and adds what it can. |
|
43 | + * @param object $test Group test with {@link GroupTest::addTestFile()} method. |
|
44 | + * @param string $path Directory to scan. |
|
45 | + * @see _attemptToAdd() |
|
46 | + */ |
|
47 | + function collect($test, $path) { |
|
48 | + $path = $this->_removeTrailingSlash($path); |
|
49 | + if ($handle = opendir($path)) { |
|
50 | + while (($entry = readdir($handle)) !== false) { |
|
51 | + $this->_handle($test, $path . DIRECTORY_SEPARATOR . $entry); |
|
52 | + } |
|
53 | + closedir($handle); |
|
54 | + } |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * This method determines what should be done with a given file and adds |
|
59 | - * it via {@link GroupTest::addTestFile()} if necessary. |
|
60 | - * |
|
61 | - * This method should be overriden to provide custom matching criteria, |
|
62 | - * such as pattern matching, recursive matching, etc. For an example, see |
|
63 | - * {@link SimplePatternCollector::_handle()}. |
|
64 | - * |
|
65 | - * @param object $test Group test with {@link GroupTest::addTestFile()} method. |
|
66 | - * @param string $filename A filename as generated by {@link collect()} |
|
67 | - * @see collect() |
|
68 | - * @access protected |
|
69 | - */ |
|
70 | - function _handle($test, $file) { |
|
71 | - if (!is_dir($file)) { |
|
72 | - $test->addTestFile($file); |
|
73 | - } |
|
74 | - } |
|
57 | + /** |
|
58 | + * This method determines what should be done with a given file and adds |
|
59 | + * it via {@link GroupTest::addTestFile()} if necessary. |
|
60 | + * |
|
61 | + * This method should be overriden to provide custom matching criteria, |
|
62 | + * such as pattern matching, recursive matching, etc. For an example, see |
|
63 | + * {@link SimplePatternCollector::_handle()}. |
|
64 | + * |
|
65 | + * @param object $test Group test with {@link GroupTest::addTestFile()} method. |
|
66 | + * @param string $filename A filename as generated by {@link collect()} |
|
67 | + * @see collect() |
|
68 | + * @access protected |
|
69 | + */ |
|
70 | + function _handle($test, $file) { |
|
71 | + if (!is_dir($file)) { |
|
72 | + $test->addTestFile($file); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -83,31 +83,31 @@ discard block |
||
83 | 83 | * @see SimpleCollector |
84 | 84 | */ |
85 | 85 | class SimplePatternCollector extends SimpleCollector { |
86 | - protected $_pattern; |
|
86 | + protected $_pattern; |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * |
|
91 | - * @param string $pattern Perl compatible regex to test name against |
|
92 | - * See {@link http://us4.php.net/manual/en/reference.pcre.pattern.syntax.php PHP's PCRE} |
|
93 | - * for full documentation of valid pattern.s |
|
94 | - */ |
|
95 | - function SimplePatternCollector($pattern = '/php$/i') { |
|
96 | - $this->_pattern = $pattern; |
|
97 | - } |
|
89 | + /** |
|
90 | + * |
|
91 | + * @param string $pattern Perl compatible regex to test name against |
|
92 | + * See {@link http://us4.php.net/manual/en/reference.pcre.pattern.syntax.php PHP's PCRE} |
|
93 | + * for full documentation of valid pattern.s |
|
94 | + */ |
|
95 | + function SimplePatternCollector($pattern = '/php$/i') { |
|
96 | + $this->_pattern = $pattern; |
|
97 | + } |
|
98 | 98 | |
99 | 99 | |
100 | - /** |
|
101 | - * Attempts to add files that match a given pattern. |
|
102 | - * |
|
103 | - * @see SimpleCollector::_handle() |
|
104 | - * @param object $test Group test with {@link GroupTest::addTestFile()} method. |
|
105 | - * @param string $path Directory to scan. |
|
106 | - * @access protected |
|
107 | - */ |
|
108 | - function _handle($test, $filename) { |
|
109 | - if (preg_match($this->_pattern, $filename)) { |
|
110 | - parent::_handle($test, $filename); |
|
111 | - } |
|
112 | - } |
|
100 | + /** |
|
101 | + * Attempts to add files that match a given pattern. |
|
102 | + * |
|
103 | + * @see SimpleCollector::_handle() |
|
104 | + * @param object $test Group test with {@link GroupTest::addTestFile()} method. |
|
105 | + * @param string $path Directory to scan. |
|
106 | + * @access protected |
|
107 | + */ |
|
108 | + function _handle($test, $filename) { |
|
109 | + if (preg_match($this->_pattern, $filename)) { |
|
110 | + parent::_handle($test, $filename); |
|
111 | + } |
|
112 | + } |
|
113 | 113 | } |
114 | 114 | \ No newline at end of file |
@@ -1,237 +1,237 @@ |
||
1 | 1 | <?php |
2 | - /** |
|
3 | - * Base include file for SimpleTest |
|
4 | - * @package SimpleTest |
|
5 | - * @subpackage WebTester |
|
6 | - * @version $Id: authentication.php 1532 2006-12-01 12:28:55Z xue $ |
|
7 | - */ |
|
8 | - /** |
|
9 | - * include http class |
|
10 | - */ |
|
11 | - require_once(dirname(__FILE__) . '/http.php'); |
|
12 | - |
|
13 | - /** |
|
14 | - * Represents a single security realm's identity. |
|
2 | + /** |
|
3 | + * Base include file for SimpleTest |
|
4 | + * @package SimpleTest |
|
5 | + * @subpackage WebTester |
|
6 | + * @version $Id: authentication.php 1532 2006-12-01 12:28:55Z xue $ |
|
7 | + */ |
|
8 | + /** |
|
9 | + * include http class |
|
10 | + */ |
|
11 | + require_once(dirname(__FILE__) . '/http.php'); |
|
12 | + |
|
13 | + /** |
|
14 | + * Represents a single security realm's identity. |
|
15 | 15 | * @package SimpleTest |
16 | 16 | * @subpackage WebTester |
17 | - */ |
|
18 | - class SimpleRealm { |
|
19 | - protected $_type; |
|
20 | - protected $_root; |
|
21 | - protected $_username; |
|
22 | - protected $_password; |
|
23 | - |
|
24 | - /** |
|
25 | - * Starts with the initial entry directory. |
|
26 | - * @param string $type Authentication type for this |
|
27 | - * realm. Only Basic authentication |
|
28 | - * is currently supported. |
|
29 | - * @param SimpleUrl $url Somewhere in realm. |
|
30 | - * @access public |
|
31 | - */ |
|
32 | - function SimpleRealm($type, $url) { |
|
33 | - $this->_type = $type; |
|
34 | - $this->_root = $url->getBasePath(); |
|
35 | - $this->_username = false; |
|
36 | - $this->_password = false; |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * Adds another location to the realm. |
|
41 | - * @param SimpleUrl $url Somewhere in realm. |
|
42 | - * @access public |
|
43 | - */ |
|
44 | - function stretch($url) { |
|
45 | - $this->_root = $this->_getCommonPath($this->_root, $url->getPath()); |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * Finds the common starting path. |
|
50 | - * @param string $first Path to compare. |
|
51 | - * @param string $second Path to compare. |
|
52 | - * @return string Common directories. |
|
53 | - * @access private |
|
54 | - */ |
|
55 | - function _getCommonPath($first, $second) { |
|
56 | - $first = explode('/', $first); |
|
57 | - $second = explode('/', $second); |
|
58 | - for ($i = 0; $i < min(count($first), count($second)); $i++) { |
|
59 | - if ($first[$i] != $second[$i]) { |
|
60 | - return implode('/', array_slice($first, 0, $i)) . '/'; |
|
61 | - } |
|
62 | - } |
|
63 | - return implode('/', $first) . '/'; |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Sets the identity to try within this realm. |
|
68 | - * @param string $username Username in authentication dialog. |
|
69 | - * @param string $username Password in authentication dialog. |
|
70 | - * @access public |
|
71 | - */ |
|
72 | - function setIdentity($username, $password) { |
|
73 | - $this->_username = $username; |
|
74 | - $this->_password = $password; |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Accessor for current identity. |
|
79 | - * @return string Last succesful username. |
|
80 | - * @access public |
|
81 | - */ |
|
82 | - function getUsername() { |
|
83 | - return $this->_username; |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Accessor for current identity. |
|
88 | - * @return string Last succesful password. |
|
89 | - * @access public |
|
90 | - */ |
|
91 | - function getPassword() { |
|
92 | - return $this->_password; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Test to see if the URL is within the directory |
|
97 | - * tree of the realm. |
|
98 | - * @param SimpleUrl $url URL to test. |
|
99 | - * @return boolean True if subpath. |
|
100 | - * @access public |
|
101 | - */ |
|
102 | - function isWithin($url) { |
|
103 | - if ($this->_isIn($this->_root, $url->getBasePath())) { |
|
104 | - return true; |
|
105 | - } |
|
106 | - if ($this->_isIn($this->_root, $url->getBasePath() . $url->getPage() . '/')) { |
|
107 | - return true; |
|
108 | - } |
|
109 | - return false; |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Tests to see if one string is a substring of |
|
114 | - * another. |
|
115 | - * @param string $part Small bit. |
|
116 | - * @param string $whole Big bit. |
|
117 | - * @return boolean True if the small bit is |
|
118 | - * in the big bit. |
|
119 | - * @access private |
|
120 | - */ |
|
121 | - function _isIn($part, $whole) { |
|
122 | - return strpos($whole, $part) === 0; |
|
123 | - } |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Manages security realms. |
|
17 | + */ |
|
18 | + class SimpleRealm { |
|
19 | + protected $_type; |
|
20 | + protected $_root; |
|
21 | + protected $_username; |
|
22 | + protected $_password; |
|
23 | + |
|
24 | + /** |
|
25 | + * Starts with the initial entry directory. |
|
26 | + * @param string $type Authentication type for this |
|
27 | + * realm. Only Basic authentication |
|
28 | + * is currently supported. |
|
29 | + * @param SimpleUrl $url Somewhere in realm. |
|
30 | + * @access public |
|
31 | + */ |
|
32 | + function SimpleRealm($type, $url) { |
|
33 | + $this->_type = $type; |
|
34 | + $this->_root = $url->getBasePath(); |
|
35 | + $this->_username = false; |
|
36 | + $this->_password = false; |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * Adds another location to the realm. |
|
41 | + * @param SimpleUrl $url Somewhere in realm. |
|
42 | + * @access public |
|
43 | + */ |
|
44 | + function stretch($url) { |
|
45 | + $this->_root = $this->_getCommonPath($this->_root, $url->getPath()); |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * Finds the common starting path. |
|
50 | + * @param string $first Path to compare. |
|
51 | + * @param string $second Path to compare. |
|
52 | + * @return string Common directories. |
|
53 | + * @access private |
|
54 | + */ |
|
55 | + function _getCommonPath($first, $second) { |
|
56 | + $first = explode('/', $first); |
|
57 | + $second = explode('/', $second); |
|
58 | + for ($i = 0; $i < min(count($first), count($second)); $i++) { |
|
59 | + if ($first[$i] != $second[$i]) { |
|
60 | + return implode('/', array_slice($first, 0, $i)) . '/'; |
|
61 | + } |
|
62 | + } |
|
63 | + return implode('/', $first) . '/'; |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Sets the identity to try within this realm. |
|
68 | + * @param string $username Username in authentication dialog. |
|
69 | + * @param string $username Password in authentication dialog. |
|
70 | + * @access public |
|
71 | + */ |
|
72 | + function setIdentity($username, $password) { |
|
73 | + $this->_username = $username; |
|
74 | + $this->_password = $password; |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Accessor for current identity. |
|
79 | + * @return string Last succesful username. |
|
80 | + * @access public |
|
81 | + */ |
|
82 | + function getUsername() { |
|
83 | + return $this->_username; |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Accessor for current identity. |
|
88 | + * @return string Last succesful password. |
|
89 | + * @access public |
|
90 | + */ |
|
91 | + function getPassword() { |
|
92 | + return $this->_password; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Test to see if the URL is within the directory |
|
97 | + * tree of the realm. |
|
98 | + * @param SimpleUrl $url URL to test. |
|
99 | + * @return boolean True if subpath. |
|
100 | + * @access public |
|
101 | + */ |
|
102 | + function isWithin($url) { |
|
103 | + if ($this->_isIn($this->_root, $url->getBasePath())) { |
|
104 | + return true; |
|
105 | + } |
|
106 | + if ($this->_isIn($this->_root, $url->getBasePath() . $url->getPage() . '/')) { |
|
107 | + return true; |
|
108 | + } |
|
109 | + return false; |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Tests to see if one string is a substring of |
|
114 | + * another. |
|
115 | + * @param string $part Small bit. |
|
116 | + * @param string $whole Big bit. |
|
117 | + * @return boolean True if the small bit is |
|
118 | + * in the big bit. |
|
119 | + * @access private |
|
120 | + */ |
|
121 | + function _isIn($part, $whole) { |
|
122 | + return strpos($whole, $part) === 0; |
|
123 | + } |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Manages security realms. |
|
128 | 128 | * @package SimpleTest |
129 | 129 | * @subpackage WebTester |
130 | - */ |
|
131 | - class SimpleAuthenticator { |
|
132 | - protected $_realms; |
|
133 | - |
|
134 | - /** |
|
135 | - * Clears the realms. |
|
136 | - * @access public |
|
137 | - */ |
|
138 | - function SimpleAuthenticator() { |
|
139 | - $this->restartSession(); |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * Starts with no realms set up. |
|
144 | - * @access public |
|
145 | - */ |
|
146 | - function restartSession() { |
|
147 | - $this->_realms = array(); |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * Adds a new realm centered the current URL. |
|
152 | - * Browsers vary wildly on their behaviour in this |
|
153 | - * regard. Mozilla ignores the realm and presents |
|
154 | - * only when challenged, wasting bandwidth. IE |
|
155 | - * just carries on presenting until a new challenge |
|
156 | - * occours. SimpleTest tries to follow the spirit of |
|
157 | - * the original standards committee and treats the |
|
158 | - * base URL as the root of a file tree shaped realm. |
|
159 | - * @param SimpleUrl $url Base of realm. |
|
160 | - * @param string $type Authentication type for this |
|
161 | - * realm. Only Basic authentication |
|
162 | - * is currently supported. |
|
163 | - * @param string $realm Name of realm. |
|
164 | - * @access public |
|
165 | - */ |
|
166 | - function addRealm($url, $type, $realm) { |
|
167 | - $this->_realms[$url->getHost()][$realm] = new SimpleRealm($type, $url); |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Sets the current identity to be presented |
|
172 | - * against that realm. |
|
173 | - * @param string $host Server hosting realm. |
|
174 | - * @param string $realm Name of realm. |
|
175 | - * @param string $username Username for realm. |
|
176 | - * @param string $password Password for realm. |
|
177 | - * @access public |
|
178 | - */ |
|
179 | - function setIdentityForRealm($host, $realm, $username, $password) { |
|
180 | - if (isset($this->_realms[$host][$realm])) { |
|
181 | - $this->_realms[$host][$realm]->setIdentity($username, $password); |
|
182 | - } |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Finds the name of the realm by comparing URLs. |
|
187 | - * @param SimpleUrl $url URL to test. |
|
188 | - * @return SimpleRealm Name of realm. |
|
189 | - * @access private |
|
190 | - */ |
|
191 | - function _findRealmFromUrl($url) { |
|
192 | - if (! isset($this->_realms[$url->getHost()])) { |
|
193 | - return false; |
|
194 | - } |
|
195 | - foreach ($this->_realms[$url->getHost()] as $name => $realm) { |
|
196 | - if ($realm->isWithin($url)) { |
|
197 | - return $realm; |
|
198 | - } |
|
199 | - } |
|
200 | - return false; |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Presents the appropriate headers for this location. |
|
205 | - * @param SimpleHttpRequest $request Request to modify. |
|
206 | - * @param SimpleUrl $url Base of realm. |
|
207 | - * @access public |
|
208 | - */ |
|
209 | - function addHeaders($request, $url) { |
|
210 | - if ($url->getUsername() && $url->getPassword()) { |
|
211 | - $username = $url->getUsername(); |
|
212 | - $password = $url->getPassword(); |
|
213 | - } elseif ($realm = $this->_findRealmFromUrl($url)) { |
|
214 | - $username = $realm->getUsername(); |
|
215 | - $password = $realm->getPassword(); |
|
216 | - } else { |
|
217 | - return; |
|
218 | - } |
|
219 | - $this->addBasicHeaders($request, $username, $password); |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * Presents the appropriate headers for this |
|
224 | - * location for basic authentication. |
|
225 | - * @param SimpleHttpRequest $request Request to modify. |
|
226 | - * @param string $username Username for realm. |
|
227 | - * @param string $password Password for realm. |
|
228 | - * @access public |
|
229 | - * @static |
|
230 | - */ |
|
231 | - static function addBasicHeaders($request, $username, $password) { |
|
232 | - if ($username && $password) { |
|
233 | - $request->addHeaderLine( |
|
234 | - 'Authorization: Basic ' . base64_encode("$username:$password")); |
|
235 | - } |
|
236 | - } |
|
237 | - } |
|
238 | 130 | \ No newline at end of file |
131 | + */ |
|
132 | + class SimpleAuthenticator { |
|
133 | + protected $_realms; |
|
134 | + |
|
135 | + /** |
|
136 | + * Clears the realms. |
|
137 | + * @access public |
|
138 | + */ |
|
139 | + function SimpleAuthenticator() { |
|
140 | + $this->restartSession(); |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Starts with no realms set up. |
|
145 | + * @access public |
|
146 | + */ |
|
147 | + function restartSession() { |
|
148 | + $this->_realms = array(); |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * Adds a new realm centered the current URL. |
|
153 | + * Browsers vary wildly on their behaviour in this |
|
154 | + * regard. Mozilla ignores the realm and presents |
|
155 | + * only when challenged, wasting bandwidth. IE |
|
156 | + * just carries on presenting until a new challenge |
|
157 | + * occours. SimpleTest tries to follow the spirit of |
|
158 | + * the original standards committee and treats the |
|
159 | + * base URL as the root of a file tree shaped realm. |
|
160 | + * @param SimpleUrl $url Base of realm. |
|
161 | + * @param string $type Authentication type for this |
|
162 | + * realm. Only Basic authentication |
|
163 | + * is currently supported. |
|
164 | + * @param string $realm Name of realm. |
|
165 | + * @access public |
|
166 | + */ |
|
167 | + function addRealm($url, $type, $realm) { |
|
168 | + $this->_realms[$url->getHost()][$realm] = new SimpleRealm($type, $url); |
|
169 | + } |
|
170 | + |
|
171 | + /** |
|
172 | + * Sets the current identity to be presented |
|
173 | + * against that realm. |
|
174 | + * @param string $host Server hosting realm. |
|
175 | + * @param string $realm Name of realm. |
|
176 | + * @param string $username Username for realm. |
|
177 | + * @param string $password Password for realm. |
|
178 | + * @access public |
|
179 | + */ |
|
180 | + function setIdentityForRealm($host, $realm, $username, $password) { |
|
181 | + if (isset($this->_realms[$host][$realm])) { |
|
182 | + $this->_realms[$host][$realm]->setIdentity($username, $password); |
|
183 | + } |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Finds the name of the realm by comparing URLs. |
|
188 | + * @param SimpleUrl $url URL to test. |
|
189 | + * @return SimpleRealm Name of realm. |
|
190 | + * @access private |
|
191 | + */ |
|
192 | + function _findRealmFromUrl($url) { |
|
193 | + if (! isset($this->_realms[$url->getHost()])) { |
|
194 | + return false; |
|
195 | + } |
|
196 | + foreach ($this->_realms[$url->getHost()] as $name => $realm) { |
|
197 | + if ($realm->isWithin($url)) { |
|
198 | + return $realm; |
|
199 | + } |
|
200 | + } |
|
201 | + return false; |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Presents the appropriate headers for this location. |
|
206 | + * @param SimpleHttpRequest $request Request to modify. |
|
207 | + * @param SimpleUrl $url Base of realm. |
|
208 | + * @access public |
|
209 | + */ |
|
210 | + function addHeaders($request, $url) { |
|
211 | + if ($url->getUsername() && $url->getPassword()) { |
|
212 | + $username = $url->getUsername(); |
|
213 | + $password = $url->getPassword(); |
|
214 | + } elseif ($realm = $this->_findRealmFromUrl($url)) { |
|
215 | + $username = $realm->getUsername(); |
|
216 | + $password = $realm->getPassword(); |
|
217 | + } else { |
|
218 | + return; |
|
219 | + } |
|
220 | + $this->addBasicHeaders($request, $username, $password); |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * Presents the appropriate headers for this |
|
225 | + * location for basic authentication. |
|
226 | + * @param SimpleHttpRequest $request Request to modify. |
|
227 | + * @param string $username Username for realm. |
|
228 | + * @param string $password Password for realm. |
|
229 | + * @access public |
|
230 | + * @static |
|
231 | + */ |
|
232 | + static function addBasicHeaders($request, $username, $password) { |
|
233 | + if ($username && $password) { |
|
234 | + $request->addHeaderLine( |
|
235 | + 'Authorization: Basic ' . base64_encode("$username:$password")); |
|
236 | + } |
|
237 | + } |
|
238 | + } |
|
239 | 239 | \ No newline at end of file |
@@ -1,181 +1,181 @@ |
||
1 | 1 | <?php |
2 | - /** |
|
3 | - * base include file for SimpleTest |
|
4 | - * @package SimpleTest |
|
5 | - * @subpackage UnitTester |
|
6 | - * @version $Id: errors.php 1606 2007-01-09 10:42:06Z wei $ |
|
7 | - */ |
|
2 | + /** |
|
3 | + * base include file for SimpleTest |
|
4 | + * @package SimpleTest |
|
5 | + * @subpackage UnitTester |
|
6 | + * @version $Id: errors.php 1606 2007-01-09 10:42:06Z wei $ |
|
7 | + */ |
|
8 | 8 | |
9 | - /** @ignore - PHP5 compatibility fix. */ |
|
10 | - if (! defined('E_STRICT')) { |
|
11 | - define('E_STRICT', 2048); |
|
12 | - } |
|
9 | + /** @ignore - PHP5 compatibility fix. */ |
|
10 | + if (! defined('E_STRICT')) { |
|
11 | + define('E_STRICT', 2048); |
|
12 | + } |
|
13 | 13 | |
14 | - /**#@+ |
|
14 | + /**#@+ |
|
15 | 15 | * Includes SimpleTest files. |
16 | 16 | */ |
17 | - require_once(dirname(__FILE__) . '/invoker.php'); |
|
17 | + require_once(dirname(__FILE__) . '/invoker.php'); |
|
18 | 18 | |
19 | - /** |
|
20 | - * Extension that traps errors into an error queue. |
|
19 | + /** |
|
20 | + * Extension that traps errors into an error queue. |
|
21 | 21 | * @package SimpleTest |
22 | 22 | * @subpackage UnitTester |
23 | - */ |
|
24 | - class SimpleErrorTrappingInvoker extends SimpleInvokerDecorator { |
|
23 | + */ |
|
24 | + class SimpleErrorTrappingInvoker extends SimpleInvokerDecorator { |
|
25 | 25 | |
26 | - /** |
|
27 | - * Stores the invoker to wrap. |
|
28 | - * @param SimpleInvoker $invoker Test method runner. |
|
29 | - */ |
|
30 | - function SimpleErrorTrappingInvoker($invoker) { |
|
31 | - $this->SimpleInvokerDecorator($invoker); |
|
32 | - } |
|
26 | + /** |
|
27 | + * Stores the invoker to wrap. |
|
28 | + * @param SimpleInvoker $invoker Test method runner. |
|
29 | + */ |
|
30 | + function SimpleErrorTrappingInvoker($invoker) { |
|
31 | + $this->SimpleInvokerDecorator($invoker); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Invokes a test method and dispatches any |
|
36 | - * untrapped errors. Called back from |
|
37 | - * the visiting runner. |
|
38 | - * @param string $method Test method to call. |
|
39 | - * @access public |
|
40 | - */ |
|
41 | - function invoke($method) { |
|
42 | - set_error_handler('simpleTestErrorHandler'); |
|
43 | - parent::invoke($method); |
|
44 | - $queue = SimpleErrorQueue::instance(); |
|
45 | - while (list($severity, $message, $file, $line, $globals) = $queue->extract()) { |
|
46 | - $severity = SimpleErrorQueue::getSeverityAsString($severity); |
|
47 | - $test_case = $this->getTestCase(); |
|
48 | - $test_case->error($severity, $message, $file, $line); |
|
49 | - } |
|
50 | - restore_error_handler(); |
|
51 | - } |
|
52 | - } |
|
34 | + /** |
|
35 | + * Invokes a test method and dispatches any |
|
36 | + * untrapped errors. Called back from |
|
37 | + * the visiting runner. |
|
38 | + * @param string $method Test method to call. |
|
39 | + * @access public |
|
40 | + */ |
|
41 | + function invoke($method) { |
|
42 | + set_error_handler('simpleTestErrorHandler'); |
|
43 | + parent::invoke($method); |
|
44 | + $queue = SimpleErrorQueue::instance(); |
|
45 | + while (list($severity, $message, $file, $line, $globals) = $queue->extract()) { |
|
46 | + $severity = SimpleErrorQueue::getSeverityAsString($severity); |
|
47 | + $test_case = $this->getTestCase(); |
|
48 | + $test_case->error($severity, $message, $file, $line); |
|
49 | + } |
|
50 | + restore_error_handler(); |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Singleton error queue used to record trapped |
|
56 | - * errors. |
|
54 | + /** |
|
55 | + * Singleton error queue used to record trapped |
|
56 | + * errors. |
|
57 | 57 | * @package SimpleTest |
58 | 58 | * @subpackage UnitTester |
59 | - */ |
|
60 | - class SimpleErrorQueue { |
|
61 | - protected $_queue; |
|
59 | + */ |
|
60 | + class SimpleErrorQueue { |
|
61 | + protected $_queue; |
|
62 | 62 | |
63 | - /** |
|
64 | - * Starts with an empty queue. |
|
65 | - * @access public |
|
66 | - */ |
|
67 | - function SimpleErrorQueue() { |
|
68 | - $this->clear(); |
|
69 | - } |
|
63 | + /** |
|
64 | + * Starts with an empty queue. |
|
65 | + * @access public |
|
66 | + */ |
|
67 | + function SimpleErrorQueue() { |
|
68 | + $this->clear(); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * 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. |
|
78 | - * @access public |
|
79 | - */ |
|
80 | - function add($severity, $message, $filename, $line, $super_globals) { |
|
81 | - array_push( |
|
82 | - $this->_queue, |
|
83 | - array($severity, $message, $filename, $line, $super_globals)); |
|
84 | - } |
|
71 | + /** |
|
72 | + * 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. |
|
78 | + * @access public |
|
79 | + */ |
|
80 | + function add($severity, $message, $filename, $line, $super_globals) { |
|
81 | + array_push( |
|
82 | + $this->_queue, |
|
83 | + array($severity, $message, $filename, $line, $super_globals)); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Pulls the earliest error from the queue. |
|
88 | - * @return False if none, or a list of error |
|
89 | - * information. Elements are: severity |
|
90 | - * as the PHP error code, the error message, |
|
91 | - * the file with the error, the line number |
|
92 | - * and a list of PHP super global arrays. |
|
93 | - * @access public |
|
94 | - */ |
|
95 | - function extract() { |
|
96 | - if (count($this->_queue)) { |
|
97 | - return array_shift($this->_queue); |
|
98 | - } |
|
99 | - return false; |
|
100 | - } |
|
86 | + /** |
|
87 | + * Pulls the earliest error from the queue. |
|
88 | + * @return False if none, or a list of error |
|
89 | + * information. Elements are: severity |
|
90 | + * as the PHP error code, the error message, |
|
91 | + * the file with the error, the line number |
|
92 | + * and a list of PHP super global arrays. |
|
93 | + * @access public |
|
94 | + */ |
|
95 | + function extract() { |
|
96 | + if (count($this->_queue)) { |
|
97 | + return array_shift($this->_queue); |
|
98 | + } |
|
99 | + return false; |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Discards the contents of the error queue. |
|
104 | - * @access public |
|
105 | - */ |
|
106 | - function clear() { |
|
107 | - $this->_queue = array(); |
|
108 | - } |
|
102 | + /** |
|
103 | + * Discards the contents of the error queue. |
|
104 | + * @access public |
|
105 | + */ |
|
106 | + function clear() { |
|
107 | + $this->_queue = array(); |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * Tests to see if the queue is empty. |
|
112 | - * @return True if empty. |
|
113 | - */ |
|
114 | - function isEmpty() { |
|
115 | - return (count($this->_queue) == 0); |
|
116 | - } |
|
110 | + /** |
|
111 | + * Tests to see if the queue is empty. |
|
112 | + * @return True if empty. |
|
113 | + */ |
|
114 | + function isEmpty() { |
|
115 | + return (count($this->_queue) == 0); |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * Global access to a single error queue. |
|
120 | - * @return Global error queue object. |
|
121 | - * @access public |
|
122 | - * @static |
|
123 | - */ |
|
124 | - static function instance() { |
|
125 | - static $queue = false; |
|
126 | - if (! $queue) { |
|
127 | - $queue = new SimpleErrorQueue(); |
|
128 | - } |
|
129 | - return $queue; |
|
130 | - } |
|
118 | + /** |
|
119 | + * Global access to a single error queue. |
|
120 | + * @return Global error queue object. |
|
121 | + * @access public |
|
122 | + * @static |
|
123 | + */ |
|
124 | + static function instance() { |
|
125 | + static $queue = false; |
|
126 | + if (! $queue) { |
|
127 | + $queue = new SimpleErrorQueue(); |
|
128 | + } |
|
129 | + return $queue; |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * Converst an error code into it's string |
|
134 | - * representation. |
|
135 | - * @param $severity PHP integer error code. |
|
136 | - * @return String version of error code. |
|
137 | - * @access public |
|
138 | - * @static |
|
139 | - */ |
|
140 | - static function getSeverityAsString($severity) { |
|
141 | - static $map = array( |
|
142 | - E_STRICT => 'E_STRICT', |
|
143 | - E_ERROR => 'E_ERROR', |
|
144 | - E_WARNING => 'E_WARNING', |
|
145 | - E_PARSE => 'E_PARSE', |
|
146 | - E_NOTICE => 'E_NOTICE', |
|
147 | - E_CORE_ERROR => 'E_CORE_ERROR', |
|
148 | - E_CORE_WARNING => 'E_CORE_WARNING', |
|
149 | - E_COMPILE_ERROR => 'E_COMPILE_ERROR', |
|
150 | - E_COMPILE_WARNING => 'E_COMPILE_WARNING', |
|
151 | - E_USER_ERROR => 'E_USER_ERROR', |
|
152 | - E_USER_WARNING => 'E_USER_WARNING', |
|
153 | - E_USER_NOTICE => 'E_USER_NOTICE', 4096 => 'E??'); |
|
154 | - return $map[$severity]; |
|
155 | - } |
|
156 | - } |
|
132 | + /** |
|
133 | + * Converst an error code into it's string |
|
134 | + * representation. |
|
135 | + * @param $severity PHP integer error code. |
|
136 | + * @return String version of error code. |
|
137 | + * @access public |
|
138 | + * @static |
|
139 | + */ |
|
140 | + static function getSeverityAsString($severity) { |
|
141 | + static $map = array( |
|
142 | + E_STRICT => 'E_STRICT', |
|
143 | + E_ERROR => 'E_ERROR', |
|
144 | + E_WARNING => 'E_WARNING', |
|
145 | + E_PARSE => 'E_PARSE', |
|
146 | + E_NOTICE => 'E_NOTICE', |
|
147 | + E_CORE_ERROR => 'E_CORE_ERROR', |
|
148 | + E_CORE_WARNING => 'E_CORE_WARNING', |
|
149 | + E_COMPILE_ERROR => 'E_COMPILE_ERROR', |
|
150 | + E_COMPILE_WARNING => 'E_COMPILE_WARNING', |
|
151 | + E_USER_ERROR => 'E_USER_ERROR', |
|
152 | + E_USER_WARNING => 'E_USER_WARNING', |
|
153 | + E_USER_NOTICE => 'E_USER_NOTICE', 4096 => 'E??'); |
|
154 | + return $map[$severity]; |
|
155 | + } |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * Error handler that simply stashes any errors into the global |
|
160 | - * error queue. Simulates the existing behaviour with respect to |
|
161 | - * logging errors, but this feature may be removed in future. |
|
162 | - * @param $severity PHP error code. |
|
163 | - * @param $message Text of error. |
|
164 | - * @param $filename File error occoured in. |
|
165 | - * @param $line Line number of error. |
|
166 | - * @param $super_globals Hash of PHP super global arrays. |
|
167 | - * @static |
|
168 | - * @access public |
|
169 | - */ |
|
170 | - function simpleTestErrorHandler($severity, $message, $filename, $line, $super_globals) { |
|
171 | - if ($severity = $severity & error_reporting()) { |
|
172 | - restore_error_handler(); |
|
173 | - if (ini_get('log_errors')) { |
|
174 | - $label = SimpleErrorQueue::getSeverityAsString($severity); |
|
175 | - error_log("$label: $message in $filename on line $line"); |
|
176 | - } |
|
177 | - $queue = SimpleErrorQueue::instance(); |
|
178 | - $queue->add($severity, $message, $filename, $line, $super_globals); |
|
179 | - set_error_handler('simpleTestErrorHandler'); |
|
180 | - } |
|
181 | - } |
|
182 | 158 | \ No newline at end of file |
159 | + /** |
|
160 | + * Error handler that simply stashes any errors into the global |
|
161 | + * error queue. Simulates the existing behaviour with respect to |
|
162 | + * logging errors, but this feature may be removed in future. |
|
163 | + * @param $severity PHP error code. |
|
164 | + * @param $message Text of error. |
|
165 | + * @param $filename File error occoured in. |
|
166 | + * @param $line Line number of error. |
|
167 | + * @param $super_globals Hash of PHP super global arrays. |
|
168 | + * @static |
|
169 | + * @access public |
|
170 | + */ |
|
171 | + function simpleTestErrorHandler($severity, $message, $filename, $line, $super_globals) { |
|
172 | + if ($severity = $severity & error_reporting()) { |
|
173 | + restore_error_handler(); |
|
174 | + if (ini_get('log_errors')) { |
|
175 | + $label = SimpleErrorQueue::getSeverityAsString($severity); |
|
176 | + error_log("$label: $message in $filename on line $line"); |
|
177 | + } |
|
178 | + $queue = SimpleErrorQueue::instance(); |
|
179 | + $queue->add($severity, $message, $filename, $line, $super_globals); |
|
180 | + set_error_handler('simpleTestErrorHandler'); |
|
181 | + } |
|
182 | + } |
|
183 | 183 | \ No newline at end of file |
@@ -1,281 +1,281 @@ |
||
1 | 1 | <?php |
2 | - /** |
|
3 | - * Global state for SimpleTest and kicker script in future versions. |
|
4 | - * @package SimpleTest |
|
5 | - * @subpackage UnitTester |
|
6 | - * @version $Id: simpletest.php 1532 2006-12-01 12:28:55Z xue $ |
|
7 | - */ |
|
2 | + /** |
|
3 | + * Global state for SimpleTest and kicker script in future versions. |
|
4 | + * @package SimpleTest |
|
5 | + * @subpackage UnitTester |
|
6 | + * @version $Id: simpletest.php 1532 2006-12-01 12:28:55Z xue $ |
|
7 | + */ |
|
8 | 8 | |
9 | - /**#@+ |
|
9 | + /**#@+ |
|
10 | 10 | * include SimpleTest files |
11 | 11 | */ |
12 | - if (version_compare(phpversion(), '5') >= 0) { |
|
13 | - require_once(dirname(__FILE__) . '/reflection_php5.php'); |
|
14 | - } else { |
|
15 | - require_once(dirname(__FILE__) . '/reflection_php4.php'); |
|
16 | - } |
|
17 | - /**#@-*/ |
|
12 | + if (version_compare(phpversion(), '5') >= 0) { |
|
13 | + require_once(dirname(__FILE__) . '/reflection_php5.php'); |
|
14 | + } else { |
|
15 | + require_once(dirname(__FILE__) . '/reflection_php4.php'); |
|
16 | + } |
|
17 | + /**#@-*/ |
|
18 | 18 | |
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. |
|
24 | - * @package SimpleTest |
|
25 | - */ |
|
26 | - class SimpleTest { |
|
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. |
|
24 | + * @package SimpleTest |
|
25 | + */ |
|
26 | + class SimpleTest { |
|
27 | 27 | |
28 | - /** |
|
29 | - * Reads the SimpleTest version from the release file. |
|
30 | - * @return string Version string. |
|
31 | - * @static |
|
32 | - * @access public |
|
33 | - */ |
|
34 | - static function getVersion() { |
|
35 | - $content = file(dirname(__FILE__) . '/VERSION'); |
|
36 | - return trim($content[0]); |
|
37 | - } |
|
28 | + /** |
|
29 | + * Reads the SimpleTest version from the release file. |
|
30 | + * @return string Version string. |
|
31 | + * @static |
|
32 | + * @access public |
|
33 | + */ |
|
34 | + static function getVersion() { |
|
35 | + $content = file(dirname(__FILE__) . '/VERSION'); |
|
36 | + return trim($content[0]); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Sets the name of a test case to ignore, usually |
|
41 | - * because the class is an abstract case that should |
|
42 | - * not be run. Once PHP4 is dropped this will disappear |
|
43 | - * as a public method and "abstract" will rule. |
|
44 | - * @param string $class Add a class to ignore. |
|
45 | - * @static |
|
46 | - * @access public |
|
47 | - */ |
|
48 | - static function ignore($class) { |
|
49 | - $registry = &SimpleTest::_getRegistry(); |
|
50 | - $registry['IgnoreList'][strtolower($class)] = true; |
|
51 | - } |
|
39 | + /** |
|
40 | + * Sets the name of a test case to ignore, usually |
|
41 | + * because the class is an abstract case that should |
|
42 | + * not be run. Once PHP4 is dropped this will disappear |
|
43 | + * as a public method and "abstract" will rule. |
|
44 | + * @param string $class Add a class to ignore. |
|
45 | + * @static |
|
46 | + * @access public |
|
47 | + */ |
|
48 | + static function ignore($class) { |
|
49 | + $registry = &SimpleTest::_getRegistry(); |
|
50 | + $registry['IgnoreList'][strtolower($class)] = true; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Scans the now complete ignore list, and adds |
|
55 | - * all parent classes to the list. If a class |
|
56 | - * is not a runnable test case, then it's parents |
|
57 | - * wouldn't be either. This is syntactic sugar |
|
58 | - * to cut down on ommissions of ignore()'s or |
|
59 | - * missing abstract declarations. This cannot |
|
60 | - * be done whilst loading classes wiithout forcing |
|
61 | - * 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. |
|
64 | - * @param array $classes Class names of interest. |
|
65 | - * @static |
|
66 | - * @access public |
|
67 | - */ |
|
68 | - static function ignoreParentsIfIgnored($classes) { |
|
69 | - $registry = &SimpleTest::_getRegistry(); |
|
70 | - foreach ($classes as $class) { |
|
71 | - if (SimpleTest::isIgnored($class)) { |
|
72 | - $reflection = new SimpleReflection($class); |
|
73 | - if ($parent = $reflection->getParent()) { |
|
74 | - SimpleTest::ignore($parent); |
|
75 | - } |
|
76 | - } |
|
77 | - } |
|
78 | - } |
|
53 | + /** |
|
54 | + * Scans the now complete ignore list, and adds |
|
55 | + * all parent classes to the list. If a class |
|
56 | + * is not a runnable test case, then it's parents |
|
57 | + * wouldn't be either. This is syntactic sugar |
|
58 | + * to cut down on ommissions of ignore()'s or |
|
59 | + * missing abstract declarations. This cannot |
|
60 | + * be done whilst loading classes wiithout forcing |
|
61 | + * 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. |
|
64 | + * @param array $classes Class names of interest. |
|
65 | + * @static |
|
66 | + * @access public |
|
67 | + */ |
|
68 | + static function ignoreParentsIfIgnored($classes) { |
|
69 | + $registry = &SimpleTest::_getRegistry(); |
|
70 | + foreach ($classes as $class) { |
|
71 | + if (SimpleTest::isIgnored($class)) { |
|
72 | + $reflection = new SimpleReflection($class); |
|
73 | + if ($parent = $reflection->getParent()) { |
|
74 | + SimpleTest::ignore($parent); |
|
75 | + } |
|
76 | + } |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Test to see if a test case is in the ignore |
|
82 | - * list. Quite obviously the ignore list should |
|
83 | - * be a separate object and will be one day. |
|
84 | - * This method is internal to SimpleTest. Don't |
|
85 | - * use it. |
|
86 | - * @param string $class Class name to test. |
|
87 | - * @return boolean True if should not be run. |
|
88 | - * @access public |
|
89 | - * @static |
|
90 | - */ |
|
91 | - static function isIgnored($class) { |
|
92 | - $registry = &SimpleTest::_getRegistry(); |
|
93 | - return isset($registry['IgnoreList'][strtolower($class)]); |
|
94 | - } |
|
80 | + /** |
|
81 | + * Test to see if a test case is in the ignore |
|
82 | + * list. Quite obviously the ignore list should |
|
83 | + * be a separate object and will be one day. |
|
84 | + * This method is internal to SimpleTest. Don't |
|
85 | + * use it. |
|
86 | + * @param string $class Class name to test. |
|
87 | + * @return boolean True if should not be run. |
|
88 | + * @access public |
|
89 | + * @static |
|
90 | + */ |
|
91 | + static function isIgnored($class) { |
|
92 | + $registry = &SimpleTest::_getRegistry(); |
|
93 | + return isset($registry['IgnoreList'][strtolower($class)]); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @deprecated |
|
98 | - */ |
|
99 | - function setMockBaseClass($mock_base) { |
|
100 | - $registry = &SimpleTest::_getRegistry(); |
|
101 | - $registry['MockBaseClass'] = $mock_base; |
|
102 | - } |
|
96 | + /** |
|
97 | + * @deprecated |
|
98 | + */ |
|
99 | + function setMockBaseClass($mock_base) { |
|
100 | + $registry = &SimpleTest::_getRegistry(); |
|
101 | + $registry['MockBaseClass'] = $mock_base; |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * @deprecated |
|
106 | - */ |
|
107 | - function getMockBaseClass() { |
|
108 | - $registry = &SimpleTest::_getRegistry(); |
|
109 | - return $registry['MockBaseClass']; |
|
110 | - } |
|
104 | + /** |
|
105 | + * @deprecated |
|
106 | + */ |
|
107 | + function getMockBaseClass() { |
|
108 | + $registry = &SimpleTest::_getRegistry(); |
|
109 | + return $registry['MockBaseClass']; |
|
110 | + } |
|
111 | 111 | |
112 | - /** |
|
113 | - * Sets proxy to use on all requests for when |
|
114 | - * testing from behind a firewall. Set host |
|
115 | - * to false to disable. This will take effect |
|
116 | - * if there are no other proxy settings. |
|
117 | - * @param string $proxy Proxy host as URL. |
|
118 | - * @param string $username Proxy username for authentication. |
|
119 | - * @param string $password Proxy password for authentication. |
|
120 | - * @access public |
|
121 | - */ |
|
122 | - function useProxy($proxy, $username = false, $password = false) { |
|
123 | - $registry = &SimpleTest::_getRegistry(); |
|
124 | - $registry['DefaultProxy'] = $proxy; |
|
125 | - $registry['DefaultProxyUsername'] = $username; |
|
126 | - $registry['DefaultProxyPassword'] = $password; |
|
127 | - } |
|
112 | + /** |
|
113 | + * Sets proxy to use on all requests for when |
|
114 | + * testing from behind a firewall. Set host |
|
115 | + * to false to disable. This will take effect |
|
116 | + * if there are no other proxy settings. |
|
117 | + * @param string $proxy Proxy host as URL. |
|
118 | + * @param string $username Proxy username for authentication. |
|
119 | + * @param string $password Proxy password for authentication. |
|
120 | + * @access public |
|
121 | + */ |
|
122 | + function useProxy($proxy, $username = false, $password = false) { |
|
123 | + $registry = &SimpleTest::_getRegistry(); |
|
124 | + $registry['DefaultProxy'] = $proxy; |
|
125 | + $registry['DefaultProxyUsername'] = $username; |
|
126 | + $registry['DefaultProxyPassword'] = $password; |
|
127 | + } |
|
128 | 128 | |
129 | - /** |
|
130 | - * Accessor for default proxy host. |
|
131 | - * @return string Proxy URL. |
|
132 | - * @access public |
|
133 | - */ |
|
134 | - function getDefaultProxy() { |
|
135 | - $registry = &SimpleTest::_getRegistry(); |
|
136 | - return $registry['DefaultProxy']; |
|
137 | - } |
|
129 | + /** |
|
130 | + * Accessor for default proxy host. |
|
131 | + * @return string Proxy URL. |
|
132 | + * @access public |
|
133 | + */ |
|
134 | + function getDefaultProxy() { |
|
135 | + $registry = &SimpleTest::_getRegistry(); |
|
136 | + return $registry['DefaultProxy']; |
|
137 | + } |
|
138 | 138 | |
139 | - /** |
|
140 | - * Accessor for default proxy username. |
|
141 | - * @return string Proxy username for authentication. |
|
142 | - * @access public |
|
143 | - */ |
|
144 | - function getDefaultProxyUsername() { |
|
145 | - $registry = &SimpleTest::_getRegistry(); |
|
146 | - return $registry['DefaultProxyUsername']; |
|
147 | - } |
|
139 | + /** |
|
140 | + * Accessor for default proxy username. |
|
141 | + * @return string Proxy username for authentication. |
|
142 | + * @access public |
|
143 | + */ |
|
144 | + function getDefaultProxyUsername() { |
|
145 | + $registry = &SimpleTest::_getRegistry(); |
|
146 | + return $registry['DefaultProxyUsername']; |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * Accessor for default proxy password. |
|
151 | - * @return string Proxy password for authentication. |
|
152 | - * @access public |
|
153 | - */ |
|
154 | - function getDefaultProxyPassword() { |
|
155 | - $registry = &SimpleTest::_getRegistry(); |
|
156 | - return $registry['DefaultProxyPassword']; |
|
157 | - } |
|
149 | + /** |
|
150 | + * Accessor for default proxy password. |
|
151 | + * @return string Proxy password for authentication. |
|
152 | + * @access public |
|
153 | + */ |
|
154 | + function getDefaultProxyPassword() { |
|
155 | + $registry = &SimpleTest::_getRegistry(); |
|
156 | + return $registry['DefaultProxyPassword']; |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
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 | - static function setCurrent($test) { |
|
168 | - $registry = &SimpleTest::_getRegistry(); |
|
169 | - $registry['CurrentTestCase'] = $test; |
|
170 | - } |
|
159 | + /** |
|
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 | + static function setCurrent($test) { |
|
168 | + $registry = &SimpleTest::_getRegistry(); |
|
169 | + $registry['CurrentTestCase'] = $test; |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * Accessor for current test instance. |
|
174 | - * @return SimpleTEstCase Currently running test. |
|
175 | - * @access public |
|
176 | - * @static |
|
177 | - */ |
|
178 | - static function &getCurrent() { |
|
179 | - $registry = &SimpleTest::_getRegistry(); |
|
180 | - return $registry['CurrentTestCase']; |
|
181 | - } |
|
172 | + /** |
|
173 | + * Accessor for current test instance. |
|
174 | + * @return SimpleTEstCase Currently running test. |
|
175 | + * @access public |
|
176 | + * @static |
|
177 | + */ |
|
178 | + static function &getCurrent() { |
|
179 | + $registry = &SimpleTest::_getRegistry(); |
|
180 | + return $registry['CurrentTestCase']; |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * Accessor for global registry of options. |
|
185 | - * @return hash All stored values. |
|
186 | - * @access private |
|
187 | - * @static |
|
188 | - */ |
|
189 | - static function &_getRegistry() { |
|
190 | - static $registry = false; |
|
191 | - if (! $registry) { |
|
192 | - $registry = SimpleTest::_getDefaults(); |
|
193 | - } |
|
194 | - return $registry; |
|
195 | - } |
|
183 | + /** |
|
184 | + * Accessor for global registry of options. |
|
185 | + * @return hash All stored values. |
|
186 | + * @access private |
|
187 | + * @static |
|
188 | + */ |
|
189 | + static function &_getRegistry() { |
|
190 | + static $registry = false; |
|
191 | + if (! $registry) { |
|
192 | + $registry = SimpleTest::_getDefaults(); |
|
193 | + } |
|
194 | + return $registry; |
|
195 | + } |
|
196 | 196 | |
197 | - /** |
|
198 | - * Constant default values. |
|
199 | - * @return hash All registry defaults. |
|
200 | - * @access private |
|
201 | - * @static |
|
202 | - */ |
|
203 | - static function _getDefaults() { |
|
204 | - return array( |
|
205 | - 'StubBaseClass' => 'SimpleStub', |
|
206 | - 'MockBaseClass' => 'SimpleMock', |
|
207 | - 'IgnoreList' => array(), |
|
208 | - 'DefaultProxy' => false, |
|
209 | - 'DefaultProxyUsername' => false, |
|
210 | - 'DefaultProxyPassword' => false); |
|
211 | - } |
|
212 | - } |
|
197 | + /** |
|
198 | + * Constant default values. |
|
199 | + * @return hash All registry defaults. |
|
200 | + * @access private |
|
201 | + * @static |
|
202 | + */ |
|
203 | + static function _getDefaults() { |
|
204 | + return array( |
|
205 | + 'StubBaseClass' => 'SimpleStub', |
|
206 | + 'MockBaseClass' => 'SimpleMock', |
|
207 | + 'IgnoreList' => array(), |
|
208 | + 'DefaultProxy' => false, |
|
209 | + 'DefaultProxyUsername' => false, |
|
210 | + 'DefaultProxyPassword' => false); |
|
211 | + } |
|
212 | + } |
|
213 | 213 | |
214 | - /** |
|
215 | - * @deprecated |
|
216 | - */ |
|
217 | - class SimpleTestOptions extends SimpleTest { |
|
214 | + /** |
|
215 | + * @deprecated |
|
216 | + */ |
|
217 | + class SimpleTestOptions extends SimpleTest { |
|
218 | 218 | |
219 | - /** |
|
220 | - * @deprecated |
|
221 | - */ |
|
222 | - static function getVersion() { |
|
223 | - return Simpletest::getVersion(); |
|
224 | - } |
|
219 | + /** |
|
220 | + * @deprecated |
|
221 | + */ |
|
222 | + static function getVersion() { |
|
223 | + return Simpletest::getVersion(); |
|
224 | + } |
|
225 | 225 | |
226 | - /** |
|
227 | - * @deprecated |
|
228 | - */ |
|
229 | - static function ignore($class) { |
|
230 | - return Simpletest::ignore($class); |
|
231 | - } |
|
226 | + /** |
|
227 | + * @deprecated |
|
228 | + */ |
|
229 | + static function ignore($class) { |
|
230 | + return Simpletest::ignore($class); |
|
231 | + } |
|
232 | 232 | |
233 | - /** |
|
234 | - * @deprecated |
|
235 | - */ |
|
236 | - static function isIgnored($class) { |
|
237 | - return Simpletest::isIgnored($class); |
|
238 | - } |
|
233 | + /** |
|
234 | + * @deprecated |
|
235 | + */ |
|
236 | + static function isIgnored($class) { |
|
237 | + return Simpletest::isIgnored($class); |
|
238 | + } |
|
239 | 239 | |
240 | - /** |
|
241 | - * @deprecated |
|
242 | - */ |
|
243 | - function setMockBaseClass($mock_base) { |
|
244 | - return Simpletest::setMockBaseClass($mock_base); |
|
245 | - } |
|
240 | + /** |
|
241 | + * @deprecated |
|
242 | + */ |
|
243 | + function setMockBaseClass($mock_base) { |
|
244 | + return Simpletest::setMockBaseClass($mock_base); |
|
245 | + } |
|
246 | 246 | |
247 | - /** |
|
248 | - * @deprecated |
|
249 | - */ |
|
250 | - function getMockBaseClass() { |
|
251 | - return Simpletest::getMockBaseClass(); |
|
252 | - } |
|
247 | + /** |
|
248 | + * @deprecated |
|
249 | + */ |
|
250 | + function getMockBaseClass() { |
|
251 | + return Simpletest::getMockBaseClass(); |
|
252 | + } |
|
253 | 253 | |
254 | - /** |
|
255 | - * @deprecated |
|
256 | - */ |
|
257 | - function useProxy($proxy, $username = false, $password = false) { |
|
258 | - return Simpletest::useProxy($proxy, $username, $password); |
|
259 | - } |
|
254 | + /** |
|
255 | + * @deprecated |
|
256 | + */ |
|
257 | + function useProxy($proxy, $username = false, $password = false) { |
|
258 | + return Simpletest::useProxy($proxy, $username, $password); |
|
259 | + } |
|
260 | 260 | |
261 | - /** |
|
262 | - * @deprecated |
|
263 | - */ |
|
264 | - function getDefaultProxy() { |
|
265 | - return Simpletest::getDefaultProxy(); |
|
266 | - } |
|
261 | + /** |
|
262 | + * @deprecated |
|
263 | + */ |
|
264 | + function getDefaultProxy() { |
|
265 | + return Simpletest::getDefaultProxy(); |
|
266 | + } |
|
267 | 267 | |
268 | - /** |
|
269 | - * @deprecated |
|
270 | - */ |
|
271 | - function getDefaultProxyUsername() { |
|
272 | - return Simpletest::getDefaultProxyUsername(); |
|
273 | - } |
|
268 | + /** |
|
269 | + * @deprecated |
|
270 | + */ |
|
271 | + function getDefaultProxyUsername() { |
|
272 | + return Simpletest::getDefaultProxyUsername(); |
|
273 | + } |
|
274 | 274 | |
275 | - /** |
|
276 | - * @deprecated |
|
277 | - */ |
|
278 | - function getDefaultProxyPassword() { |
|
279 | - return Simpletest::getDefaultProxyPassword(); |
|
280 | - } |
|
281 | - } |
|
282 | 275 | \ No newline at end of file |
276 | + /** |
|
277 | + * @deprecated |
|
278 | + */ |
|
279 | + function getDefaultProxyPassword() { |
|
280 | + return Simpletest::getDefaultProxyPassword(); |
|
281 | + } |
|
282 | + } |
|
283 | 283 | \ No newline at end of file |
@@ -1,215 +1,215 @@ |
||
1 | 1 | <?php |
2 | - /** |
|
3 | - * base include file for SimpleTest |
|
4 | - * @package SimpleTest |
|
5 | - * @subpackage MockObjects |
|
6 | - * @version $Id: socket.php 1398 2006-09-08 19:31:03Z xue $ |
|
7 | - */ |
|
8 | - |
|
9 | - /**#@+ |
|
2 | + /** |
|
3 | + * base include file for SimpleTest |
|
4 | + * @package SimpleTest |
|
5 | + * @subpackage MockObjects |
|
6 | + * @version $Id: socket.php 1398 2006-09-08 19:31:03Z xue $ |
|
7 | + */ |
|
8 | + |
|
9 | + /**#@+ |
|
10 | 10 | * include SimpleTest files |
11 | 11 | */ |
12 | - require_once(dirname(__FILE__) . '/compatibility.php'); |
|
13 | - /**#@-*/ |
|
12 | + require_once(dirname(__FILE__) . '/compatibility.php'); |
|
13 | + /**#@-*/ |
|
14 | 14 | |
15 | - /** |
|
16 | - * Stashes an error for later. Useful for constructors |
|
17 | - * until PHP gets exceptions. |
|
15 | + /** |
|
16 | + * Stashes an error for later. Useful for constructors |
|
17 | + * until PHP gets exceptions. |
|
18 | 18 | * @package SimpleTest |
19 | 19 | * @subpackage WebTester |
20 | - */ |
|
21 | - class SimpleStickyError { |
|
22 | - protected $_error = 'Constructor not chained'; |
|
23 | - |
|
24 | - /** |
|
25 | - * Sets the error to empty. |
|
26 | - * @access public |
|
27 | - */ |
|
28 | - function SimpleStickyError() { |
|
29 | - $this->_clearError(); |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * Test for an outstanding error. |
|
34 | - * @return boolean True if there is an error. |
|
35 | - * @access public |
|
36 | - */ |
|
37 | - function isError() { |
|
38 | - return ($this->_error != ''); |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * Accessor for an outstanding error. |
|
43 | - * @return string Empty string if no error otherwise |
|
44 | - * the error message. |
|
45 | - * @access public |
|
46 | - */ |
|
47 | - function getError() { |
|
48 | - return $this->_error; |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Sets the internal error. |
|
53 | - * @param string Error message to stash. |
|
54 | - * @access protected |
|
55 | - */ |
|
56 | - function _setError($error) { |
|
57 | - $this->_error = $error; |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Resets the error state to no error. |
|
62 | - * @access protected |
|
63 | - */ |
|
64 | - function _clearError() { |
|
65 | - $this->_setError(''); |
|
66 | - } |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * Wrapper for TCP/IP socket. |
|
71 | - * @package SimpleTest |
|
72 | - * @subpackage WebTester |
|
73 | - */ |
|
74 | - class SimpleSocket extends SimpleStickyError { |
|
75 | - protected $_handle; |
|
76 | - protected $_is_open = false; |
|
77 | - protected $_sent = ''; |
|
78 | - public $lock_size; |
|
79 | - |
|
80 | - /** |
|
81 | - * Opens a socket for reading and writing. |
|
82 | - * @param string $host Hostname to send request to. |
|
83 | - * @param integer $port Port on remote machine to open. |
|
84 | - * @param integer $timeout Connection timeout in seconds. |
|
85 | - * @param integer $block_size Size of chunk to read. |
|
86 | - * @access public |
|
87 | - */ |
|
88 | - function SimpleSocket($host, $port, $timeout, $block_size = 255) { |
|
89 | - $this->SimpleStickyError(); |
|
90 | - if (! ($this->_handle = $this->_openSocket($host, $port, $error_number, $error, $timeout))) { |
|
91 | - $this->_setError("Cannot open [$host:$port] with [$error] within [$timeout] seconds"); |
|
92 | - return; |
|
93 | - } |
|
94 | - $this->_is_open = true; |
|
95 | - $this->_block_size = $block_size; |
|
96 | - SimpleTestCompatibility::setTimeout($this->_handle, $timeout); |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Writes some data to the socket and saves alocal copy. |
|
101 | - * @param string $message String to send to socket. |
|
102 | - * @return boolean True if successful. |
|
103 | - * @access public |
|
104 | - */ |
|
105 | - function write($message) { |
|
106 | - if ($this->isError() || ! $this->isOpen()) { |
|
107 | - return false; |
|
108 | - } |
|
109 | - $count = fwrite($this->_handle, $message); |
|
110 | - if (! $count) { |
|
111 | - if ($count === false) { |
|
112 | - $this->_setError('Cannot write to socket'); |
|
113 | - $this->close(); |
|
114 | - } |
|
115 | - return false; |
|
116 | - } |
|
117 | - fflush($this->_handle); |
|
118 | - $this->_sent .= $message; |
|
119 | - return true; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Reads data from the socket. The error suppresion |
|
124 | - * is a workaround for PHP4 always throwing a warning |
|
125 | - * with a secure socket. |
|
126 | - * @return integer/boolean Incoming bytes. False |
|
127 | - * on error. |
|
128 | - * @access public |
|
129 | - */ |
|
130 | - function read() { |
|
131 | - if ($this->isError() || ! $this->isOpen()) { |
|
132 | - return false; |
|
133 | - } |
|
134 | - $raw = @fread($this->_handle, $this->_block_size); |
|
135 | - if ($raw === false) { |
|
136 | - $this->_setError('Cannot read from socket'); |
|
137 | - $this->close(); |
|
138 | - } |
|
139 | - return $raw; |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * Accessor for socket open state. |
|
144 | - * @return boolean True if open. |
|
145 | - * @access public |
|
146 | - */ |
|
147 | - function isOpen() { |
|
148 | - return $this->_is_open; |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * Closes the socket preventing further reads. |
|
153 | - * Cannot be reopened once closed. |
|
154 | - * @return boolean True if successful. |
|
155 | - * @access public |
|
156 | - */ |
|
157 | - function close() { |
|
158 | - $this->_is_open = false; |
|
159 | - return fclose($this->_handle); |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * Accessor for content so far. |
|
164 | - * @return string Bytes sent only. |
|
165 | - * @access public |
|
166 | - */ |
|
167 | - function getSent() { |
|
168 | - return $this->_sent; |
|
169 | - } |
|
170 | - |
|
171 | - /** |
|
172 | - * Actually opens the low level socket. |
|
173 | - * @param string $host Host to connect to. |
|
174 | - * @param integer $port Port on host. |
|
175 | - * @param integer $error_number Recipient of error code. |
|
176 | - * @param string $error Recipoent of error message. |
|
177 | - * @param integer $timeout Maximum time to wait for connection. |
|
178 | - * @access protected |
|
179 | - */ |
|
180 | - function _openSocket($host, $port, $error_number, $error, $timeout) { |
|
181 | - return @fsockopen($host, $port, $error_number, $error, $timeout); |
|
182 | - } |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Wrapper for TCP/IP socket over TLS. |
|
20 | + */ |
|
21 | + class SimpleStickyError { |
|
22 | + protected $_error = 'Constructor not chained'; |
|
23 | + |
|
24 | + /** |
|
25 | + * Sets the error to empty. |
|
26 | + * @access public |
|
27 | + */ |
|
28 | + function SimpleStickyError() { |
|
29 | + $this->_clearError(); |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * Test for an outstanding error. |
|
34 | + * @return boolean True if there is an error. |
|
35 | + * @access public |
|
36 | + */ |
|
37 | + function isError() { |
|
38 | + return ($this->_error != ''); |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * Accessor for an outstanding error. |
|
43 | + * @return string Empty string if no error otherwise |
|
44 | + * the error message. |
|
45 | + * @access public |
|
46 | + */ |
|
47 | + function getError() { |
|
48 | + return $this->_error; |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Sets the internal error. |
|
53 | + * @param string Error message to stash. |
|
54 | + * @access protected |
|
55 | + */ |
|
56 | + function _setError($error) { |
|
57 | + $this->_error = $error; |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Resets the error state to no error. |
|
62 | + * @access protected |
|
63 | + */ |
|
64 | + function _clearError() { |
|
65 | + $this->_setError(''); |
|
66 | + } |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * Wrapper for TCP/IP socket. |
|
187 | 71 | * @package SimpleTest |
188 | 72 | * @subpackage WebTester |
189 | - */ |
|
190 | - class SimpleSecureSocket extends SimpleSocket { |
|
191 | - |
|
192 | - /** |
|
193 | - * Opens a secure socket for reading and writing. |
|
194 | - * @param string $host Hostname to send request to. |
|
195 | - * @param integer $port Port on remote machine to open. |
|
196 | - * @param integer $timeout Connection timeout in seconds. |
|
197 | - * @access public |
|
198 | - */ |
|
199 | - function SimpleSecureSocket($host, $port, $timeout) { |
|
200 | - $this->SimpleSocket($host, $port, $timeout); |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Actually opens the low level socket. |
|
205 | - * @param string $host Host to connect to. |
|
206 | - * @param integer $port Port on host. |
|
207 | - * @param integer $error_number Recipient of error code. |
|
208 | - * @param string $error Recipient of error message. |
|
209 | - * @param integer $timeout Maximum time to wait for connection. |
|
210 | - * @access protected |
|
211 | - */ |
|
212 | - function _openSocket($host, $port, $error_number, $error, $timeout) { |
|
213 | - return parent::_openSocket("tls://$host", $port, $error_number, $error, $timeout); |
|
214 | - } |
|
215 | - } |
|
216 | 73 | \ No newline at end of file |
74 | + */ |
|
75 | + class SimpleSocket extends SimpleStickyError { |
|
76 | + protected $_handle; |
|
77 | + protected $_is_open = false; |
|
78 | + protected $_sent = ''; |
|
79 | + public $lock_size; |
|
80 | + |
|
81 | + /** |
|
82 | + * Opens a socket for reading and writing. |
|
83 | + * @param string $host Hostname to send request to. |
|
84 | + * @param integer $port Port on remote machine to open. |
|
85 | + * @param integer $timeout Connection timeout in seconds. |
|
86 | + * @param integer $block_size Size of chunk to read. |
|
87 | + * @access public |
|
88 | + */ |
|
89 | + function SimpleSocket($host, $port, $timeout, $block_size = 255) { |
|
90 | + $this->SimpleStickyError(); |
|
91 | + if (! ($this->_handle = $this->_openSocket($host, $port, $error_number, $error, $timeout))) { |
|
92 | + $this->_setError("Cannot open [$host:$port] with [$error] within [$timeout] seconds"); |
|
93 | + return; |
|
94 | + } |
|
95 | + $this->_is_open = true; |
|
96 | + $this->_block_size = $block_size; |
|
97 | + SimpleTestCompatibility::setTimeout($this->_handle, $timeout); |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Writes some data to the socket and saves alocal copy. |
|
102 | + * @param string $message String to send to socket. |
|
103 | + * @return boolean True if successful. |
|
104 | + * @access public |
|
105 | + */ |
|
106 | + function write($message) { |
|
107 | + if ($this->isError() || ! $this->isOpen()) { |
|
108 | + return false; |
|
109 | + } |
|
110 | + $count = fwrite($this->_handle, $message); |
|
111 | + if (! $count) { |
|
112 | + if ($count === false) { |
|
113 | + $this->_setError('Cannot write to socket'); |
|
114 | + $this->close(); |
|
115 | + } |
|
116 | + return false; |
|
117 | + } |
|
118 | + fflush($this->_handle); |
|
119 | + $this->_sent .= $message; |
|
120 | + return true; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Reads data from the socket. The error suppresion |
|
125 | + * is a workaround for PHP4 always throwing a warning |
|
126 | + * with a secure socket. |
|
127 | + * @return integer/boolean Incoming bytes. False |
|
128 | + * on error. |
|
129 | + * @access public |
|
130 | + */ |
|
131 | + function read() { |
|
132 | + if ($this->isError() || ! $this->isOpen()) { |
|
133 | + return false; |
|
134 | + } |
|
135 | + $raw = @fread($this->_handle, $this->_block_size); |
|
136 | + if ($raw === false) { |
|
137 | + $this->_setError('Cannot read from socket'); |
|
138 | + $this->close(); |
|
139 | + } |
|
140 | + return $raw; |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Accessor for socket open state. |
|
145 | + * @return boolean True if open. |
|
146 | + * @access public |
|
147 | + */ |
|
148 | + function isOpen() { |
|
149 | + return $this->_is_open; |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * Closes the socket preventing further reads. |
|
154 | + * Cannot be reopened once closed. |
|
155 | + * @return boolean True if successful. |
|
156 | + * @access public |
|
157 | + */ |
|
158 | + function close() { |
|
159 | + $this->_is_open = false; |
|
160 | + return fclose($this->_handle); |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Accessor for content so far. |
|
165 | + * @return string Bytes sent only. |
|
166 | + * @access public |
|
167 | + */ |
|
168 | + function getSent() { |
|
169 | + return $this->_sent; |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Actually opens the low level socket. |
|
174 | + * @param string $host Host to connect to. |
|
175 | + * @param integer $port Port on host. |
|
176 | + * @param integer $error_number Recipient of error code. |
|
177 | + * @param string $error Recipoent of error message. |
|
178 | + * @param integer $timeout Maximum time to wait for connection. |
|
179 | + * @access protected |
|
180 | + */ |
|
181 | + function _openSocket($host, $port, $error_number, $error, $timeout) { |
|
182 | + return @fsockopen($host, $port, $error_number, $error, $timeout); |
|
183 | + } |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Wrapper for TCP/IP socket over TLS. |
|
188 | + * @package SimpleTest |
|
189 | + * @subpackage WebTester |
|
190 | + */ |
|
191 | + class SimpleSecureSocket extends SimpleSocket { |
|
192 | + |
|
193 | + /** |
|
194 | + * Opens a secure socket for reading and writing. |
|
195 | + * @param string $host Hostname to send request to. |
|
196 | + * @param integer $port Port on remote machine to open. |
|
197 | + * @param integer $timeout Connection timeout in seconds. |
|
198 | + * @access public |
|
199 | + */ |
|
200 | + function SimpleSecureSocket($host, $port, $timeout) { |
|
201 | + $this->SimpleSocket($host, $port, $timeout); |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Actually opens the low level socket. |
|
206 | + * @param string $host Host to connect to. |
|
207 | + * @param integer $port Port on host. |
|
208 | + * @param integer $error_number Recipient of error code. |
|
209 | + * @param string $error Recipient of error message. |
|
210 | + * @param integer $timeout Maximum time to wait for connection. |
|
211 | + * @access protected |
|
212 | + */ |
|
213 | + function _openSocket($host, $port, $error_number, $error, $timeout) { |
|
214 | + return parent::_openSocket("tls://$host", $port, $error_number, $error, $timeout); |
|
215 | + } |
|
216 | + } |
|
217 | 217 | \ No newline at end of file |