Completed
Push — scrutinizer ( 84e9d0...6a9613 )
by Fabio
22:48
created
tests/test_tools/simpletest/tag.php 3 patches
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -112,6 +112,7 @@  discard block
 block discarded – undo
112 112
         /**
113 113
          *    Sets an attribute.
114 114
          *    @param string $label    Attribute name.
115
+         * @param string $value
115 116
          *    @return string $value   New attribute value.
116 117
          *    @access protected
117 118
          */
@@ -467,9 +468,6 @@  discard block
 block discarded – undo
467 468
         /**
468 469
          *    Dispatches the value into the form encoded packet.
469 470
          *    @param SimpleEncoding $encoding    Form packet.
470
-         *    @param integer $x                  X coordinate of click.
471
-         *    @param integer $y                  Y coordinate of click.
472
-         *    @access public
473 471
          */
474 472
         function write($encoding){//, $x, $y) {
475 473
             if ($this->getName()) {
@@ -1274,6 +1272,7 @@  discard block
 block discarded – undo
1274 1272
         /**
1275 1273
          *    Tests to see if a value is allowed.
1276 1274
          *    @param string    Attempted value.
1275
+         * @param string $value
1277 1276
          *    @return boolean  True if a valid value.
1278 1277
          *    @access private
1279 1278
          */
Please login to merge, or discard this patch.
Indentation   +1345 added lines, -1345 removed lines patch added patch discarded remove patch
@@ -1,1391 +1,1391 @@
 block discarded – undo
1 1
 <?php
2
-    /**
3
-     *	Base include file for SimpleTest.
4
-     *	@package	SimpleTest
5
-     *	@subpackage	WebTester
6
-     *	@version	$Id: tag.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: tag.php 1398 2006-09-08 19:31:03Z xue $
7
+	 */
8
+
9
+	/**#@+
10 10
      * include SimpleTest files
11 11
      */
12
-    require_once(dirname(__FILE__) . '/parser.php');
13
-    require_once(dirname(__FILE__) . '/encoding.php');
14
-    /**#@-*/
12
+	require_once(dirname(__FILE__) . '/parser.php');
13
+	require_once(dirname(__FILE__) . '/encoding.php');
14
+	/**#@-*/
15 15
 
16
-    /**
17
-     *    HTML or XML tag.
16
+	/**
17
+	 *    HTML or XML tag.
18 18
 	 *    @package SimpleTest
19 19
 	 *    @subpackage WebTester
20
-     */
21
-    class SimpleTag {
22
-        protected $_name;
23
-        protected $_attributes;
24
-        protected $_content;
25
-
26
-        /**
27
-         *    Starts with a named tag with attributes only.
28
-         *    @param string $name        Tag name.
29
-         *    @param hash $attributes    Attribute names and
30
-         *                               string values. Note that
31
-         *                               the keys must have been
32
-         *                               converted to lower case.
33
-         */
34
-        function SimpleTag($name, $attributes) {
35
-            $this->_name = strtolower(trim($name));
36
-            $this->_attributes = $attributes;
37
-            $this->_content = '';
38
-        }
39
-
40
-        /**
41
-         *    Check to see if the tag can have both start and
42
-         *    end tags with content in between.
43
-         *    @return boolean        True if content allowed.
44
-         *    @access public
45
-         */
46
-        function expectEndTag() {
47
-            return true;
48
-        }
49
-
50
-        /**
51
-         *    The current tag should not swallow all content for
52
-         *    itself as it's searchable page content. Private
53
-         *    content tags are usually widgets that contain default
54
-         *    values.
55
-         *    @return boolean        False as content is available
56
-         *                           to other tags by default.
57
-         *    @access public
58
-         */
59
-        function isPrivateContent() {
60
-            return false;
61
-        }
62
-
63
-        /**
64
-         *    Appends string content to the current content.
65
-         *    @param string $content        Additional text.
66
-         *    @access public
67
-         */
68
-        function addContent($content) {
69
-            $this->_content .= (string)$content;
70
-        }
71
-
72
-        /**
73
-         *    Adds an enclosed tag to the content.
74
-         *    @param SimpleTag $tag    New tag.
75
-         *    @access public
76
-         */
77
-        function addTag($tag) {
78
-        }
79
-
80
-        /**
81
-         *    Accessor for tag name.
82
-         *    @return string       Name of tag.
83
-         *    @access public
84
-         */
85
-        function getTagName() {
86
-            return $this->_name;
87
-        }
88
-
89
-        /**
90
-         *    List of legal child elements.
91
-         *    @return array        List of element names.
92
-         *    @access public
93
-         */
94
-        function getChildElements() {
95
-            return array();
96
-        }
97
-
98
-        /**
99
-         *    Accessor for an attribute.
100
-         *    @param string $label    Attribute name.
101
-         *    @return string          Attribute value.
102
-         *    @access public
103
-         */
104
-        function getAttribute($label) {
105
-            $label = strtolower($label);
106
-            if (! isset($this->_attributes[$label])) {
107
-                return false;
108
-            }
109
-            return (string)$this->_attributes[$label];
110
-        }
111
-
112
-        /**
113
-         *    Sets an attribute.
114
-         *    @param string $label    Attribute name.
115
-         *    @return string $value   New attribute value.
116
-         *    @access protected
117
-         */
118
-        function _setAttribute($label, $value) {
119
-            $this->_attributes[strtolower($label)] = $value;
120
-        }
121
-
122
-        /**
123
-         *    Accessor for the whole content so far.
124
-         *    @return string       Content as big raw string.
125
-         *    @access public
126
-         */
127
-        function getContent() {
128
-            return $this->_content;
129
-        }
130
-
131
-        /**
132
-         *    Accessor for content reduced to visible text. Acts
133
-         *    like a text mode browser, normalising space and
134
-         *    reducing images to their alt text.
135
-         *    @return string       Content as plain text.
136
-         *    @access public
137
-         */
138
-        function getText() {
139
-            return SimpleHtmlSaxParser::normalise($this->_content);
140
-        }
141
-
142
-        /**
143
-         *    Test to see if id attribute matches.
144
-         *    @param string $id        ID to test against.
145
-         *    @return boolean          True on match.
146
-         *    @access public
147
-         */
148
-        function isId($id) {
149
-            return ($this->getAttribute('id') == $id);
150
-        }
151
-    }
152
-
153
-    /**
154
-     *    Page title.
20
+	 */
21
+	class SimpleTag {
22
+		protected $_name;
23
+		protected $_attributes;
24
+		protected $_content;
25
+
26
+		/**
27
+		 *    Starts with a named tag with attributes only.
28
+		 *    @param string $name        Tag name.
29
+		 *    @param hash $attributes    Attribute names and
30
+		 *                               string values. Note that
31
+		 *                               the keys must have been
32
+		 *                               converted to lower case.
33
+		 */
34
+		function SimpleTag($name, $attributes) {
35
+			$this->_name = strtolower(trim($name));
36
+			$this->_attributes = $attributes;
37
+			$this->_content = '';
38
+		}
39
+
40
+		/**
41
+		 *    Check to see if the tag can have both start and
42
+		 *    end tags with content in between.
43
+		 *    @return boolean        True if content allowed.
44
+		 *    @access public
45
+		 */
46
+		function expectEndTag() {
47
+			return true;
48
+		}
49
+
50
+		/**
51
+		 *    The current tag should not swallow all content for
52
+		 *    itself as it's searchable page content. Private
53
+		 *    content tags are usually widgets that contain default
54
+		 *    values.
55
+		 *    @return boolean        False as content is available
56
+		 *                           to other tags by default.
57
+		 *    @access public
58
+		 */
59
+		function isPrivateContent() {
60
+			return false;
61
+		}
62
+
63
+		/**
64
+		 *    Appends string content to the current content.
65
+		 *    @param string $content        Additional text.
66
+		 *    @access public
67
+		 */
68
+		function addContent($content) {
69
+			$this->_content .= (string)$content;
70
+		}
71
+
72
+		/**
73
+		 *    Adds an enclosed tag to the content.
74
+		 *    @param SimpleTag $tag    New tag.
75
+		 *    @access public
76
+		 */
77
+		function addTag($tag) {
78
+		}
79
+
80
+		/**
81
+		 *    Accessor for tag name.
82
+		 *    @return string       Name of tag.
83
+		 *    @access public
84
+		 */
85
+		function getTagName() {
86
+			return $this->_name;
87
+		}
88
+
89
+		/**
90
+		 *    List of legal child elements.
91
+		 *    @return array        List of element names.
92
+		 *    @access public
93
+		 */
94
+		function getChildElements() {
95
+			return array();
96
+		}
97
+
98
+		/**
99
+		 *    Accessor for an attribute.
100
+		 *    @param string $label    Attribute name.
101
+		 *    @return string          Attribute value.
102
+		 *    @access public
103
+		 */
104
+		function getAttribute($label) {
105
+			$label = strtolower($label);
106
+			if (! isset($this->_attributes[$label])) {
107
+				return false;
108
+			}
109
+			return (string)$this->_attributes[$label];
110
+		}
111
+
112
+		/**
113
+		 *    Sets an attribute.
114
+		 *    @param string $label    Attribute name.
115
+		 *    @return string $value   New attribute value.
116
+		 *    @access protected
117
+		 */
118
+		function _setAttribute($label, $value) {
119
+			$this->_attributes[strtolower($label)] = $value;
120
+		}
121
+
122
+		/**
123
+		 *    Accessor for the whole content so far.
124
+		 *    @return string       Content as big raw string.
125
+		 *    @access public
126
+		 */
127
+		function getContent() {
128
+			return $this->_content;
129
+		}
130
+
131
+		/**
132
+		 *    Accessor for content reduced to visible text. Acts
133
+		 *    like a text mode browser, normalising space and
134
+		 *    reducing images to their alt text.
135
+		 *    @return string       Content as plain text.
136
+		 *    @access public
137
+		 */
138
+		function getText() {
139
+			return SimpleHtmlSaxParser::normalise($this->_content);
140
+		}
141
+
142
+		/**
143
+		 *    Test to see if id attribute matches.
144
+		 *    @param string $id        ID to test against.
145
+		 *    @return boolean          True on match.
146
+		 *    @access public
147
+		 */
148
+		function isId($id) {
149
+			return ($this->getAttribute('id') == $id);
150
+		}
151
+	}
152
+
153
+	/**
154
+	 *    Page title.
155 155
 	 *    @package SimpleTest
156 156
 	 *    @subpackage WebTester
157
-     */
158
-    class SimpleTitleTag extends SimpleTag {
159
-
160
-        /**
161
-         *    Starts with a named tag with attributes only.
162
-         *    @param hash $attributes    Attribute names and
163
-         *                               string values.
164
-         */
165
-        function SimpleTitleTag($attributes) {
166
-            $this->SimpleTag('title', $attributes);
167
-        }
168
-    }
169
-
170
-    /**
171
-     *    Link.
157
+	 */
158
+	class SimpleTitleTag extends SimpleTag {
159
+
160
+		/**
161
+		 *    Starts with a named tag with attributes only.
162
+		 *    @param hash $attributes    Attribute names and
163
+		 *                               string values.
164
+		 */
165
+		function SimpleTitleTag($attributes) {
166
+			$this->SimpleTag('title', $attributes);
167
+		}
168
+	}
169
+
170
+	/**
171
+	 *    Link.
172 172
 	 *    @package SimpleTest
173 173
 	 *    @subpackage WebTester
174
-     */
175
-    class SimpleAnchorTag extends SimpleTag {
176
-
177
-        /**
178
-         *    Starts with a named tag with attributes only.
179
-         *    @param hash $attributes    Attribute names and
180
-         *                               string values.
181
-         */
182
-        function SimpleAnchorTag($attributes) {
183
-            $this->SimpleTag('a', $attributes);
184
-        }
185
-
186
-        /**
187
-         *    Accessor for URL as string.
188
-         *    @return string    Coerced as string.
189
-         *    @access public
190
-         */
191
-        function getHref() {
192
-            $url = $this->getAttribute('href');
193
-            if (is_bool($url)) {
194
-                $url = '';
195
-            }
196
-            return $url;
197
-        }
198
-    }
199
-
200
-    /**
201
-     *    Form element.
174
+	 */
175
+	class SimpleAnchorTag extends SimpleTag {
176
+
177
+		/**
178
+		 *    Starts with a named tag with attributes only.
179
+		 *    @param hash $attributes    Attribute names and
180
+		 *                               string values.
181
+		 */
182
+		function SimpleAnchorTag($attributes) {
183
+			$this->SimpleTag('a', $attributes);
184
+		}
185
+
186
+		/**
187
+		 *    Accessor for URL as string.
188
+		 *    @return string    Coerced as string.
189
+		 *    @access public
190
+		 */
191
+		function getHref() {
192
+			$url = $this->getAttribute('href');
193
+			if (is_bool($url)) {
194
+				$url = '';
195
+			}
196
+			return $url;
197
+		}
198
+	}
199
+
200
+	/**
201
+	 *    Form element.
202 202
 	 *    @package SimpleTest
203 203
 	 *    @subpackage WebTester
204
-     */
205
-    class SimpleWidget extends SimpleTag {
206
-        protected $_value;
207
-        protected $_label;
208
-        protected $_is_set;
209
-
210
-        /**
211
-         *    Starts with a named tag with attributes only.
212
-         *    @param string $name        Tag name.
213
-         *    @param hash $attributes    Attribute names and
214
-         *                               string values.
215
-         */
216
-        function SimpleWidget($name, $attributes) {
217
-            $this->SimpleTag($name, $attributes);
218
-            $this->_value = false;
219
-            $this->_label = false;
220
-            $this->_is_set = false;
221
-        }
222
-
223
-        /**
224
-         *    Accessor for name submitted as the key in
225
-         *    GET/POST variables hash.
226
-         *    @return string        Parsed value.
227
-         *    @access public
228
-         */
229
-        function getName() {
230
-            return $this->getAttribute('name');
231
-        }
232
-
233
-        /**
234
-         *    Accessor for default value parsed with the tag.
235
-         *    @return string        Parsed value.
236
-         *    @access public
237
-         */
238
-        function getDefault() {
239
-            return $this->getAttribute('value');
240
-        }
241
-
242
-        /**
243
-         *    Accessor for currently set value or default if
244
-         *    none.
245
-         *    @return string      Value set by form or default
246
-         *                        if none.
247
-         *    @access public
248
-         */
249
-        function getValue() {
250
-            if (! $this->_is_set) {
251
-                return $this->getDefault();
252
-            }
253
-            return $this->_value;
254
-        }
255
-
256
-        /**
257
-         *    Sets the current form element value.
258
-         *    @param string $value       New value.
259
-         *    @return boolean            True if allowed.
260
-         *    @access public
261
-         */
262
-        function setValue($value) {
263
-            $this->_value = $value;
264
-            $this->_is_set = true;
265
-            return true;
266
-        }
267
-
268
-        /**
269
-         *    Resets the form element value back to the
270
-         *    default.
271
-         *    @access public
272
-         */
273
-        function resetValue() {
274
-            $this->_is_set = false;
275
-        }
276
-
277
-        /**
278
-         *    Allows setting of a label externally, say by a
279
-         *    label tag.
280
-         *    @param string $label    Label to attach.
281
-         *    @access public
282
-         */
283
-        function setLabel($label) {
284
-            $this->_label = trim($label);
285
-        }
286
-
287
-        /**
288
-         *    Reads external or internal label.
289
-         *    @param string $label    Label to test.
290
-         *    @return boolean         True is match.
291
-         *    @access public
292
-         */
293
-        function isLabel($label) {
294
-            return $this->_label == trim($label);
295
-        }
296
-
297
-        /**
298
-         *    Dispatches the value into the form encoded packet.
299
-         *    @param SimpleEncoding $encoding    Form packet.
300
-         *    @access public
301
-         */
302
-        function write($encoding) {
303
-            if ($this->getName()) {
304
-                $encoding->add($this->getName(), $this->getValue());
305
-            }
306
-        }
307
-    }
308
-
309
-    /**
310
-     *    Text, password and hidden field.
204
+	 */
205
+	class SimpleWidget extends SimpleTag {
206
+		protected $_value;
207
+		protected $_label;
208
+		protected $_is_set;
209
+
210
+		/**
211
+		 *    Starts with a named tag with attributes only.
212
+		 *    @param string $name        Tag name.
213
+		 *    @param hash $attributes    Attribute names and
214
+		 *                               string values.
215
+		 */
216
+		function SimpleWidget($name, $attributes) {
217
+			$this->SimpleTag($name, $attributes);
218
+			$this->_value = false;
219
+			$this->_label = false;
220
+			$this->_is_set = false;
221
+		}
222
+
223
+		/**
224
+		 *    Accessor for name submitted as the key in
225
+		 *    GET/POST variables hash.
226
+		 *    @return string        Parsed value.
227
+		 *    @access public
228
+		 */
229
+		function getName() {
230
+			return $this->getAttribute('name');
231
+		}
232
+
233
+		/**
234
+		 *    Accessor for default value parsed with the tag.
235
+		 *    @return string        Parsed value.
236
+		 *    @access public
237
+		 */
238
+		function getDefault() {
239
+			return $this->getAttribute('value');
240
+		}
241
+
242
+		/**
243
+		 *    Accessor for currently set value or default if
244
+		 *    none.
245
+		 *    @return string      Value set by form or default
246
+		 *                        if none.
247
+		 *    @access public
248
+		 */
249
+		function getValue() {
250
+			if (! $this->_is_set) {
251
+				return $this->getDefault();
252
+			}
253
+			return $this->_value;
254
+		}
255
+
256
+		/**
257
+		 *    Sets the current form element value.
258
+		 *    @param string $value       New value.
259
+		 *    @return boolean            True if allowed.
260
+		 *    @access public
261
+		 */
262
+		function setValue($value) {
263
+			$this->_value = $value;
264
+			$this->_is_set = true;
265
+			return true;
266
+		}
267
+
268
+		/**
269
+		 *    Resets the form element value back to the
270
+		 *    default.
271
+		 *    @access public
272
+		 */
273
+		function resetValue() {
274
+			$this->_is_set = false;
275
+		}
276
+
277
+		/**
278
+		 *    Allows setting of a label externally, say by a
279
+		 *    label tag.
280
+		 *    @param string $label    Label to attach.
281
+		 *    @access public
282
+		 */
283
+		function setLabel($label) {
284
+			$this->_label = trim($label);
285
+		}
286
+
287
+		/**
288
+		 *    Reads external or internal label.
289
+		 *    @param string $label    Label to test.
290
+		 *    @return boolean         True is match.
291
+		 *    @access public
292
+		 */
293
+		function isLabel($label) {
294
+			return $this->_label == trim($label);
295
+		}
296
+
297
+		/**
298
+		 *    Dispatches the value into the form encoded packet.
299
+		 *    @param SimpleEncoding $encoding    Form packet.
300
+		 *    @access public
301
+		 */
302
+		function write($encoding) {
303
+			if ($this->getName()) {
304
+				$encoding->add($this->getName(), $this->getValue());
305
+			}
306
+		}
307
+	}
308
+
309
+	/**
310
+	 *    Text, password and hidden field.
311 311
 	 *    @package SimpleTest
312 312
 	 *    @subpackage WebTester
313
-     */
314
-    class SimpleTextTag extends SimpleWidget {
315
-
316
-        /**
317
-         *    Starts with a named tag with attributes only.
318
-         *    @param hash $attributes    Attribute names and
319
-         *                               string values.
320
-         */
321
-        function SimpleTextTag($attributes) {
322
-            $this->SimpleWidget('input', $attributes);
323
-            if ($this->getAttribute('value') === false) {
324
-                $this->_setAttribute('value', '');
325
-            }
326
-        }
327
-
328
-        /**
329
-         *    Tag contains no content.
330
-         *    @return boolean        False.
331
-         *    @access public
332
-         */
333
-        function expectEndTag() {
334
-            return false;
335
-        }
336
-
337
-        /**
338
-         *    Sets the current form element value. Cannot
339
-         *    change the value of a hidden field.
340
-         *    @param string $value       New value.
341
-         *    @return boolean            True if allowed.
342
-         *    @access public
343
-         */
344
-        function setValue($value) {
345
-            if ($this->getAttribute('type') == 'hidden') {
346
-                return false;
347
-            }
348
-            return parent::setValue($value);
349
-        }
350
-    }
351
-
352
-    /**
353
-     *    Submit button as input tag.
313
+	 */
314
+	class SimpleTextTag extends SimpleWidget {
315
+
316
+		/**
317
+		 *    Starts with a named tag with attributes only.
318
+		 *    @param hash $attributes    Attribute names and
319
+		 *                               string values.
320
+		 */
321
+		function SimpleTextTag($attributes) {
322
+			$this->SimpleWidget('input', $attributes);
323
+			if ($this->getAttribute('value') === false) {
324
+				$this->_setAttribute('value', '');
325
+			}
326
+		}
327
+
328
+		/**
329
+		 *    Tag contains no content.
330
+		 *    @return boolean        False.
331
+		 *    @access public
332
+		 */
333
+		function expectEndTag() {
334
+			return false;
335
+		}
336
+
337
+		/**
338
+		 *    Sets the current form element value. Cannot
339
+		 *    change the value of a hidden field.
340
+		 *    @param string $value       New value.
341
+		 *    @return boolean            True if allowed.
342
+		 *    @access public
343
+		 */
344
+		function setValue($value) {
345
+			if ($this->getAttribute('type') == 'hidden') {
346
+				return false;
347
+			}
348
+			return parent::setValue($value);
349
+		}
350
+	}
351
+
352
+	/**
353
+	 *    Submit button as input tag.
354 354
 	 *    @package SimpleTest
355 355
 	 *    @subpackage WebTester
356
-     */
357
-    class SimpleSubmitTag extends SimpleWidget {
358
-
359
-        /**
360
-         *    Starts with a named tag with attributes only.
361
-         *    @param hash $attributes    Attribute names and
362
-         *                               string values.
363
-         */
364
-        function SimpleSubmitTag($attributes) {
365
-            $this->SimpleWidget('input', $attributes);
366
-            if ($this->getAttribute('value') === false) {
367
-                $this->_setAttribute('value', 'Submit');
368
-            }
369
-        }
370
-
371
-        /**
372
-         *    Tag contains no end element.
373
-         *    @return boolean        False.
374
-         *    @access public
375
-         */
376
-        function expectEndTag() {
377
-            return false;
378
-        }
379
-
380
-        /**
381
-         *    Disables the setting of the button value.
382
-         *    @param string $value       Ignored.
383
-         *    @return boolean            True if allowed.
384
-         *    @access public
385
-         */
386
-        function setValue($value) {
387
-            return false;
388
-        }
389
-
390
-        /**
391
-         *    Value of browser visible text.
392
-         *    @return string        Visible label.
393
-         *    @access public
394
-         */
395
-        function getLabel() {
396
-            return $this->getValue();
397
-        }
398
-
399
-        /**
400
-         *    Test for a label match when searching.
401
-         *    @param string $label     Label to test.
402
-         *    @return boolean          True on match.
403
-         *    @access public
404
-         */
405
-        function isLabel($label) {
406
-            return trim($label) == trim($this->getLabel());
407
-        }
408
-    }
409
-
410
-    /**
411
-     *    Image button as input tag.
356
+	 */
357
+	class SimpleSubmitTag extends SimpleWidget {
358
+
359
+		/**
360
+		 *    Starts with a named tag with attributes only.
361
+		 *    @param hash $attributes    Attribute names and
362
+		 *                               string values.
363
+		 */
364
+		function SimpleSubmitTag($attributes) {
365
+			$this->SimpleWidget('input', $attributes);
366
+			if ($this->getAttribute('value') === false) {
367
+				$this->_setAttribute('value', 'Submit');
368
+			}
369
+		}
370
+
371
+		/**
372
+		 *    Tag contains no end element.
373
+		 *    @return boolean        False.
374
+		 *    @access public
375
+		 */
376
+		function expectEndTag() {
377
+			return false;
378
+		}
379
+
380
+		/**
381
+		 *    Disables the setting of the button value.
382
+		 *    @param string $value       Ignored.
383
+		 *    @return boolean            True if allowed.
384
+		 *    @access public
385
+		 */
386
+		function setValue($value) {
387
+			return false;
388
+		}
389
+
390
+		/**
391
+		 *    Value of browser visible text.
392
+		 *    @return string        Visible label.
393
+		 *    @access public
394
+		 */
395
+		function getLabel() {
396
+			return $this->getValue();
397
+		}
398
+
399
+		/**
400
+		 *    Test for a label match when searching.
401
+		 *    @param string $label     Label to test.
402
+		 *    @return boolean          True on match.
403
+		 *    @access public
404
+		 */
405
+		function isLabel($label) {
406
+			return trim($label) == trim($this->getLabel());
407
+		}
408
+	}
409
+
410
+	/**
411
+	 *    Image button as input tag.
412 412
 	 *    @package SimpleTest
413 413
 	 *    @subpackage WebTester
414
-     */
415
-    class SimpleImageSubmitTag extends SimpleWidget {
416
-
417
-        /**
418
-         *    Starts with a named tag with attributes only.
419
-         *    @param hash $attributes    Attribute names and
420
-         *                               string values.
421
-         */
422
-        function SimpleImageSubmitTag($attributes) {
423
-            $this->SimpleWidget('input', $attributes);
424
-        }
425
-
426
-        /**
427
-         *    Tag contains no end element.
428
-         *    @return boolean        False.
429
-         *    @access public
430
-         */
431
-        function expectEndTag() {
432
-            return false;
433
-        }
434
-
435
-        /**
436
-         *    Disables the setting of the button value.
437
-         *    @param string $value       Ignored.
438
-         *    @return boolean            True if allowed.
439
-         *    @access public
440
-         */
441
-        function setValue($value) {
442
-            return false;
443
-        }
444
-
445
-        /**
446
-         *    Value of browser visible text.
447
-         *    @return string        Visible label.
448
-         *    @access public
449
-         */
450
-        function getLabel() {
451
-            if ($this->getAttribute('title')) {
452
-                return $this->getAttribute('title');
453
-            }
454
-            return $this->getAttribute('alt');
455
-        }
456
-
457
-        /**
458
-         *    Test for a label match when searching.
459
-         *    @param string $label     Label to test.
460
-         *    @return boolean          True on match.
461
-         *    @access public
462
-         */
463
-        function isLabel($label) {
464
-            return trim($label) == trim($this->getLabel());
465
-        }
466
-
467
-        /**
468
-         *    Dispatches the value into the form encoded packet.
469
-         *    @param SimpleEncoding $encoding    Form packet.
470
-         *    @param integer $x                  X coordinate of click.
471
-         *    @param integer $y                  Y coordinate of click.
472
-         *    @access public
473
-         */
474
-        function write($encoding){//, $x, $y) {
475
-            if ($this->getName()) {
476
-                $encoding->add($this->getName() . '.x', $x);
477
-                $encoding->add($this->getName() . '.y', $y);
478
-            } else {
479
-                $encoding->add('x', $x);
480
-                $encoding->add('y', $y);
481
-            }
482
-        }
483
-    }
484
-
485
-    /**
486
-     *    Submit button as button tag.
414
+	 */
415
+	class SimpleImageSubmitTag extends SimpleWidget {
416
+
417
+		/**
418
+		 *    Starts with a named tag with attributes only.
419
+		 *    @param hash $attributes    Attribute names and
420
+		 *                               string values.
421
+		 */
422
+		function SimpleImageSubmitTag($attributes) {
423
+			$this->SimpleWidget('input', $attributes);
424
+		}
425
+
426
+		/**
427
+		 *    Tag contains no end element.
428
+		 *    @return boolean        False.
429
+		 *    @access public
430
+		 */
431
+		function expectEndTag() {
432
+			return false;
433
+		}
434
+
435
+		/**
436
+		 *    Disables the setting of the button value.
437
+		 *    @param string $value       Ignored.
438
+		 *    @return boolean            True if allowed.
439
+		 *    @access public
440
+		 */
441
+		function setValue($value) {
442
+			return false;
443
+		}
444
+
445
+		/**
446
+		 *    Value of browser visible text.
447
+		 *    @return string        Visible label.
448
+		 *    @access public
449
+		 */
450
+		function getLabel() {
451
+			if ($this->getAttribute('title')) {
452
+				return $this->getAttribute('title');
453
+			}
454
+			return $this->getAttribute('alt');
455
+		}
456
+
457
+		/**
458
+		 *    Test for a label match when searching.
459
+		 *    @param string $label     Label to test.
460
+		 *    @return boolean          True on match.
461
+		 *    @access public
462
+		 */
463
+		function isLabel($label) {
464
+			return trim($label) == trim($this->getLabel());
465
+		}
466
+
467
+		/**
468
+		 *    Dispatches the value into the form encoded packet.
469
+		 *    @param SimpleEncoding $encoding    Form packet.
470
+		 *    @param integer $x                  X coordinate of click.
471
+		 *    @param integer $y                  Y coordinate of click.
472
+		 *    @access public
473
+		 */
474
+		function write($encoding){//, $x, $y) {
475
+			if ($this->getName()) {
476
+				$encoding->add($this->getName() . '.x', $x);
477
+				$encoding->add($this->getName() . '.y', $y);
478
+			} else {
479
+				$encoding->add('x', $x);
480
+				$encoding->add('y', $y);
481
+			}
482
+		}
483
+	}
484
+
485
+	/**
486
+	 *    Submit button as button tag.
487 487
 	 *    @package SimpleTest
488 488
 	 *    @subpackage WebTester
489
-     */
490
-    class SimpleButtonTag extends SimpleWidget {
491
-
492
-        /**
493
-         *    Starts with a named tag with attributes only.
494
-         *    Defaults are very browser dependent.
495
-         *    @param hash $attributes    Attribute names and
496
-         *                               string values.
497
-         */
498
-        function SimpleButtonTag($attributes) {
499
-            $this->SimpleWidget('button', $attributes);
500
-        }
501
-
502
-        /**
503
-         *    Check to see if the tag can have both start and
504
-         *    end tags with content in between.
505
-         *    @return boolean        True if content allowed.
506
-         *    @access public
507
-         */
508
-        function expectEndTag() {
509
-            return true;
510
-        }
511
-
512
-        /**
513
-         *    Disables the setting of the button value.
514
-         *    @param string $value       Ignored.
515
-         *    @return boolean            True if allowed.
516
-         *    @access public
517
-         */
518
-        function setValue($value) {
519
-            return false;
520
-        }
521
-
522
-        /**
523
-         *    Value of browser visible text.
524
-         *    @return string        Visible label.
525
-         *    @access public
526
-         */
527
-        function getLabel() {
528
-            return $this->getContent();
529
-        }
530
-
531
-        /**
532
-         *    Test for a label match when searching.
533
-         *    @param string $label     Label to test.
534
-         *    @return boolean          True on match.
535
-         *    @access public
536
-         */
537
-        function isLabel($label) {
538
-            return trim($label) == trim($this->getLabel());
539
-        }
540
-    }
541
-
542
-    /**
543
-     *    Content tag for text area.
489
+	 */
490
+	class SimpleButtonTag extends SimpleWidget {
491
+
492
+		/**
493
+		 *    Starts with a named tag with attributes only.
494
+		 *    Defaults are very browser dependent.
495
+		 *    @param hash $attributes    Attribute names and
496
+		 *                               string values.
497
+		 */
498
+		function SimpleButtonTag($attributes) {
499
+			$this->SimpleWidget('button', $attributes);
500
+		}
501
+
502
+		/**
503
+		 *    Check to see if the tag can have both start and
504
+		 *    end tags with content in between.
505
+		 *    @return boolean        True if content allowed.
506
+		 *    @access public
507
+		 */
508
+		function expectEndTag() {
509
+			return true;
510
+		}
511
+
512
+		/**
513
+		 *    Disables the setting of the button value.
514
+		 *    @param string $value       Ignored.
515
+		 *    @return boolean            True if allowed.
516
+		 *    @access public
517
+		 */
518
+		function setValue($value) {
519
+			return false;
520
+		}
521
+
522
+		/**
523
+		 *    Value of browser visible text.
524
+		 *    @return string        Visible label.
525
+		 *    @access public
526
+		 */
527
+		function getLabel() {
528
+			return $this->getContent();
529
+		}
530
+
531
+		/**
532
+		 *    Test for a label match when searching.
533
+		 *    @param string $label     Label to test.
534
+		 *    @return boolean          True on match.
535
+		 *    @access public
536
+		 */
537
+		function isLabel($label) {
538
+			return trim($label) == trim($this->getLabel());
539
+		}
540
+	}
541
+
542
+	/**
543
+	 *    Content tag for text area.
544 544
 	 *    @package SimpleTest
545 545
 	 *    @subpackage WebTester
546
-     */
547
-    class SimpleTextAreaTag extends SimpleWidget {
548
-
549
-        /**
550
-         *    Starts with a named tag with attributes only.
551
-         *    @param hash $attributes    Attribute names and
552
-         *                               string values.
553
-         */
554
-        function SimpleTextAreaTag($attributes) {
555
-            $this->SimpleWidget('textarea', $attributes);
556
-        }
557
-
558
-        /**
559
-         *    Accessor for starting value.
560
-         *    @return string        Parsed value.
561
-         *    @access public
562
-         */
563
-        function getDefault() {
564
-            return $this->_wrap(SimpleHtmlSaxParser::decodeHtml($this->getContent()));
565
-        }
566
-
567
-        /**
568
-         *    Applies word wrapping if needed.
569
-         *    @param string $value      New value.
570
-         *    @return boolean            True if allowed.
571
-         *    @access public
572
-         */
573
-        function setValue($value) {
574
-            return parent::setValue($this->_wrap($value));
575
-        }
576
-
577
-        /**
578
-         *    Test to see if text should be wrapped.
579
-         *    @return boolean        True if wrapping on.
580
-         *    @access private
581
-         */
582
-        function _wrapIsEnabled() {
583
-            if ($this->getAttribute('cols')) {
584
-                $wrap = $this->getAttribute('wrap');
585
-                if (($wrap == 'physical') || ($wrap == 'hard')) {
586
-                    return true;
587
-                }
588
-            }
589
-            return false;
590
-        }
591
-
592
-        /**
593
-         *    Performs the formatting that is peculiar to
594
-         *    this tag. There is strange behaviour in this
595
-         *    one, including stripping a leading new line.
596
-         *    Go figure. I am using Firefox as a guide.
597
-         *    @param string $text    Text to wrap.
598
-         *    @return string         Text wrapped with carriage
599
-         *                           returns and line feeds
600
-         *    @access private
601
-         */
602
-        function _wrap($text) {
603
-            $text = str_replace("\r\r\n", "\r\n", str_replace("\n", "\r\n", $text));
604
-            $text = str_replace("\r\n\n", "\r\n", str_replace("\r", "\r\n", $text));
605
-            if (strncmp($text, "\r\n", strlen("\r\n")) == 0) {
606
-                $text = substr($text, strlen("\r\n"));
607
-            }
608
-            if ($this->_wrapIsEnabled()) {
609
-                return wordwrap(
610
-                        $text,
611
-                        (integer)$this->getAttribute('cols'),
612
-                        "\r\n");
613
-            }
614
-            return $text;
615
-        }
616
-
617
-        /**
618
-         *    The content of textarea is not part of the page.
619
-         *    @return boolean        True.
620
-         *    @access public
621
-         */
622
-        function isPrivateContent() {
623
-            return true;
624
-        }
625
-    }
626
-
627
-    /**
628
-     *    File upload widget.
546
+	 */
547
+	class SimpleTextAreaTag extends SimpleWidget {
548
+
549
+		/**
550
+		 *    Starts with a named tag with attributes only.
551
+		 *    @param hash $attributes    Attribute names and
552
+		 *                               string values.
553
+		 */
554
+		function SimpleTextAreaTag($attributes) {
555
+			$this->SimpleWidget('textarea', $attributes);
556
+		}
557
+
558
+		/**
559
+		 *    Accessor for starting value.
560
+		 *    @return string        Parsed value.
561
+		 *    @access public
562
+		 */
563
+		function getDefault() {
564
+			return $this->_wrap(SimpleHtmlSaxParser::decodeHtml($this->getContent()));
565
+		}
566
+
567
+		/**
568
+		 *    Applies word wrapping if needed.
569
+		 *    @param string $value      New value.
570
+		 *    @return boolean            True if allowed.
571
+		 *    @access public
572
+		 */
573
+		function setValue($value) {
574
+			return parent::setValue($this->_wrap($value));
575
+		}
576
+
577
+		/**
578
+		 *    Test to see if text should be wrapped.
579
+		 *    @return boolean        True if wrapping on.
580
+		 *    @access private
581
+		 */
582
+		function _wrapIsEnabled() {
583
+			if ($this->getAttribute('cols')) {
584
+				$wrap = $this->getAttribute('wrap');
585
+				if (($wrap == 'physical') || ($wrap == 'hard')) {
586
+					return true;
587
+				}
588
+			}
589
+			return false;
590
+		}
591
+
592
+		/**
593
+		 *    Performs the formatting that is peculiar to
594
+		 *    this tag. There is strange behaviour in this
595
+		 *    one, including stripping a leading new line.
596
+		 *    Go figure. I am using Firefox as a guide.
597
+		 *    @param string $text    Text to wrap.
598
+		 *    @return string         Text wrapped with carriage
599
+		 *                           returns and line feeds
600
+		 *    @access private
601
+		 */
602
+		function _wrap($text) {
603
+			$text = str_replace("\r\r\n", "\r\n", str_replace("\n", "\r\n", $text));
604
+			$text = str_replace("\r\n\n", "\r\n", str_replace("\r", "\r\n", $text));
605
+			if (strncmp($text, "\r\n", strlen("\r\n")) == 0) {
606
+				$text = substr($text, strlen("\r\n"));
607
+			}
608
+			if ($this->_wrapIsEnabled()) {
609
+				return wordwrap(
610
+						$text,
611
+						(integer)$this->getAttribute('cols'),
612
+						"\r\n");
613
+			}
614
+			return $text;
615
+		}
616
+
617
+		/**
618
+		 *    The content of textarea is not part of the page.
619
+		 *    @return boolean        True.
620
+		 *    @access public
621
+		 */
622
+		function isPrivateContent() {
623
+			return true;
624
+		}
625
+	}
626
+
627
+	/**
628
+	 *    File upload widget.
629 629
 	 *    @package SimpleTest
630 630
 	 *    @subpackage WebTester
631
-     */
632
-    class SimpleUploadTag extends SimpleWidget {
633
-
634
-        /**
635
-         *    Starts with attributes only.
636
-         *    @param hash $attributes    Attribute names and
637
-         *                               string values.
638
-         */
639
-        function SimpleUploadTag($attributes) {
640
-            $this->SimpleWidget('input', $attributes);
641
-        }
642
-
643
-        /**
644
-         *    Tag contains no content.
645
-         *    @return boolean        False.
646
-         *    @access public
647
-         */
648
-        function expectEndTag() {
649
-            return false;
650
-        }
651
-
652
-        /**
653
-         *    Dispatches the value into the form encoded packet.
654
-         *    @param SimpleEncoding $encoding    Form packet.
655
-         *    @access public
656
-         */
657
-        function write($encoding) {
658
-            if (! file_exists($this->getValue())) {
659
-                return;
660
-            }
661
-            $encoding->attach(
662
-                    $this->getName(),
663
-                    implode('', file($this->getValue())),
664
-                    basename($this->getValue()));
665
-        }
666
-    }
667
-
668
-    /**
669
-     *    Drop down widget.
631
+	 */
632
+	class SimpleUploadTag extends SimpleWidget {
633
+
634
+		/**
635
+		 *    Starts with attributes only.
636
+		 *    @param hash $attributes    Attribute names and
637
+		 *                               string values.
638
+		 */
639
+		function SimpleUploadTag($attributes) {
640
+			$this->SimpleWidget('input', $attributes);
641
+		}
642
+
643
+		/**
644
+		 *    Tag contains no content.
645
+		 *    @return boolean        False.
646
+		 *    @access public
647
+		 */
648
+		function expectEndTag() {
649
+			return false;
650
+		}
651
+
652
+		/**
653
+		 *    Dispatches the value into the form encoded packet.
654
+		 *    @param SimpleEncoding $encoding    Form packet.
655
+		 *    @access public
656
+		 */
657
+		function write($encoding) {
658
+			if (! file_exists($this->getValue())) {
659
+				return;
660
+			}
661
+			$encoding->attach(
662
+					$this->getName(),
663
+					implode('', file($this->getValue())),
664
+					basename($this->getValue()));
665
+		}
666
+	}
667
+
668
+	/**
669
+	 *    Drop down widget.
670 670
 	 *    @package SimpleTest
671 671
 	 *    @subpackage WebTester
672
-     */
673
-    class SimpleSelectionTag extends SimpleWidget {
674
-        protected $_options;
675
-        protected $_choice;
676
-
677
-        /**
678
-         *    Starts with attributes only.
679
-         *    @param hash $attributes    Attribute names and
680
-         *                               string values.
681
-         */
682
-        function SimpleSelectionTag($attributes) {
683
-            $this->SimpleWidget('select', $attributes);
684
-            $this->_options = array();
685
-            $this->_choice = false;
686
-        }
687
-
688
-        /**
689
-         *    Adds an option tag to a selection field.
690
-         *    @param SimpleOptionTag $tag     New option.
691
-         *    @access public
692
-         */
693
-        function addTag($tag) {
694
-            if ($tag->getTagName() == 'option') {
695
-                $this->_options[] = $tag;
696
-            }
697
-        }
698
-
699
-        /**
700
-         *    Text within the selection element is ignored.
701
-         *    @param string $content        Ignored.
702
-         *    @access public
703
-         */
704
-        function addContent($content) {
705
-        }
706
-
707
-        /**
708
-         *    Scans options for defaults. If none, then
709
-         *    the first option is selected.
710
-         *    @return string        Selected field.
711
-         *    @access public
712
-         */
713
-        function getDefault() {
714
-            for ($i = 0, $count = count($this->_options); $i < $count; $i++) {
715
-                if ($this->_options[$i]->getAttribute('selected') !== false) {
716
-                    return $this->_options[$i]->getDefault();
717
-                }
718
-            }
719
-            if ($count > 0) {
720
-                return $this->_options[0]->getDefault();
721
-            }
722
-            return '';
723
-        }
724
-
725
-        /**
726
-         *    Can only set allowed values.
727
-         *    @param string $value       New choice.
728
-         *    @return boolean            True if allowed.
729
-         *    @access public
730
-         */
731
-        function setValue($value) {
732
-            for ($i = 0, $count = count($this->_options); $i < $count; $i++) {
733
-                if ($this->_options[$i]->isValue($value)) {
734
-                    $this->_choice = $i;
735
-                    return true;
736
-                }
737
-            }
738
-            return false;
739
-        }
740
-
741
-        /**
742
-         *    Accessor for current selection value.
743
-         *    @return string      Value attribute or
744
-         *                        content of opton.
745
-         *    @access public
746
-         */
747
-        function getValue() {
748
-            if ($this->_choice === false) {
749
-                return $this->getDefault();
750
-            }
751
-            return $this->_options[$this->_choice]->getValue();
752
-        }
753
-    }
754
-
755
-    /**
756
-     *    Drop down widget.
672
+	 */
673
+	class SimpleSelectionTag extends SimpleWidget {
674
+		protected $_options;
675
+		protected $_choice;
676
+
677
+		/**
678
+		 *    Starts with attributes only.
679
+		 *    @param hash $attributes    Attribute names and
680
+		 *                               string values.
681
+		 */
682
+		function SimpleSelectionTag($attributes) {
683
+			$this->SimpleWidget('select', $attributes);
684
+			$this->_options = array();
685
+			$this->_choice = false;
686
+		}
687
+
688
+		/**
689
+		 *    Adds an option tag to a selection field.
690
+		 *    @param SimpleOptionTag $tag     New option.
691
+		 *    @access public
692
+		 */
693
+		function addTag($tag) {
694
+			if ($tag->getTagName() == 'option') {
695
+				$this->_options[] = $tag;
696
+			}
697
+		}
698
+
699
+		/**
700
+		 *    Text within the selection element is ignored.
701
+		 *    @param string $content        Ignored.
702
+		 *    @access public
703
+		 */
704
+		function addContent($content) {
705
+		}
706
+
707
+		/**
708
+		 *    Scans options for defaults. If none, then
709
+		 *    the first option is selected.
710
+		 *    @return string        Selected field.
711
+		 *    @access public
712
+		 */
713
+		function getDefault() {
714
+			for ($i = 0, $count = count($this->_options); $i < $count; $i++) {
715
+				if ($this->_options[$i]->getAttribute('selected') !== false) {
716
+					return $this->_options[$i]->getDefault();
717
+				}
718
+			}
719
+			if ($count > 0) {
720
+				return $this->_options[0]->getDefault();
721
+			}
722
+			return '';
723
+		}
724
+
725
+		/**
726
+		 *    Can only set allowed values.
727
+		 *    @param string $value       New choice.
728
+		 *    @return boolean            True if allowed.
729
+		 *    @access public
730
+		 */
731
+		function setValue($value) {
732
+			for ($i = 0, $count = count($this->_options); $i < $count; $i++) {
733
+				if ($this->_options[$i]->isValue($value)) {
734
+					$this->_choice = $i;
735
+					return true;
736
+				}
737
+			}
738
+			return false;
739
+		}
740
+
741
+		/**
742
+		 *    Accessor for current selection value.
743
+		 *    @return string      Value attribute or
744
+		 *                        content of opton.
745
+		 *    @access public
746
+		 */
747
+		function getValue() {
748
+			if ($this->_choice === false) {
749
+				return $this->getDefault();
750
+			}
751
+			return $this->_options[$this->_choice]->getValue();
752
+		}
753
+	}
754
+
755
+	/**
756
+	 *    Drop down widget.
757 757
 	 *    @package SimpleTest
758 758
 	 *    @subpackage WebTester
759
-     */
760
-    class MultipleSelectionTag extends SimpleWidget {
761
-        protected $_options;
762
-        protected $_values;
763
-
764
-        /**
765
-         *    Starts with attributes only.
766
-         *    @param hash $attributes    Attribute names and
767
-         *                               string values.
768
-         */
769
-        function MultipleSelectionTag($attributes) {
770
-            $this->SimpleWidget('select', $attributes);
771
-            $this->_options = array();
772
-            $this->_values = false;
773
-        }
774
-
775
-        /**
776
-         *    Adds an option tag to a selection field.
777
-         *    @param SimpleOptionTag $tag     New option.
778
-         *    @access public
779
-         */
780
-        function addTag($tag) {
781
-            if ($tag->getTagName() == 'option') {
782
-                $this->_options[] = $tag;
783
-            }
784
-        }
785
-
786
-        /**
787
-         *    Text within the selection element is ignored.
788
-         *    @param string $content        Ignored.
789
-         *    @access public
790
-         */
791
-        function addContent($content) {
792
-        }
793
-
794
-        /**
795
-         *    Scans options for defaults to populate the
796
-         *    value array().
797
-         *    @return array        Selected fields.
798
-         *    @access public
799
-         */
800
-        function getDefault() {
801
-            $default = array();
802
-            for ($i = 0, $count = count($this->_options); $i < $count; $i++) {
803
-                if ($this->_options[$i]->getAttribute('selected') !== false) {
804
-                    $default[] = $this->_options[$i]->getDefault();
805
-                }
806
-            }
807
-            return $default;
808
-        }
809
-
810
-        /**
811
-         *    Can only set allowed values. Any illegal value
812
-         *    will result in a failure, but all correct values
813
-         *    will be set.
814
-         *    @param array $desired      New choices.
815
-         *    @return boolean            True if all allowed.
816
-         *    @access public
817
-         */
818
-        function setValue($desired) {
819
-            $achieved = array();
820
-            foreach ($desired as $value) {
821
-                $success = false;
822
-                for ($i = 0, $count = count($this->_options); $i < $count; $i++) {
823
-                    if ($this->_options[$i]->isValue($value)) {
824
-                        $achieved[] = $this->_options[$i]->getValue();
825
-                        $success = true;
826
-                        break;
827
-                    }
828
-                }
829
-                if (! $success) {
830
-                    return false;
831
-                }
832
-            }
833
-            $this->_values = $achieved;
834
-            return true;
835
-        }
836
-
837
-        /**
838
-         *    Accessor for current selection value.
839
-         *    @return array      List of currently set options.
840
-         *    @access public
841
-         */
842
-        function getValue() {
843
-            if ($this->_values === false) {
844
-                return $this->getDefault();
845
-            }
846
-            return $this->_values;
847
-        }
848
-    }
849
-
850
-    /**
851
-     *    Option for selection field.
759
+	 */
760
+	class MultipleSelectionTag extends SimpleWidget {
761
+		protected $_options;
762
+		protected $_values;
763
+
764
+		/**
765
+		 *    Starts with attributes only.
766
+		 *    @param hash $attributes    Attribute names and
767
+		 *                               string values.
768
+		 */
769
+		function MultipleSelectionTag($attributes) {
770
+			$this->SimpleWidget('select', $attributes);
771
+			$this->_options = array();
772
+			$this->_values = false;
773
+		}
774
+
775
+		/**
776
+		 *    Adds an option tag to a selection field.
777
+		 *    @param SimpleOptionTag $tag     New option.
778
+		 *    @access public
779
+		 */
780
+		function addTag($tag) {
781
+			if ($tag->getTagName() == 'option') {
782
+				$this->_options[] = $tag;
783
+			}
784
+		}
785
+
786
+		/**
787
+		 *    Text within the selection element is ignored.
788
+		 *    @param string $content        Ignored.
789
+		 *    @access public
790
+		 */
791
+		function addContent($content) {
792
+		}
793
+
794
+		/**
795
+		 *    Scans options for defaults to populate the
796
+		 *    value array().
797
+		 *    @return array        Selected fields.
798
+		 *    @access public
799
+		 */
800
+		function getDefault() {
801
+			$default = array();
802
+			for ($i = 0, $count = count($this->_options); $i < $count; $i++) {
803
+				if ($this->_options[$i]->getAttribute('selected') !== false) {
804
+					$default[] = $this->_options[$i]->getDefault();
805
+				}
806
+			}
807
+			return $default;
808
+		}
809
+
810
+		/**
811
+		 *    Can only set allowed values. Any illegal value
812
+		 *    will result in a failure, but all correct values
813
+		 *    will be set.
814
+		 *    @param array $desired      New choices.
815
+		 *    @return boolean            True if all allowed.
816
+		 *    @access public
817
+		 */
818
+		function setValue($desired) {
819
+			$achieved = array();
820
+			foreach ($desired as $value) {
821
+				$success = false;
822
+				for ($i = 0, $count = count($this->_options); $i < $count; $i++) {
823
+					if ($this->_options[$i]->isValue($value)) {
824
+						$achieved[] = $this->_options[$i]->getValue();
825
+						$success = true;
826
+						break;
827
+					}
828
+				}
829
+				if (! $success) {
830
+					return false;
831
+				}
832
+			}
833
+			$this->_values = $achieved;
834
+			return true;
835
+		}
836
+
837
+		/**
838
+		 *    Accessor for current selection value.
839
+		 *    @return array      List of currently set options.
840
+		 *    @access public
841
+		 */
842
+		function getValue() {
843
+			if ($this->_values === false) {
844
+				return $this->getDefault();
845
+			}
846
+			return $this->_values;
847
+		}
848
+	}
849
+
850
+	/**
851
+	 *    Option for selection field.
852 852
 	 *    @package SimpleTest
853 853
 	 *    @subpackage WebTester
854
-     */
855
-    class SimpleOptionTag extends SimpleWidget {
856
-
857
-        /**
858
-         *    Stashes the attributes.
859
-         */
860
-        function SimpleOptionTag($attributes) {
861
-            $this->SimpleWidget('option', $attributes);
862
-        }
863
-
864
-        /**
865
-         *    Does nothing.
866
-         *    @param string $value      Ignored.
867
-         *    @return boolean           Not allowed.
868
-         *    @access public
869
-         */
870
-        function setValue($value) {
871
-            return false;
872
-        }
873
-
874
-        /**
875
-         *    Test to see if a value matches the option.
876
-         *    @param string $compare    Value to compare with.
877
-         *    @return boolean           True if possible match.
878
-         *    @access public
879
-         */
880
-        function isValue($compare) {
881
-            $compare = trim($compare);
882
-            if (trim($this->getValue()) == $compare) {
883
-                return true;
884
-            }
885
-            return trim($this->getContent()) == $compare;
886
-        }
887
-
888
-        /**
889
-         *    Accessor for starting value. Will be set to
890
-         *    the option label if no value exists.
891
-         *    @return string        Parsed value.
892
-         *    @access public
893
-         */
894
-        function getDefault() {
895
-            if ($this->getAttribute('value') === false) {
896
-                return $this->getContent();
897
-            }
898
-            return $this->getAttribute('value');
899
-        }
900
-
901
-        /**
902
-         *    The content of options is not part of the page.
903
-         *    @return boolean        True.
904
-         *    @access public
905
-         */
906
-        function isPrivateContent() {
907
-            return true;
908
-        }
909
-    }
910
-
911
-    /**
912
-     *    Radio button.
854
+	 */
855
+	class SimpleOptionTag extends SimpleWidget {
856
+
857
+		/**
858
+		 *    Stashes the attributes.
859
+		 */
860
+		function SimpleOptionTag($attributes) {
861
+			$this->SimpleWidget('option', $attributes);
862
+		}
863
+
864
+		/**
865
+		 *    Does nothing.
866
+		 *    @param string $value      Ignored.
867
+		 *    @return boolean           Not allowed.
868
+		 *    @access public
869
+		 */
870
+		function setValue($value) {
871
+			return false;
872
+		}
873
+
874
+		/**
875
+		 *    Test to see if a value matches the option.
876
+		 *    @param string $compare    Value to compare with.
877
+		 *    @return boolean           True if possible match.
878
+		 *    @access public
879
+		 */
880
+		function isValue($compare) {
881
+			$compare = trim($compare);
882
+			if (trim($this->getValue()) == $compare) {
883
+				return true;
884
+			}
885
+			return trim($this->getContent()) == $compare;
886
+		}
887
+
888
+		/**
889
+		 *    Accessor for starting value. Will be set to
890
+		 *    the option label if no value exists.
891
+		 *    @return string        Parsed value.
892
+		 *    @access public
893
+		 */
894
+		function getDefault() {
895
+			if ($this->getAttribute('value') === false) {
896
+				return $this->getContent();
897
+			}
898
+			return $this->getAttribute('value');
899
+		}
900
+
901
+		/**
902
+		 *    The content of options is not part of the page.
903
+		 *    @return boolean        True.
904
+		 *    @access public
905
+		 */
906
+		function isPrivateContent() {
907
+			return true;
908
+		}
909
+	}
910
+
911
+	/**
912
+	 *    Radio button.
913 913
 	 *    @package SimpleTest
914 914
 	 *    @subpackage WebTester
915
-     */
916
-    class SimpleRadioButtonTag extends SimpleWidget {
917
-
918
-        /**
919
-         *    Stashes the attributes.
920
-         *    @param array $attributes        Hash of attributes.
921
-         */
922
-        function SimpleRadioButtonTag($attributes) {
923
-            $this->SimpleWidget('input', $attributes);
924
-            if ($this->getAttribute('value') === false) {
925
-                $this->_setAttribute('value', 'on');
926
-            }
927
-        }
928
-
929
-        /**
930
-         *    Tag contains no content.
931
-         *    @return boolean        False.
932
-         *    @access public
933
-         */
934
-        function expectEndTag() {
935
-            return false;
936
-        }
937
-
938
-        /**
939
-         *    The only allowed value sn the one in the
940
-         *    "value" attribute.
941
-         *    @param string $value      New value.
942
-         *    @return boolean           True if allowed.
943
-         *    @access public
944
-         */
945
-        function setValue($value) {
946
-            if ($value === false) {
947
-                return parent::setValue($value);
948
-            }
949
-            if ($value !== $this->getAttribute('value')) {
950
-                return false;
951
-            }
952
-            return parent::setValue($value);
953
-        }
954
-
955
-        /**
956
-         *    Accessor for starting value.
957
-         *    @return string        Parsed value.
958
-         *    @access public
959
-         */
960
-        function getDefault() {
961
-            if ($this->getAttribute('checked') !== false) {
962
-                return $this->getAttribute('value');
963
-            }
964
-            return false;
965
-        }
966
-    }
967
-
968
-    /**
969
-     *    Checkbox widget.
915
+	 */
916
+	class SimpleRadioButtonTag extends SimpleWidget {
917
+
918
+		/**
919
+		 *    Stashes the attributes.
920
+		 *    @param array $attributes        Hash of attributes.
921
+		 */
922
+		function SimpleRadioButtonTag($attributes) {
923
+			$this->SimpleWidget('input', $attributes);
924
+			if ($this->getAttribute('value') === false) {
925
+				$this->_setAttribute('value', 'on');
926
+			}
927
+		}
928
+
929
+		/**
930
+		 *    Tag contains no content.
931
+		 *    @return boolean        False.
932
+		 *    @access public
933
+		 */
934
+		function expectEndTag() {
935
+			return false;
936
+		}
937
+
938
+		/**
939
+		 *    The only allowed value sn the one in the
940
+		 *    "value" attribute.
941
+		 *    @param string $value      New value.
942
+		 *    @return boolean           True if allowed.
943
+		 *    @access public
944
+		 */
945
+		function setValue($value) {
946
+			if ($value === false) {
947
+				return parent::setValue($value);
948
+			}
949
+			if ($value !== $this->getAttribute('value')) {
950
+				return false;
951
+			}
952
+			return parent::setValue($value);
953
+		}
954
+
955
+		/**
956
+		 *    Accessor for starting value.
957
+		 *    @return string        Parsed value.
958
+		 *    @access public
959
+		 */
960
+		function getDefault() {
961
+			if ($this->getAttribute('checked') !== false) {
962
+				return $this->getAttribute('value');
963
+			}
964
+			return false;
965
+		}
966
+	}
967
+
968
+	/**
969
+	 *    Checkbox widget.
970 970
 	 *    @package SimpleTest
971 971
 	 *    @subpackage WebTester
972
-     */
973
-    class SimpleCheckboxTag extends SimpleWidget {
974
-
975
-        /**
976
-         *    Starts with attributes only.
977
-         *    @param hash $attributes    Attribute names and
978
-         *                               string values.
979
-         */
980
-        function SimpleCheckboxTag($attributes) {
981
-            $this->SimpleWidget('input', $attributes);
982
-            if ($this->getAttribute('value') === false) {
983
-                $this->_setAttribute('value', 'on');
984
-            }
985
-        }
986
-
987
-        /**
988
-         *    Tag contains no content.
989
-         *    @return boolean        False.
990
-         *    @access public
991
-         */
992
-        function expectEndTag() {
993
-            return false;
994
-        }
995
-
996
-        /**
997
-         *    The only allowed value in the one in the
998
-         *    "value" attribute. The default for this
999
-         *    attribute is "on". If this widget is set to
1000
-         *    true, then the usual value will be taken.
1001
-         *    @param string $value      New value.
1002
-         *    @return boolean           True if allowed.
1003
-         *    @access public
1004
-         */
1005
-        function setValue($value) {
1006
-            if ($value === false) {
1007
-                return parent::setValue($value);
1008
-            }
1009
-            if ($value === true) {
1010
-                return parent::setValue($this->getAttribute('value'));
1011
-            }
1012
-            if ($value != $this->getAttribute('value')) {
1013
-                return false;
1014
-            }
1015
-            return parent::setValue($value);
1016
-        }
1017
-
1018
-        /**
1019
-         *    Accessor for starting value. The default
1020
-         *    value is "on".
1021
-         *    @return string        Parsed value.
1022
-         *    @access public
1023
-         */
1024
-        function getDefault() {
1025
-            if ($this->getAttribute('checked') !== false) {
1026
-                return $this->getAttribute('value');
1027
-            }
1028
-            return false;
1029
-        }
1030
-    }
1031
-
1032
-    /**
1033
-     *    A group of multiple widgets with some shared behaviour.
972
+	 */
973
+	class SimpleCheckboxTag extends SimpleWidget {
974
+
975
+		/**
976
+		 *    Starts with attributes only.
977
+		 *    @param hash $attributes    Attribute names and
978
+		 *                               string values.
979
+		 */
980
+		function SimpleCheckboxTag($attributes) {
981
+			$this->SimpleWidget('input', $attributes);
982
+			if ($this->getAttribute('value') === false) {
983
+				$this->_setAttribute('value', 'on');
984
+			}
985
+		}
986
+
987
+		/**
988
+		 *    Tag contains no content.
989
+		 *    @return boolean        False.
990
+		 *    @access public
991
+		 */
992
+		function expectEndTag() {
993
+			return false;
994
+		}
995
+
996
+		/**
997
+		 *    The only allowed value in the one in the
998
+		 *    "value" attribute. The default for this
999
+		 *    attribute is "on". If this widget is set to
1000
+		 *    true, then the usual value will be taken.
1001
+		 *    @param string $value      New value.
1002
+		 *    @return boolean           True if allowed.
1003
+		 *    @access public
1004
+		 */
1005
+		function setValue($value) {
1006
+			if ($value === false) {
1007
+				return parent::setValue($value);
1008
+			}
1009
+			if ($value === true) {
1010
+				return parent::setValue($this->getAttribute('value'));
1011
+			}
1012
+			if ($value != $this->getAttribute('value')) {
1013
+				return false;
1014
+			}
1015
+			return parent::setValue($value);
1016
+		}
1017
+
1018
+		/**
1019
+		 *    Accessor for starting value. The default
1020
+		 *    value is "on".
1021
+		 *    @return string        Parsed value.
1022
+		 *    @access public
1023
+		 */
1024
+		function getDefault() {
1025
+			if ($this->getAttribute('checked') !== false) {
1026
+				return $this->getAttribute('value');
1027
+			}
1028
+			return false;
1029
+		}
1030
+	}
1031
+
1032
+	/**
1033
+	 *    A group of multiple widgets with some shared behaviour.
1034 1034
 	 *    @package SimpleTest
1035 1035
 	 *    @subpackage WebTester
1036
-     */
1037
-    class SimpleTagGroup {
1038
-        protected $_widgets = array();
1039
-
1040
-        /**
1041
-         *    Adds a tag to the group.
1042
-         *    @param SimpleWidget $widget
1043
-         *    @access public
1044
-         */
1045
-        function addWidget($widget) {
1046
-            $this->_widgets[] = $widget;
1047
-        }
1048
-
1049
-        /**
1050
-         *    Accessor to widget set.
1051
-         *    @return array        All widgets.
1052
-         *    @access protected
1053
-         */
1054
-        function &_getWidgets() {
1055
-            return $this->_widgets;
1056
-        }
1057
-
1058
-        /**
1059
-         *    Accessor for an attribute.
1060
-         *    @param string $label    Attribute name.
1061
-         *    @return boolean         Always false.
1062
-         *    @access public
1063
-         */
1064
-        function getAttribute($label) {
1065
-            return false;
1066
-        }
1067
-
1068
-        /**
1069
-         *    Fetches the name for the widget from the first
1070
-         *    member.
1071
-         *    @return string        Name of widget.
1072
-         *    @access public
1073
-         */
1074
-        function getName() {
1075
-            if (count($this->_widgets) > 0) {
1076
-                return $this->_widgets[0]->getName();
1077
-            }
1078
-        }
1079
-
1080
-        /**
1081
-         *    Scans the widgets for one with the appropriate
1082
-         *    ID field.
1083
-         *    @param string $id        ID value to try.
1084
-         *    @return boolean          True if matched.
1085
-         *    @access public
1086
-         */
1087
-        function isId($id) {
1088
-            for ($i = 0, $count = count($this->_widgets); $i < $count; $i++) {
1089
-                if ($this->_widgets[$i]->isId($id)) {
1090
-                    return true;
1091
-                }
1092
-            }
1093
-            return false;
1094
-        }
1095
-
1096
-        /**
1097
-         *    Scans the widgets for one with the appropriate
1098
-         *    attached label.
1099
-         *    @param string $label     Attached label to try.
1100
-         *    @return boolean          True if matched.
1101
-         *    @access public
1102
-         */
1103
-        function isLabel($label) {
1104
-            for ($i = 0, $count = count($this->_widgets); $i < $count; $i++) {
1105
-                if ($this->_widgets[$i]->isLabel($label)) {
1106
-                    return true;
1107
-                }
1108
-            }
1109
-            return false;
1110
-        }
1111
-
1112
-        /**
1113
-         *    Dispatches the value into the form encoded packet.
1114
-         *    @param SimpleEncoding $encoding    Form packet.
1115
-         *    @access public
1116
-         */
1117
-        function write($encoding) {
1118
-            $encoding->add($this->getName(), $this->getValue());
1119
-        }
1120
-    }
1121
-
1122
-    /**
1123
-     *    A group of tags with the same name within a form.
1036
+	 */
1037
+	class SimpleTagGroup {
1038
+		protected $_widgets = array();
1039
+
1040
+		/**
1041
+		 *    Adds a tag to the group.
1042
+		 *    @param SimpleWidget $widget
1043
+		 *    @access public
1044
+		 */
1045
+		function addWidget($widget) {
1046
+			$this->_widgets[] = $widget;
1047
+		}
1048
+
1049
+		/**
1050
+		 *    Accessor to widget set.
1051
+		 *    @return array        All widgets.
1052
+		 *    @access protected
1053
+		 */
1054
+		function &_getWidgets() {
1055
+			return $this->_widgets;
1056
+		}
1057
+
1058
+		/**
1059
+		 *    Accessor for an attribute.
1060
+		 *    @param string $label    Attribute name.
1061
+		 *    @return boolean         Always false.
1062
+		 *    @access public
1063
+		 */
1064
+		function getAttribute($label) {
1065
+			return false;
1066
+		}
1067
+
1068
+		/**
1069
+		 *    Fetches the name for the widget from the first
1070
+		 *    member.
1071
+		 *    @return string        Name of widget.
1072
+		 *    @access public
1073
+		 */
1074
+		function getName() {
1075
+			if (count($this->_widgets) > 0) {
1076
+				return $this->_widgets[0]->getName();
1077
+			}
1078
+		}
1079
+
1080
+		/**
1081
+		 *    Scans the widgets for one with the appropriate
1082
+		 *    ID field.
1083
+		 *    @param string $id        ID value to try.
1084
+		 *    @return boolean          True if matched.
1085
+		 *    @access public
1086
+		 */
1087
+		function isId($id) {
1088
+			for ($i = 0, $count = count($this->_widgets); $i < $count; $i++) {
1089
+				if ($this->_widgets[$i]->isId($id)) {
1090
+					return true;
1091
+				}
1092
+			}
1093
+			return false;
1094
+		}
1095
+
1096
+		/**
1097
+		 *    Scans the widgets for one with the appropriate
1098
+		 *    attached label.
1099
+		 *    @param string $label     Attached label to try.
1100
+		 *    @return boolean          True if matched.
1101
+		 *    @access public
1102
+		 */
1103
+		function isLabel($label) {
1104
+			for ($i = 0, $count = count($this->_widgets); $i < $count; $i++) {
1105
+				if ($this->_widgets[$i]->isLabel($label)) {
1106
+					return true;
1107
+				}
1108
+			}
1109
+			return false;
1110
+		}
1111
+
1112
+		/**
1113
+		 *    Dispatches the value into the form encoded packet.
1114
+		 *    @param SimpleEncoding $encoding    Form packet.
1115
+		 *    @access public
1116
+		 */
1117
+		function write($encoding) {
1118
+			$encoding->add($this->getName(), $this->getValue());
1119
+		}
1120
+	}
1121
+
1122
+	/**
1123
+	 *    A group of tags with the same name within a form.
1124 1124
 	 *    @package SimpleTest
1125 1125
 	 *    @subpackage WebTester
1126
-     */
1127
-    class SimpleCheckboxGroup extends SimpleTagGroup {
1128
-
1129
-        /**
1130
-         *    Accessor for current selected widget or false
1131
-         *    if none.
1132
-         *    @return string/array     Widget values or false if none.
1133
-         *    @access public
1134
-         */
1135
-        function getValue() {
1136
-            $values = array();
1137
-            $widgets = $this->_getWidgets();
1138
-            for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1139
-                if ($widgets[$i]->getValue() !== false) {
1140
-                    $values[] = $widgets[$i]->getValue();
1141
-                }
1142
-            }
1143
-            return $this->_coerceValues($values);
1144
-        }
1145
-
1146
-        /**
1147
-         *    Accessor for starting value that is active.
1148
-         *    @return string/array      Widget values or false if none.
1149
-         *    @access public
1150
-         */
1151
-        function getDefault() {
1152
-            $values = array();
1153
-            $widgets = $this->_getWidgets();
1154
-            for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1155
-                if ($widgets[$i]->getDefault() !== false) {
1156
-                    $values[] = $widgets[$i]->getDefault();
1157
-                }
1158
-            }
1159
-            return $this->_coerceValues($values);
1160
-        }
1161
-
1162
-        /**
1163
-         *    Accessor for current set values.
1164
-         *    @param string/array/boolean $values   Either a single string, a
1165
-         *                                          hash or false for nothing set.
1166
-         *    @return boolean                       True if all values can be set.
1167
-         *    @access public
1168
-         */
1169
-        function setValue($values) {
1170
-            $values = $this->_makeArray($values);
1171
-            if (! $this->_valuesArePossible($values)) {
1172
-                return false;
1173
-            }
1174
-            $widgets = $this->_getWidgets();
1175
-            for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1176
-                $possible = $widgets[$i]->getAttribute('value');
1177
-                if (in_array($widgets[$i]->getAttribute('value'), $values)) {
1178
-                    $widgets[$i]->setValue($possible);
1179
-                } else {
1180
-                    $widgets[$i]->setValue(false);
1181
-                }
1182
-            }
1183
-            return true;
1184
-        }
1185
-
1186
-        /**
1187
-         *    Tests to see if a possible value set is legal.
1188
-         *    @param string/array/boolean $values   Either a single string, a
1189
-         *                                          hash or false for nothing set.
1190
-         *    @return boolean                       False if trying to set a
1191
-         *                                          missing value.
1192
-         *    @access private
1193
-         */
1194
-        function _valuesArePossible($values) {
1195
-            $matches = array();
1196
-            $widgets = $this->_getWidgets();
1197
-            for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1198
-                $possible = $widgets[$i]->getAttribute('value');
1199
-                if (in_array($possible, $values)) {
1200
-                    $matches[] = $possible;
1201
-                }
1202
-            }
1203
-            return ($values == $matches);
1204
-        }
1205
-
1206
-        /**
1207
-         *    Converts the output to an appropriate format. This means
1208
-         *    that no values is false, a single value is just that
1209
-         *    value and only two or more are contained in an array.
1210
-         *    @param array $values           List of values of widgets.
1211
-         *    @return string/array/boolean   Expected format for a tag.
1212
-         *    @access private
1213
-         */
1214
-        function _coerceValues($values) {
1215
-            if (count($values) == 0) {
1216
-                return false;
1217
-            } elseif (count($values) == 1) {
1218
-                return $values[0];
1219
-            } else {
1220
-                return $values;
1221
-            }
1222
-        }
1223
-
1224
-        /**
1225
-         *    Converts false or string into array. The opposite of
1226
-         *    the coercian method.
1227
-         *    @param string/array/boolean $value  A single item is converted
1228
-         *                                        to a one item list. False
1229
-         *                                        gives an empty list.
1230
-         *    @return array                       List of values, possibly empty.
1231
-         *    @access private
1232
-         */
1233
-        function _makeArray($value) {
1234
-            if ($value === false) {
1235
-                return array();
1236
-            }
1237
-            if (is_string($value)) {
1238
-                return array($value);
1239
-            }
1240
-            return $value;
1241
-        }
1242
-    }
1243
-
1244
-    /**
1245
-     *    A group of tags with the same name within a form.
1246
-     *    Used for radio buttons.
1126
+	 */
1127
+	class SimpleCheckboxGroup extends SimpleTagGroup {
1128
+
1129
+		/**
1130
+		 *    Accessor for current selected widget or false
1131
+		 *    if none.
1132
+		 *    @return string/array     Widget values or false if none.
1133
+		 *    @access public
1134
+		 */
1135
+		function getValue() {
1136
+			$values = array();
1137
+			$widgets = $this->_getWidgets();
1138
+			for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1139
+				if ($widgets[$i]->getValue() !== false) {
1140
+					$values[] = $widgets[$i]->getValue();
1141
+				}
1142
+			}
1143
+			return $this->_coerceValues($values);
1144
+		}
1145
+
1146
+		/**
1147
+		 *    Accessor for starting value that is active.
1148
+		 *    @return string/array      Widget values or false if none.
1149
+		 *    @access public
1150
+		 */
1151
+		function getDefault() {
1152
+			$values = array();
1153
+			$widgets = $this->_getWidgets();
1154
+			for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1155
+				if ($widgets[$i]->getDefault() !== false) {
1156
+					$values[] = $widgets[$i]->getDefault();
1157
+				}
1158
+			}
1159
+			return $this->_coerceValues($values);
1160
+		}
1161
+
1162
+		/**
1163
+		 *    Accessor for current set values.
1164
+		 *    @param string/array/boolean $values   Either a single string, a
1165
+		 *                                          hash or false for nothing set.
1166
+		 *    @return boolean                       True if all values can be set.
1167
+		 *    @access public
1168
+		 */
1169
+		function setValue($values) {
1170
+			$values = $this->_makeArray($values);
1171
+			if (! $this->_valuesArePossible($values)) {
1172
+				return false;
1173
+			}
1174
+			$widgets = $this->_getWidgets();
1175
+			for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1176
+				$possible = $widgets[$i]->getAttribute('value');
1177
+				if (in_array($widgets[$i]->getAttribute('value'), $values)) {
1178
+					$widgets[$i]->setValue($possible);
1179
+				} else {
1180
+					$widgets[$i]->setValue(false);
1181
+				}
1182
+			}
1183
+			return true;
1184
+		}
1185
+
1186
+		/**
1187
+		 *    Tests to see if a possible value set is legal.
1188
+		 *    @param string/array/boolean $values   Either a single string, a
1189
+		 *                                          hash or false for nothing set.
1190
+		 *    @return boolean                       False if trying to set a
1191
+		 *                                          missing value.
1192
+		 *    @access private
1193
+		 */
1194
+		function _valuesArePossible($values) {
1195
+			$matches = array();
1196
+			$widgets = $this->_getWidgets();
1197
+			for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1198
+				$possible = $widgets[$i]->getAttribute('value');
1199
+				if (in_array($possible, $values)) {
1200
+					$matches[] = $possible;
1201
+				}
1202
+			}
1203
+			return ($values == $matches);
1204
+		}
1205
+
1206
+		/**
1207
+		 *    Converts the output to an appropriate format. This means
1208
+		 *    that no values is false, a single value is just that
1209
+		 *    value and only two or more are contained in an array.
1210
+		 *    @param array $values           List of values of widgets.
1211
+		 *    @return string/array/boolean   Expected format for a tag.
1212
+		 *    @access private
1213
+		 */
1214
+		function _coerceValues($values) {
1215
+			if (count($values) == 0) {
1216
+				return false;
1217
+			} elseif (count($values) == 1) {
1218
+				return $values[0];
1219
+			} else {
1220
+				return $values;
1221
+			}
1222
+		}
1223
+
1224
+		/**
1225
+		 *    Converts false or string into array. The opposite of
1226
+		 *    the coercian method.
1227
+		 *    @param string/array/boolean $value  A single item is converted
1228
+		 *                                        to a one item list. False
1229
+		 *                                        gives an empty list.
1230
+		 *    @return array                       List of values, possibly empty.
1231
+		 *    @access private
1232
+		 */
1233
+		function _makeArray($value) {
1234
+			if ($value === false) {
1235
+				return array();
1236
+			}
1237
+			if (is_string($value)) {
1238
+				return array($value);
1239
+			}
1240
+			return $value;
1241
+		}
1242
+	}
1243
+
1244
+	/**
1245
+	 *    A group of tags with the same name within a form.
1246
+	 *    Used for radio buttons.
1247 1247
 	 *    @package SimpleTest
1248 1248
 	 *    @subpackage WebTester
1249
-     */
1250
-    class SimpleRadioGroup extends SimpleTagGroup {
1251
-
1252
-        /**
1253
-         *    Each tag is tried in turn until one is
1254
-         *    successfully set. The others will be
1255
-         *    unchecked if successful.
1256
-         *    @param string $value      New value.
1257
-         *    @return boolean           True if any allowed.
1258
-         *    @access public
1259
-         */
1260
-        function setValue($value) {
1261
-            if (! $this->_valueIsPossible($value)) {
1262
-                return false;
1263
-            }
1264
-            $index = false;
1265
-            $widgets = $this->_getWidgets();
1266
-            for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1267
-                if (! $widgets[$i]->setValue($value)) {
1268
-                    $widgets[$i]->setValue(false);
1269
-                }
1270
-            }
1271
-            return true;
1272
-        }
1273
-
1274
-        /**
1275
-         *    Tests to see if a value is allowed.
1276
-         *    @param string    Attempted value.
1277
-         *    @return boolean  True if a valid value.
1278
-         *    @access private
1279
-         */
1280
-        function _valueIsPossible($value) {
1281
-            $widgets = $this->_getWidgets();
1282
-            for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1283
-                if ($widgets[$i]->getAttribute('value') == $value) {
1284
-                    return true;
1285
-                }
1286
-            }
1287
-            return false;
1288
-        }
1289
-
1290
-        /**
1291
-         *    Accessor for current selected widget or false
1292
-         *    if none.
1293
-         *    @return string/boolean   Value attribute or
1294
-         *                             content of opton.
1295
-         *    @access public
1296
-         */
1297
-        function getValue() {
1298
-            $widgets = $this->_getWidgets();
1299
-            for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1300
-                if ($widgets[$i]->getValue() !== false) {
1301
-                    return $widgets[$i]->getValue();
1302
-                }
1303
-            }
1304
-            return false;
1305
-        }
1306
-
1307
-        /**
1308
-         *    Accessor for starting value that is active.
1309
-         *    @return string/boolean      Value of first checked
1310
-         *                                widget or false if none.
1311
-         *    @access public
1312
-         */
1313
-        function getDefault() {
1314
-            $widgets = $this->_getWidgets();
1315
-            for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1316
-                if ($widgets[$i]->getDefault() !== false) {
1317
-                    return $widgets[$i]->getDefault();
1318
-                }
1319
-            }
1320
-            return false;
1321
-        }
1322
-    }
1323
-
1324
-    /**
1325
-     *    Tag to keep track of labels.
1249
+	 */
1250
+	class SimpleRadioGroup extends SimpleTagGroup {
1251
+
1252
+		/**
1253
+		 *    Each tag is tried in turn until one is
1254
+		 *    successfully set. The others will be
1255
+		 *    unchecked if successful.
1256
+		 *    @param string $value      New value.
1257
+		 *    @return boolean           True if any allowed.
1258
+		 *    @access public
1259
+		 */
1260
+		function setValue($value) {
1261
+			if (! $this->_valueIsPossible($value)) {
1262
+				return false;
1263
+			}
1264
+			$index = false;
1265
+			$widgets = $this->_getWidgets();
1266
+			for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1267
+				if (! $widgets[$i]->setValue($value)) {
1268
+					$widgets[$i]->setValue(false);
1269
+				}
1270
+			}
1271
+			return true;
1272
+		}
1273
+
1274
+		/**
1275
+		 *    Tests to see if a value is allowed.
1276
+		 *    @param string    Attempted value.
1277
+		 *    @return boolean  True if a valid value.
1278
+		 *    @access private
1279
+		 */
1280
+		function _valueIsPossible($value) {
1281
+			$widgets = $this->_getWidgets();
1282
+			for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1283
+				if ($widgets[$i]->getAttribute('value') == $value) {
1284
+					return true;
1285
+				}
1286
+			}
1287
+			return false;
1288
+		}
1289
+
1290
+		/**
1291
+		 *    Accessor for current selected widget or false
1292
+		 *    if none.
1293
+		 *    @return string/boolean   Value attribute or
1294
+		 *                             content of opton.
1295
+		 *    @access public
1296
+		 */
1297
+		function getValue() {
1298
+			$widgets = $this->_getWidgets();
1299
+			for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1300
+				if ($widgets[$i]->getValue() !== false) {
1301
+					return $widgets[$i]->getValue();
1302
+				}
1303
+			}
1304
+			return false;
1305
+		}
1306
+
1307
+		/**
1308
+		 *    Accessor for starting value that is active.
1309
+		 *    @return string/boolean      Value of first checked
1310
+		 *                                widget or false if none.
1311
+		 *    @access public
1312
+		 */
1313
+		function getDefault() {
1314
+			$widgets = $this->_getWidgets();
1315
+			for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1316
+				if ($widgets[$i]->getDefault() !== false) {
1317
+					return $widgets[$i]->getDefault();
1318
+				}
1319
+			}
1320
+			return false;
1321
+		}
1322
+	}
1323
+
1324
+	/**
1325
+	 *    Tag to keep track of labels.
1326 1326
 	 *    @package SimpleTest
1327 1327
 	 *    @subpackage WebTester
1328
-     */
1329
-    class SimpleLabelTag extends SimpleTag {
1330
-
1331
-        /**
1332
-         *    Starts with a named tag with attributes only.
1333
-         *    @param hash $attributes    Attribute names and
1334
-         *                               string values.
1335
-         */
1336
-        function SimpleLabelTag($attributes) {
1337
-            $this->SimpleTag('label', $attributes);
1338
-        }
1339
-
1340
-        /**
1341
-         *    Access for the ID to attach the label to.
1342
-         *    @return string        For attribute.
1343
-         *    @access public
1344
-         */
1345
-        function getFor() {
1346
-            return $this->getAttribute('for');
1347
-        }
1348
-    }
1349
-
1350
-    /**
1351
-     *    Tag to aid parsing the form.
1328
+	 */
1329
+	class SimpleLabelTag extends SimpleTag {
1330
+
1331
+		/**
1332
+		 *    Starts with a named tag with attributes only.
1333
+		 *    @param hash $attributes    Attribute names and
1334
+		 *                               string values.
1335
+		 */
1336
+		function SimpleLabelTag($attributes) {
1337
+			$this->SimpleTag('label', $attributes);
1338
+		}
1339
+
1340
+		/**
1341
+		 *    Access for the ID to attach the label to.
1342
+		 *    @return string        For attribute.
1343
+		 *    @access public
1344
+		 */
1345
+		function getFor() {
1346
+			return $this->getAttribute('for');
1347
+		}
1348
+	}
1349
+
1350
+	/**
1351
+	 *    Tag to aid parsing the form.
1352 1352
 	 *    @package SimpleTest
1353 1353
 	 *    @subpackage WebTester
1354
-     */
1355
-    class SimpleFormTag extends SimpleTag {
1356
-
1357
-        /**
1358
-         *    Starts with a named tag with attributes only.
1359
-         *    @param hash $attributes    Attribute names and
1360
-         *                               string values.
1361
-         */
1362
-        function SimpleFormTag($attributes) {
1363
-            $this->SimpleTag('form', $attributes);
1364
-        }
1365
-    }
1366
-
1367
-    /**
1368
-     *    Tag to aid parsing the frames in a page.
1354
+	 */
1355
+	class SimpleFormTag extends SimpleTag {
1356
+
1357
+		/**
1358
+		 *    Starts with a named tag with attributes only.
1359
+		 *    @param hash $attributes    Attribute names and
1360
+		 *                               string values.
1361
+		 */
1362
+		function SimpleFormTag($attributes) {
1363
+			$this->SimpleTag('form', $attributes);
1364
+		}
1365
+	}
1366
+
1367
+	/**
1368
+	 *    Tag to aid parsing the frames in a page.
1369 1369
 	 *    @package SimpleTest
1370 1370
 	 *    @subpackage WebTester
1371
-     */
1372
-    class SimpleFrameTag extends SimpleTag {
1373
-
1374
-        /**
1375
-         *    Starts with a named tag with attributes only.
1376
-         *    @param hash $attributes    Attribute names and
1377
-         *                               string values.
1378
-         */
1379
-        function SimpleFrameTag($attributes) {
1380
-            $this->SimpleTag('frame', $attributes);
1381
-        }
1382
-
1383
-        /**
1384
-         *    Tag contains no content.
1385
-         *    @return boolean        False.
1386
-         *    @access public
1387
-         */
1388
-        function expectEndTag() {
1389
-            return false;
1390
-        }
1391
-    }
1392 1371
\ No newline at end of file
1372
+	 */
1373
+	class SimpleFrameTag extends SimpleTag {
1374
+
1375
+		/**
1376
+		 *    Starts with a named tag with attributes only.
1377
+		 *    @param hash $attributes    Attribute names and
1378
+		 *                               string values.
1379
+		 */
1380
+		function SimpleFrameTag($attributes) {
1381
+			$this->SimpleTag('frame', $attributes);
1382
+		}
1383
+
1384
+		/**
1385
+		 *    Tag contains no content.
1386
+		 *    @return boolean        False.
1387
+		 *    @access public
1388
+		 */
1389
+		function expectEndTag() {
1390
+			return false;
1391
+		}
1392
+	}
1393 1393
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
          *    @access public
67 67
          */
68 68
         function addContent($content) {
69
-            $this->_content .= (string)$content;
69
+            $this->_content .= (string) $content;
70 70
         }
71 71
 
72 72
         /**
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
          */
104 104
         function getAttribute($label) {
105 105
             $label = strtolower($label);
106
-            if (! isset($this->_attributes[$label])) {
106
+            if (!isset($this->_attributes[$label])) {
107 107
                 return false;
108 108
             }
109
-            return (string)$this->_attributes[$label];
109
+            return (string) $this->_attributes[$label];
110 110
         }
111 111
 
112 112
         /**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
          *    @access public
248 248
          */
249 249
         function getValue() {
250
-            if (! $this->_is_set) {
250
+            if (!$this->_is_set) {
251 251
                 return $this->getDefault();
252 252
             }
253 253
             return $this->_value;
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
          *    @param integer $y                  Y coordinate of click.
472 472
          *    @access public
473 473
          */
474
-        function write($encoding){//, $x, $y) {
474
+        function write($encoding) {//, $x, $y) {
475 475
             if ($this->getName()) {
476 476
                 $encoding->add($this->getName() . '.x', $x);
477 477
                 $encoding->add($this->getName() . '.y', $y);
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
             if ($this->_wrapIsEnabled()) {
609 609
                 return wordwrap(
610 610
                         $text,
611
-                        (integer)$this->getAttribute('cols'),
611
+                        (integer) $this->getAttribute('cols'),
612 612
                         "\r\n");
613 613
             }
614 614
             return $text;
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
          *    @access public
656 656
          */
657 657
         function write($encoding) {
658
-            if (! file_exists($this->getValue())) {
658
+            if (!file_exists($this->getValue())) {
659 659
                 return;
660 660
             }
661 661
             $encoding->attach(
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
                         break;
827 827
                     }
828 828
                 }
829
-                if (! $success) {
829
+                if (!$success) {
830 830
                     return false;
831 831
                 }
832 832
             }
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
          */
1169 1169
         function setValue($values) {
1170 1170
             $values = $this->_makeArray($values);
1171
-            if (! $this->_valuesArePossible($values)) {
1171
+            if (!$this->_valuesArePossible($values)) {
1172 1172
                 return false;
1173 1173
             }
1174 1174
             $widgets = $this->_getWidgets();
@@ -1258,13 +1258,13 @@  discard block
 block discarded – undo
1258 1258
          *    @access public
1259 1259
          */
1260 1260
         function setValue($value) {
1261
-            if (! $this->_valueIsPossible($value)) {
1261
+            if (!$this->_valueIsPossible($value)) {
1262 1262
                 return false;
1263 1263
             }
1264 1264
             $index = false;
1265 1265
             $widgets = $this->_getWidgets();
1266 1266
             for ($i = 0, $count = count($widgets); $i < $count; $i++) {
1267
-                if (! $widgets[$i]->setValue($value)) {
1267
+                if (!$widgets[$i]->setValue($value)) {
1268 1268
                     $widgets[$i]->setValue(false);
1269 1269
                 }
1270 1270
             }
Please login to merge, or discard this patch.
tests/test_tools/simpletest/test_case.php 3 patches
Doc Comments   +2 added lines, -12 removed lines patch added patch discarded remove patch
@@ -330,13 +330,7 @@  discard block
 block discarded – undo
330 330
 
331 331
         /**
332 332
          *    Uses a stack trace to find the line of an assertion.
333
-         *    @param string $format    String formatting.
334
-         *    @param array $stack      Stack frames top most first. Only
335
-         *                             needed if not using the PHP
336
-         *                             backtrace function.
337
-         *    @return string           Line number of first assert*
338
-         *                             method embedded in format string.
339
-         *    @access public
333
+         * @param string $stack
340 334
          */
341 335
         function getAssertionLine($stack = false) {
342 336
             if ($stack === false) {
@@ -349,7 +343,7 @@  discard block
 block discarded – undo
349 343
          *    Sends a formatted dump of a variable to the
350 344
          *    test suite for those emergency debugging
351 345
          *    situations.
352
-         *    @param mixed $variable    Variable to display.
346
+         *    @param string|boolean $variable    Variable to display.
353 347
          *    @param string $message    Message to display.
354 348
          *    @return mixed             The original variable.
355 349
          *    @access public
@@ -440,10 +434,6 @@  discard block
 block discarded – undo
440 434
         /**
441 435
          *    Adds a test into the suite by class name. The class will
442 436
          *    be instantiated as needed.
443
-         *    @param SimpleTestCase $test_case  Suite or individual test
444
-         *                                      case implementing the
445
-         *                                      runnable test interface.
446
-         *    @access public
447 437
          */
448 438
         function addTestClass($class) {
449 439
             if ($this->_getBaseTestCase($class) == 'grouptest') {
Please login to merge, or discard this patch.
Indentation   +672 added lines, -672 removed lines patch added patch discarded remove patch
@@ -1,689 +1,689 @@
 block discarded – undo
1 1
 <?php
2
-    /**
3
-     *	Base include file for SimpleTest
4
-     *	@package	SimpleTest
5
-     *	@subpackage	UnitTester
6
-     *	@version	$Id: test_case.php 2309 2007-10-08 03:24:07Z wei $
7
-     */
8
-
9
-    /**#@+
2
+	/**
3
+	 *	Base include file for SimpleTest
4
+	 *	@package	SimpleTest
5
+	 *	@subpackage	UnitTester
6
+	 *	@version	$Id: test_case.php 2309 2007-10-08 03:24:07Z wei $
7
+	 */
8
+
9
+	/**#@+
10 10
      * Includes SimpleTest files and defined the root constant
11 11
      * for dependent libraries.
12 12
      */
13
-    require_once(dirname(__FILE__) . '/invoker.php');
14
-    require_once(dirname(__FILE__) . '/errors.php');
15
-    require_once(dirname(__FILE__) . '/compatibility.php');
16
-    require_once(dirname(__FILE__) . '/scorer.php');
17
-    require_once(dirname(__FILE__) . '/expectation.php');
18
-    require_once(dirname(__FILE__) . '/dumper.php');
19
-    require_once(dirname(__FILE__) . '/simpletest.php');
20
-    if (version_compare(phpversion(), '5') >= 0) {
21
-        require_once(dirname(__FILE__) . '/exceptions.php');
22
-        require_once(dirname(__FILE__) . '/reflection_php5.php');
23
-    } else {
24
-        require_once(dirname(__FILE__) . '/reflection_php4.php');
25
-    }
26
-    if (! defined('SIMPLE_TEST')) {
27
-        /**
28
-         * @ignore
29
-         */
30
-        define('SIMPLE_TEST', dirname(__FILE__) . '/');
31
-    }
32
-    /**#@-*/
33
-
34
-    /**
35
-     *    Basic test case. This is the smallest unit of a test
36
-     *    suite. It searches for
37
-     *    all methods that start with the the string "test" and
38
-     *    runs them. Working test cases extend this class.
13
+	require_once(dirname(__FILE__) . '/invoker.php');
14
+	require_once(dirname(__FILE__) . '/errors.php');
15
+	require_once(dirname(__FILE__) . '/compatibility.php');
16
+	require_once(dirname(__FILE__) . '/scorer.php');
17
+	require_once(dirname(__FILE__) . '/expectation.php');
18
+	require_once(dirname(__FILE__) . '/dumper.php');
19
+	require_once(dirname(__FILE__) . '/simpletest.php');
20
+	if (version_compare(phpversion(), '5') >= 0) {
21
+		require_once(dirname(__FILE__) . '/exceptions.php');
22
+		require_once(dirname(__FILE__) . '/reflection_php5.php');
23
+	} else {
24
+		require_once(dirname(__FILE__) . '/reflection_php4.php');
25
+	}
26
+	if (! defined('SIMPLE_TEST')) {
27
+		/**
28
+		 * @ignore
29
+		 */
30
+		define('SIMPLE_TEST', dirname(__FILE__) . '/');
31
+	}
32
+	/**#@-*/
33
+
34
+	/**
35
+	 *    Basic test case. This is the smallest unit of a test
36
+	 *    suite. It searches for
37
+	 *    all methods that start with the the string "test" and
38
+	 *    runs them. Working test cases extend this class.
39 39
 	 *    @package		SimpleTest
40 40
 	 *    @subpackage	UnitTester
41
-     */
42
-    class SimpleTestCase {
43
-        protected $_label = false;
44
-        protected $_reporter;
45
-        protected $_observers;
46
-
47
-        /**
48
-         *    Sets up the test with no display.
49
-         *    @param string $label    If no test name is given then
50
-         *                            the class name is used.
51
-         *    @access public
52
-         */
53
-        function SimpleTestCase($label = false) {
54
-            if ($label) {
55
-                $this->_label = $label;
56
-            }
57
-        }
58
-
59
-        /**
60
-         *    Accessor for the test name for subclasses.
61
-         *    @return string           Name of the test.
62
-         *    @access public
63
-         */
64
-        function getLabel() {
65
-            return $this->_label ? $this->_label : get_class($this);
66
-        }
67
-
68
-        /**
69
-         *    Used to invoke the single tests.
70
-         *    @return SimpleInvoker        Individual test runner.
71
-         *    @access public
72
-         */
73
-        function createInvoker() {
74
-            $invoker = new SimpleErrorTrappingInvoker(new SimpleInvoker($this));
75
-            if (version_compare(phpversion(), '5') >= 0) {
76
-                $invoker = new SimpleExceptionTrappingInvoker($invoker);
77
-            }
78
-            return $invoker;
79
-        }
80
-
81
-        /**
82
-         *    Uses reflection to run every method within itself
83
-         *    starting with the string "test" unless a method
84
-         *    is specified.
85
-         *    @param SimpleReporter $reporter    Current test reporter.
86
-         *    @access public
87
-         */
88
-        function run($reporter) {
89
-            SimpleTest::setCurrent($this);
90
-            $this->_reporter = $reporter;
91
-            $this->_reporter->paintCaseStart($this->getLabel());
92
-            foreach ($this->getTests() as $method) {
93
-                if ($this->_reporter->shouldInvoke($this->getLabel(), $method)) {
94
-                    $invoker = $this->_reporter->createInvoker($this->createInvoker());
95
-                    $invoker->before($method);
96
-                    $invoker->invoke($method);
97
-                    $invoker->after($method);
98
-                }
99
-            }
100
-            $this->_reporter->paintCaseEnd($this->getLabel());
101
-            unset($this->_reporter);
102
-            return $reporter->getStatus();
103
-        }
104
-
105
-        /**
106
-         *    Gets a list of test names. Normally that will
107
-         *    be all internal methods that start with the
108
-         *    name "test". This method should be overridden
109
-         *    if you want a different rule.
110
-         *    @return array        List of test names.
111
-         *    @access public
112
-         */
113
-        function getTests() {
114
-            $methods = array();
115
-            foreach (get_class_methods(get_class($this)) as $method) {
116
-                if ($this->_isTest($method)) {
117
-                    $methods[] = $method;
118
-                }
119
-            }
120
-            return $methods;
121
-        }
122
-
123
-        /**
124
-         *    Tests to see if the method is a test that should
125
-         *    be run. Currently any method that starts with 'test'
126
-         *    is a candidate unless it is the constructor.
127
-         *    @param string $method        Method name to try.
128
-         *    @return boolean              True if test method.
129
-         *    @access protected
130
-         */
131
-        function _isTest($method) {
132
-            if (strtolower(substr($method, 0, 4)) == 'test') {
133
-                return ! SimpleTestCompatibility::isA($this, strtolower($method));
134
-            }
135
-            return false;
136
-        }
137
-
138
-        /**
139
-         *    Announces the start of the test.
140
-         *    @param string $method    Test method just started.
141
-         *    @access public
142
-         */
143
-        function before($method) {
144
-            $this->_reporter->paintMethodStart($method);
145
-            $this->_observers = array();
146
-        }
147
-
148
-        /**
149
-         *    Sets up unit test wide variables at the start
150
-         *    of each test method. To be overridden in
151
-         *    actual user test cases.
152
-         *    @access public
153
-         */
154
-        function setUp() {
155
-        }
156
-
157
-        /**
158
-         *    Clears the data set in the setUp() method call.
159
-         *    To be overridden by the user in actual user test cases.
160
-         *    @access public
161
-         */
162
-        function tearDown() {
163
-        }
164
-
165
-        /**
166
-         *    Announces the end of the test. Includes private clean up.
167
-         *    @param string $method    Test method just finished.
168
-         *    @access public
169
-         */
170
-        function after($method) {
171
-            for ($i = 0; $i < count($this->_observers); $i++) {
172
-                $this->_observers[$i]->atTestEnd($method);
173
-            }
174
-            $this->_reporter->paintMethodEnd($method);
175
-        }
176
-
177
-        /**
178
-         *    Sets up an observer for the test end.
179
-         *    @param object $observer    Must have atTestEnd()
180
-         *                               method.
181
-         *    @access public
182
-         */
183
-        function tell($observer) {
184
-            $this->_observers[] = $observer;
185
-        }
186
-
187
-        /**
188
-         *    Sends a pass event with a message.
189
-         *    @param string $message        Message to send.
190
-         *    @access public
191
-         */
192
-        function pass($message = "Pass") {
193
-            if (! isset($this->_reporter)) {
194
-                trigger_error('Can only make assertions within test methods');
195
-            }
196
-            $this->_reporter->paintPass(
197
-                    $message . $this->getAssertionLine());
198
-            return true;
199
-        }
200
-
201
-        /**
202
-         *    Sends a fail event with a message.
203
-         *    @param string $message        Message to send.
204
-         *    @access public
205
-         */
206
-        function fail($message = "Fail") {
207
-            if (! isset($this->_reporter)) {
208
-                trigger_error('Can only make assertions within test methods');
209
-            }
210
-            $this->_reporter->paintFail(
211
-                    $message . $this->getAssertionLine());
212
-            return false;
213
-        }
214
-
215
-        /**
216
-         *    Formats a PHP error and dispatches it to the
217
-         *    reporter.
218
-         *    @param integer $severity  PHP error code.
219
-         *    @param string $message    Text of error.
220
-         *    @param string $file       File error occoured in.
221
-         *    @param integer $line      Line number of error.
222
-         *    @access public
223
-         */
224
-        function error($severity, $message, $file, $line) {
225
-            if (! isset($this->_reporter)) {
226
-                trigger_error('Can only make assertions within test methods');
227
-            }
228
-            $this->_reporter->paintError(
229
-                    "Unexpected PHP error [$message] severity [$severity] in [$file] line [$line]");
230
-        }
231
-
232
-        /**
233
-         *    Formats an exception and dispatches it to the
234
-         *    reporter.
235
-         *    @param Exception $exception    Object thrown.
236
-         *    @access public
237
-         */
238
-        function exception($exception) {
239
-            $this->_reporter->paintError(
240
-                    'Unexpected exception of type [' . get_class($exception) .
241
-                    '] with message ['. $exception->getMessage() .
242
-                    '] in ['. $exception->getFile() .
243
-                    '] line [' . $exception->getLine() .
41
+	 */
42
+	class SimpleTestCase {
43
+		protected $_label = false;
44
+		protected $_reporter;
45
+		protected $_observers;
46
+
47
+		/**
48
+		 *    Sets up the test with no display.
49
+		 *    @param string $label    If no test name is given then
50
+		 *                            the class name is used.
51
+		 *    @access public
52
+		 */
53
+		function SimpleTestCase($label = false) {
54
+			if ($label) {
55
+				$this->_label = $label;
56
+			}
57
+		}
58
+
59
+		/**
60
+		 *    Accessor for the test name for subclasses.
61
+		 *    @return string           Name of the test.
62
+		 *    @access public
63
+		 */
64
+		function getLabel() {
65
+			return $this->_label ? $this->_label : get_class($this);
66
+		}
67
+
68
+		/**
69
+		 *    Used to invoke the single tests.
70
+		 *    @return SimpleInvoker        Individual test runner.
71
+		 *    @access public
72
+		 */
73
+		function createInvoker() {
74
+			$invoker = new SimpleErrorTrappingInvoker(new SimpleInvoker($this));
75
+			if (version_compare(phpversion(), '5') >= 0) {
76
+				$invoker = new SimpleExceptionTrappingInvoker($invoker);
77
+			}
78
+			return $invoker;
79
+		}
80
+
81
+		/**
82
+		 *    Uses reflection to run every method within itself
83
+		 *    starting with the string "test" unless a method
84
+		 *    is specified.
85
+		 *    @param SimpleReporter $reporter    Current test reporter.
86
+		 *    @access public
87
+		 */
88
+		function run($reporter) {
89
+			SimpleTest::setCurrent($this);
90
+			$this->_reporter = $reporter;
91
+			$this->_reporter->paintCaseStart($this->getLabel());
92
+			foreach ($this->getTests() as $method) {
93
+				if ($this->_reporter->shouldInvoke($this->getLabel(), $method)) {
94
+					$invoker = $this->_reporter->createInvoker($this->createInvoker());
95
+					$invoker->before($method);
96
+					$invoker->invoke($method);
97
+					$invoker->after($method);
98
+				}
99
+			}
100
+			$this->_reporter->paintCaseEnd($this->getLabel());
101
+			unset($this->_reporter);
102
+			return $reporter->getStatus();
103
+		}
104
+
105
+		/**
106
+		 *    Gets a list of test names. Normally that will
107
+		 *    be all internal methods that start with the
108
+		 *    name "test". This method should be overridden
109
+		 *    if you want a different rule.
110
+		 *    @return array        List of test names.
111
+		 *    @access public
112
+		 */
113
+		function getTests() {
114
+			$methods = array();
115
+			foreach (get_class_methods(get_class($this)) as $method) {
116
+				if ($this->_isTest($method)) {
117
+					$methods[] = $method;
118
+				}
119
+			}
120
+			return $methods;
121
+		}
122
+
123
+		/**
124
+		 *    Tests to see if the method is a test that should
125
+		 *    be run. Currently any method that starts with 'test'
126
+		 *    is a candidate unless it is the constructor.
127
+		 *    @param string $method        Method name to try.
128
+		 *    @return boolean              True if test method.
129
+		 *    @access protected
130
+		 */
131
+		function _isTest($method) {
132
+			if (strtolower(substr($method, 0, 4)) == 'test') {
133
+				return ! SimpleTestCompatibility::isA($this, strtolower($method));
134
+			}
135
+			return false;
136
+		}
137
+
138
+		/**
139
+		 *    Announces the start of the test.
140
+		 *    @param string $method    Test method just started.
141
+		 *    @access public
142
+		 */
143
+		function before($method) {
144
+			$this->_reporter->paintMethodStart($method);
145
+			$this->_observers = array();
146
+		}
147
+
148
+		/**
149
+		 *    Sets up unit test wide variables at the start
150
+		 *    of each test method. To be overridden in
151
+		 *    actual user test cases.
152
+		 *    @access public
153
+		 */
154
+		function setUp() {
155
+		}
156
+
157
+		/**
158
+		 *    Clears the data set in the setUp() method call.
159
+		 *    To be overridden by the user in actual user test cases.
160
+		 *    @access public
161
+		 */
162
+		function tearDown() {
163
+		}
164
+
165
+		/**
166
+		 *    Announces the end of the test. Includes private clean up.
167
+		 *    @param string $method    Test method just finished.
168
+		 *    @access public
169
+		 */
170
+		function after($method) {
171
+			for ($i = 0; $i < count($this->_observers); $i++) {
172
+				$this->_observers[$i]->atTestEnd($method);
173
+			}
174
+			$this->_reporter->paintMethodEnd($method);
175
+		}
176
+
177
+		/**
178
+		 *    Sets up an observer for the test end.
179
+		 *    @param object $observer    Must have atTestEnd()
180
+		 *                               method.
181
+		 *    @access public
182
+		 */
183
+		function tell($observer) {
184
+			$this->_observers[] = $observer;
185
+		}
186
+
187
+		/**
188
+		 *    Sends a pass event with a message.
189
+		 *    @param string $message        Message to send.
190
+		 *    @access public
191
+		 */
192
+		function pass($message = "Pass") {
193
+			if (! isset($this->_reporter)) {
194
+				trigger_error('Can only make assertions within test methods');
195
+			}
196
+			$this->_reporter->paintPass(
197
+					$message . $this->getAssertionLine());
198
+			return true;
199
+		}
200
+
201
+		/**
202
+		 *    Sends a fail event with a message.
203
+		 *    @param string $message        Message to send.
204
+		 *    @access public
205
+		 */
206
+		function fail($message = "Fail") {
207
+			if (! isset($this->_reporter)) {
208
+				trigger_error('Can only make assertions within test methods');
209
+			}
210
+			$this->_reporter->paintFail(
211
+					$message . $this->getAssertionLine());
212
+			return false;
213
+		}
214
+
215
+		/**
216
+		 *    Formats a PHP error and dispatches it to the
217
+		 *    reporter.
218
+		 *    @param integer $severity  PHP error code.
219
+		 *    @param string $message    Text of error.
220
+		 *    @param string $file       File error occoured in.
221
+		 *    @param integer $line      Line number of error.
222
+		 *    @access public
223
+		 */
224
+		function error($severity, $message, $file, $line) {
225
+			if (! isset($this->_reporter)) {
226
+				trigger_error('Can only make assertions within test methods');
227
+			}
228
+			$this->_reporter->paintError(
229
+					"Unexpected PHP error [$message] severity [$severity] in [$file] line [$line]");
230
+		}
231
+
232
+		/**
233
+		 *    Formats an exception and dispatches it to the
234
+		 *    reporter.
235
+		 *    @param Exception $exception    Object thrown.
236
+		 *    @access public
237
+		 */
238
+		function exception($exception) {
239
+			$this->_reporter->paintError(
240
+					'Unexpected exception of type [' . get_class($exception) .
241
+					'] with message ['. $exception->getMessage() .
242
+					'] in ['. $exception->getFile() .
243
+					'] line [' . $exception->getLine() .
244 244
 					'] stack [' . $exception->getTraceAsString() .']');
245
-        }
246
-
247
-        /**
248
-         *    Sends a user defined event to the test reporter.
249
-         *    This is for small scale extension where
250
-         *    both the test case and either the reporter or
251
-         *    display are subclassed.
252
-         *    @param string $type       Type of event.
253
-         *    @param mixed $payload     Object or message to deliver.
254
-         *    @access public
255
-         */
256
-        function signal($type, $payload) {
257
-            if (! isset($this->_reporter)) {
258
-                trigger_error('Can only make assertions within test methods');
259
-            }
260
-            $this->_reporter->paintSignal($type, $payload);
261
-        }
262
-
263
-        /**
264
-         *    Cancels any outstanding errors.
265
-         *    @access public
266
-         */
267
-        function swallowErrors() {
268
-            $queue = &SimpleErrorQueue::instance();
269
-            $queue->clear();
270
-        }
271
-
272
-        /**
273
-         *    Runs an expectation directly, for extending the
274
-         *    tests with new expectation classes.
275
-         *    @param SimpleExpectation $expectation  Expectation subclass.
276
-         *    @param mixed $compare               Value to compare.
277
-         *    @param string $message                 Message to display.
278
-         *    @return boolean                        True on pass
279
-         *    @access public
280
-         */
281
-        function assert($expectation, $compare, $message = '%s') {
282
-            return $this->assertTrue(
283
-                    $expectation->test($compare),
284
-                    sprintf($message, $expectation->overlayMessage($compare)));
285
-        }
286
-
287
-        /**
288
-         *	  @deprecated
289
-         */
290
-        function assertExpectation($expectation, $compare, $message = '%s') {
291
-        	return $this->assert($expectation, $compare, $message);
292
-        }
293
-
294
-        /**
295
-         *    Called from within the test methods to register
296
-         *    passes and failures.
297
-         *    @param boolean $result    Pass on true.
298
-         *    @param string $message    Message to display describing
299
-         *                              the test state.
300
-         *    @return boolean           True on pass
301
-         *    @access public
302
-         */
303
-        function assertTrue($result, $message = false) {
304
-            if (! $message) {
305
-                $message = 'True assertion got ' . ($result ? 'True' : 'False');
306
-            }
307
-            if ($result) {
308
-                return $this->pass($message);
309
-            } else {
310
-                return $this->fail($message);
311
-            }
312
-        }
313
-
314
-        /**
315
-         *    Will be true on false and vice versa. False
316
-         *    is the PHP definition of false, so that null,
317
-         *    empty strings, zero and an empty array all count
318
-         *    as false.
319
-         *    @param boolean $result    Pass on false.
320
-         *    @param string $message    Message to display.
321
-         *    @return boolean           True on pass
322
-         *    @access public
323
-         */
324
-        function assertFalse($result, $message = false) {
325
-            if (! $message) {
326
-                $message = 'False assertion got ' . ($result ? 'True' : 'False');
327
-            }
328
-            return $this->assertTrue(! $result, $message);
329
-        }
330
-
331
-        /**
332
-         *    Uses a stack trace to find the line of an assertion.
333
-         *    @param string $format    String formatting.
334
-         *    @param array $stack      Stack frames top most first. Only
335
-         *                             needed if not using the PHP
336
-         *                             backtrace function.
337
-         *    @return string           Line number of first assert*
338
-         *                             method embedded in format string.
339
-         *    @access public
340
-         */
341
-        function getAssertionLine($stack = false) {
342
-            if ($stack === false) {
343
-                $stack = SimpleTestCompatibility::getStackTrace();
344
-            }
345
-            return SimpleDumper::getFormattedAssertionLine($stack);
346
-        }
347
-
348
-        /**
349
-         *    Sends a formatted dump of a variable to the
350
-         *    test suite for those emergency debugging
351
-         *    situations.
352
-         *    @param mixed $variable    Variable to display.
353
-         *    @param string $message    Message to display.
354
-         *    @return mixed             The original variable.
355
-         *    @access public
356
-         */
357
-        function dump($variable, $message = false) {
358
-            $formatted = SimpleDumper::dump($variable);
359
-            if ($message) {
360
-                $formatted = $message . "\n" . $formatted;
361
-            }
362
-            $this->_reporter->paintFormattedMessage($formatted);
363
-            return $variable;
364
-        }
365
-
366
-        /**
367
-         *    Dispatches a text message straight to the
368
-         *    test suite. Useful for status bar displays.
369
-         *    @param string $message        Message to show.
370
-         *    @access public
371
-         */
372
-        function sendMessage($message) {
373
-            $this->_reporter->PaintMessage($message);
374
-        }
375
-
376
-        /**
377
-         *    Accessor for the number of subtests.
378
-         *    @return integer           Number of test cases.
379
-         *    @access public
380
-         *    @static
381
-         */
382
-        static function getSize() {
383
-            return 1;
384
-        }
385
-    }
386
-
387
-    /**
388
-     *    This is a composite test class for combining
389
-     *    test cases and other RunnableTest classes into
390
-     *    a group test.
245
+		}
246
+
247
+		/**
248
+		 *    Sends a user defined event to the test reporter.
249
+		 *    This is for small scale extension where
250
+		 *    both the test case and either the reporter or
251
+		 *    display are subclassed.
252
+		 *    @param string $type       Type of event.
253
+		 *    @param mixed $payload     Object or message to deliver.
254
+		 *    @access public
255
+		 */
256
+		function signal($type, $payload) {
257
+			if (! isset($this->_reporter)) {
258
+				trigger_error('Can only make assertions within test methods');
259
+			}
260
+			$this->_reporter->paintSignal($type, $payload);
261
+		}
262
+
263
+		/**
264
+		 *    Cancels any outstanding errors.
265
+		 *    @access public
266
+		 */
267
+		function swallowErrors() {
268
+			$queue = &SimpleErrorQueue::instance();
269
+			$queue->clear();
270
+		}
271
+
272
+		/**
273
+		 *    Runs an expectation directly, for extending the
274
+		 *    tests with new expectation classes.
275
+		 *    @param SimpleExpectation $expectation  Expectation subclass.
276
+		 *    @param mixed $compare               Value to compare.
277
+		 *    @param string $message                 Message to display.
278
+		 *    @return boolean                        True on pass
279
+		 *    @access public
280
+		 */
281
+		function assert($expectation, $compare, $message = '%s') {
282
+			return $this->assertTrue(
283
+					$expectation->test($compare),
284
+					sprintf($message, $expectation->overlayMessage($compare)));
285
+		}
286
+
287
+		/**
288
+		 *	  @deprecated
289
+		 */
290
+		function assertExpectation($expectation, $compare, $message = '%s') {
291
+			return $this->assert($expectation, $compare, $message);
292
+		}
293
+
294
+		/**
295
+		 *    Called from within the test methods to register
296
+		 *    passes and failures.
297
+		 *    @param boolean $result    Pass on true.
298
+		 *    @param string $message    Message to display describing
299
+		 *                              the test state.
300
+		 *    @return boolean           True on pass
301
+		 *    @access public
302
+		 */
303
+		function assertTrue($result, $message = false) {
304
+			if (! $message) {
305
+				$message = 'True assertion got ' . ($result ? 'True' : 'False');
306
+			}
307
+			if ($result) {
308
+				return $this->pass($message);
309
+			} else {
310
+				return $this->fail($message);
311
+			}
312
+		}
313
+
314
+		/**
315
+		 *    Will be true on false and vice versa. False
316
+		 *    is the PHP definition of false, so that null,
317
+		 *    empty strings, zero and an empty array all count
318
+		 *    as false.
319
+		 *    @param boolean $result    Pass on false.
320
+		 *    @param string $message    Message to display.
321
+		 *    @return boolean           True on pass
322
+		 *    @access public
323
+		 */
324
+		function assertFalse($result, $message = false) {
325
+			if (! $message) {
326
+				$message = 'False assertion got ' . ($result ? 'True' : 'False');
327
+			}
328
+			return $this->assertTrue(! $result, $message);
329
+		}
330
+
331
+		/**
332
+		 *    Uses a stack trace to find the line of an assertion.
333
+		 *    @param string $format    String formatting.
334
+		 *    @param array $stack      Stack frames top most first. Only
335
+		 *                             needed if not using the PHP
336
+		 *                             backtrace function.
337
+		 *    @return string           Line number of first assert*
338
+		 *                             method embedded in format string.
339
+		 *    @access public
340
+		 */
341
+		function getAssertionLine($stack = false) {
342
+			if ($stack === false) {
343
+				$stack = SimpleTestCompatibility::getStackTrace();
344
+			}
345
+			return SimpleDumper::getFormattedAssertionLine($stack);
346
+		}
347
+
348
+		/**
349
+		 *    Sends a formatted dump of a variable to the
350
+		 *    test suite for those emergency debugging
351
+		 *    situations.
352
+		 *    @param mixed $variable    Variable to display.
353
+		 *    @param string $message    Message to display.
354
+		 *    @return mixed             The original variable.
355
+		 *    @access public
356
+		 */
357
+		function dump($variable, $message = false) {
358
+			$formatted = SimpleDumper::dump($variable);
359
+			if ($message) {
360
+				$formatted = $message . "\n" . $formatted;
361
+			}
362
+			$this->_reporter->paintFormattedMessage($formatted);
363
+			return $variable;
364
+		}
365
+
366
+		/**
367
+		 *    Dispatches a text message straight to the
368
+		 *    test suite. Useful for status bar displays.
369
+		 *    @param string $message        Message to show.
370
+		 *    @access public
371
+		 */
372
+		function sendMessage($message) {
373
+			$this->_reporter->PaintMessage($message);
374
+		}
375
+
376
+		/**
377
+		 *    Accessor for the number of subtests.
378
+		 *    @return integer           Number of test cases.
379
+		 *    @access public
380
+		 *    @static
381
+		 */
382
+		static function getSize() {
383
+			return 1;
384
+		}
385
+	}
386
+
387
+	/**
388
+	 *    This is a composite test class for combining
389
+	 *    test cases and other RunnableTest classes into
390
+	 *    a group test.
391 391
 	 *    @package		SimpleTest
392 392
 	 *    @subpackage	UnitTester
393
-     */
394
-    class GroupTest {
395
-        protected $_label;
396
-        protected $_test_cases;
397
-        protected $_old_track_errors;
398
-        protected $_xdebug_is_enabled;
399
-
400
-        /**
401
-         *    Sets the name of the test suite.
402
-         *    @param string $label    Name sent at the start and end
403
-         *                            of the test.
404
-         *    @access public
405
-         */
406
-        function GroupTest($label = false) {
407
-            $this->_label = $label ? $label : get_class($this);
408
-            $this->_test_cases = array();
409
-            $this->_old_track_errors = ini_get('track_errors');
410
-            $this->_xdebug_is_enabled = function_exists('xdebug_is_enabled') ?
411
-                    xdebug_is_enabled() : false;
412
-        }
413
-
414
-        /**
415
-         *    Accessor for the test name for subclasses.
416
-         *    @return string           Name of the test.
417
-         *    @access public
418
-         */
419
-        function getLabel() {
420
-            return $this->_label;
421
-        }
393
+	 */
394
+	class GroupTest {
395
+		protected $_label;
396
+		protected $_test_cases;
397
+		protected $_old_track_errors;
398
+		protected $_xdebug_is_enabled;
399
+
400
+		/**
401
+		 *    Sets the name of the test suite.
402
+		 *    @param string $label    Name sent at the start and end
403
+		 *                            of the test.
404
+		 *    @access public
405
+		 */
406
+		function GroupTest($label = false) {
407
+			$this->_label = $label ? $label : get_class($this);
408
+			$this->_test_cases = array();
409
+			$this->_old_track_errors = ini_get('track_errors');
410
+			$this->_xdebug_is_enabled = function_exists('xdebug_is_enabled') ?
411
+					xdebug_is_enabled() : false;
412
+		}
413
+
414
+		/**
415
+		 *    Accessor for the test name for subclasses.
416
+		 *    @return string           Name of the test.
417
+		 *    @access public
418
+		 */
419
+		function getLabel() {
420
+			return $this->_label;
421
+		}
422 422
 
423 423
 		function setLabel($value)
424 424
 		{
425 425
 			$this->_label = $value;
426 426
 		}
427 427
 
428
-        /**
429
-         *    Adds a test into the suite. Can be either a group
430
-         *    test or some other unit test.
431
-         *    @param SimpleTestCase $test_case  Suite or individual test
432
-         *                                      case implementing the
433
-         *                                      runnable test interface.
434
-         *    @access public
435
-         */
436
-        function addTestCase($test_case) {
437
-            $this->_test_cases[] = $test_case;
438
-        }
439
-
440
-        /**
441
-         *    Adds a test into the suite by class name. The class will
442
-         *    be instantiated as needed.
443
-         *    @param SimpleTestCase $test_case  Suite or individual test
444
-         *                                      case implementing the
445
-         *                                      runnable test interface.
446
-         *    @access public
447
-         */
448
-        function addTestClass($class) {
449
-            if ($this->_getBaseTestCase($class) == 'grouptest') {
450
-                $this->_test_cases[] = new $class();
451
-            } else {
452
-                $this->_test_cases[] = $class;
453
-            }
454
-        }
455
-
456
-        /**
457
-         *    Builds a group test from a library of test cases.
458
-         *    The new group is composed into this one.
459
-         *    @param string $test_file        File name of library with
460
-         *                                    test case classes.
461
-         *    @access public
462
-         */
463
-        function addTestFile($test_file) {
464
-            $existing_classes = get_declared_classes();
465
-            if ($error = $this->_requireWithError($test_file)) {
466
-                $this->addTestCase(new BadGroupTest($test_file, $error));
467
-                return;
468
-            }
469
-            $classes = $this->_selectRunnableTests($existing_classes, get_declared_classes());
470
-            if (count($classes) == 0) {
471
-                $this->addTestCase(new BadGroupTest($test_file, "No runnable test cases in [$test_file]"));
472
-                return;
473
-            }
474
-            $group = $this->_createGroupFromClasses($test_file, $classes);
475
-            $this->addTestCase($group);
476
-        }
477
-
478
-        /**
479
-         *    Requires a source file recording any syntax errors.
480
-         *    @param string $file        File name to require in.
481
-         *    @return string/boolean     An error message on failure or false
482
-         *                               if no errors.
483
-         *    @access private
484
-         */
485
-        function _requireWithError($file) {
486
-            $this->_enableErrorReporting();
487
-            include_once($file);
488
-            $error = isset($php_errormsg) ? $php_errormsg : false;
489
-            $this->_disableErrorReporting();
490
-            $self_inflicted_errors = array(
491
-                    'Assigning the return value of new by reference is deprecated',
492
-                    'var: Deprecated. Please use the public/private/protected modifiers');
493
-            if (in_array($error, $self_inflicted_errors)) {
494
-                return false;
495
-            }
496
-            return $error;
497
-        }
498
-
499
-        /**
500
-         *    Sets up detection of parse errors. Note that XDebug
501
-         *    interferes with this and has to be disabled. This is
502
-         *    to make sure the correct error code is returned
503
-         *    from unattended scripts.
504
-         *    @access private
505
-         */
506
-        function _enableErrorReporting() {
507
-            if ($this->_xdebug_is_enabled) {
508
-                xdebug_disable();
509
-            }
510
-            ini_set('track_errors', true);
511
-        }
512
-
513
-        /**
514
-         *    Resets detection of parse errors to their old values.
515
-         *    This is to make sure the correct error code is returned
516
-         *    from unattended scripts.
517
-         *    @access private
518
-         */
519
-        function _disableErrorReporting() {
520
-            ini_set('track_errors', $this->_old_track_errors);
521
-            if ($this->_xdebug_is_enabled) {
522
-                xdebug_enable();
523
-            }
524
-        }
525
-
526
-        /**
527
-         *    Calculates the incoming test cases from a before
528
-         *    and after list of loaded classes. Skips abstract
529
-         *    classes.
530
-         *    @param array $existing_classes   Classes before require().
531
-         *    @param array $new_classes        Classes after require().
532
-         *    @return array                    New classes which are test
533
-         *                                     cases that shouldn't be ignored.
534
-         *    @access private
535
-         */
536
-        function _selectRunnableTests($existing_classes, $new_classes) {
537
-            $classes = array();
538
-            foreach ($new_classes as $class) {
539
-                if (in_array($class, $existing_classes)) {
540
-                    continue;
541
-                }
542
-                if ($this->_getBaseTestCase($class)) {
543
-                    $reflection = new SimpleReflection($class);
544
-                    if ($reflection->isAbstract()) {
545
-                        SimpleTest::ignore($class);
546
-                    }
547
-                    $classes[] = $class;
548
-                }
549
-            }
550
-            return $classes;
551
-        }
552
-
553
-        /**
554
-         *    Builds a group test from a class list.
555
-         *    @param string $title       Title of new group.
556
-         *    @param array $classes      Test classes.
557
-         *    @return GroupTest          Group loaded with the new
558
-         *                               test cases.
559
-         *    @access private
560
-         */
561
-        function &_createGroupFromClasses($title, $classes) {
562
-            SimpleTest::ignoreParentsIfIgnored($classes);
563
-            $group = new GroupTest($title);
564
-            foreach ($classes as $class) {
565
-                if (! SimpleTest::isIgnored($class)) {
566
-                    $group->addTestClass($class);
567
-                }
568
-            }
569
-            return $group;
570
-        }
571
-
572
-        /**
573
-         *    Test to see if a class is derived from the
574
-         *    SimpleTestCase class.
575
-         *    @param string $class     Class name.
576
-         *    @access private
577
-         */
578
-        function _getBaseTestCase($class) {
579
-            while ($class = get_parent_class($class)) {
580
-                $class = strtolower($class);
581
-                if ($class == "simpletestcase" || $class == "grouptest") {
582
-                    return $class;
583
-                }
584
-            }
585
-            return false;
586
-        }
587
-
588
-        /**
589
-         *    Delegates to a visiting collector to add test
590
-         *    files.
591
-         *    @param string $path                  Path to scan from.
592
-         *    @param SimpleCollector $collector    Directory scanner.
593
-         *    @access public
594
-         */
595
-        function collect($path, $collector) {
596
-            $collector->collect($this, $path);
597
-        }
598
-
599
-        /**
600
-         *    Invokes run() on all of the held test cases, instantiating
601
-         *    them if necessary.
602
-         *    @param SimpleReporter $reporter    Current test reporter.
603
-         *    @access public
604
-         */
605
-        function run($reporter) {
606
-            $reporter->paintGroupStart($this->getLabel(), $this->getSize());
607
-            for ($i = 0, $count = count($this->_test_cases); $i < $count; $i++) {
608
-                if (is_string($this->_test_cases[$i])) {
609
-                    $class = $this->_test_cases[$i];
610
-                    $test = new $class();
611
-                    $test->run($reporter);
612
-                } else {
613
-                    $this->_test_cases[$i]->run($reporter);
614
-                }
615
-            }
616
-            $reporter->paintGroupEnd($this->getLabel());
617
-            return $reporter->getStatus();
618
-        }
619
-
620
-        /**
621
-         *    Number of contained test cases.
622
-         *    @return integer     Total count of cases in the group.
623
-         *    @access public
624
-         */
625
-        function getSize() {
626
-            $count = 0;
627
-            foreach ($this->_test_cases as $case) {
628
-                if (is_string($case)) {
629
-                    $count++;
630
-                } else {
631
-                    $count += $case->getSize();
632
-                }
633
-            }
634
-            return $count;
635
-        }
636
-    }
637
-
638
-    /**
639
-     *    This is a failing group test for when a test suite hasn't
640
-     *    loaded properly.
428
+		/**
429
+		 *    Adds a test into the suite. Can be either a group
430
+		 *    test or some other unit test.
431
+		 *    @param SimpleTestCase $test_case  Suite or individual test
432
+		 *                                      case implementing the
433
+		 *                                      runnable test interface.
434
+		 *    @access public
435
+		 */
436
+		function addTestCase($test_case) {
437
+			$this->_test_cases[] = $test_case;
438
+		}
439
+
440
+		/**
441
+		 *    Adds a test into the suite by class name. The class will
442
+		 *    be instantiated as needed.
443
+		 *    @param SimpleTestCase $test_case  Suite or individual test
444
+		 *                                      case implementing the
445
+		 *                                      runnable test interface.
446
+		 *    @access public
447
+		 */
448
+		function addTestClass($class) {
449
+			if ($this->_getBaseTestCase($class) == 'grouptest') {
450
+				$this->_test_cases[] = new $class();
451
+			} else {
452
+				$this->_test_cases[] = $class;
453
+			}
454
+		}
455
+
456
+		/**
457
+		 *    Builds a group test from a library of test cases.
458
+		 *    The new group is composed into this one.
459
+		 *    @param string $test_file        File name of library with
460
+		 *                                    test case classes.
461
+		 *    @access public
462
+		 */
463
+		function addTestFile($test_file) {
464
+			$existing_classes = get_declared_classes();
465
+			if ($error = $this->_requireWithError($test_file)) {
466
+				$this->addTestCase(new BadGroupTest($test_file, $error));
467
+				return;
468
+			}
469
+			$classes = $this->_selectRunnableTests($existing_classes, get_declared_classes());
470
+			if (count($classes) == 0) {
471
+				$this->addTestCase(new BadGroupTest($test_file, "No runnable test cases in [$test_file]"));
472
+				return;
473
+			}
474
+			$group = $this->_createGroupFromClasses($test_file, $classes);
475
+			$this->addTestCase($group);
476
+		}
477
+
478
+		/**
479
+		 *    Requires a source file recording any syntax errors.
480
+		 *    @param string $file        File name to require in.
481
+		 *    @return string/boolean     An error message on failure or false
482
+		 *                               if no errors.
483
+		 *    @access private
484
+		 */
485
+		function _requireWithError($file) {
486
+			$this->_enableErrorReporting();
487
+			include_once($file);
488
+			$error = isset($php_errormsg) ? $php_errormsg : false;
489
+			$this->_disableErrorReporting();
490
+			$self_inflicted_errors = array(
491
+					'Assigning the return value of new by reference is deprecated',
492
+					'var: Deprecated. Please use the public/private/protected modifiers');
493
+			if (in_array($error, $self_inflicted_errors)) {
494
+				return false;
495
+			}
496
+			return $error;
497
+		}
498
+
499
+		/**
500
+		 *    Sets up detection of parse errors. Note that XDebug
501
+		 *    interferes with this and has to be disabled. This is
502
+		 *    to make sure the correct error code is returned
503
+		 *    from unattended scripts.
504
+		 *    @access private
505
+		 */
506
+		function _enableErrorReporting() {
507
+			if ($this->_xdebug_is_enabled) {
508
+				xdebug_disable();
509
+			}
510
+			ini_set('track_errors', true);
511
+		}
512
+
513
+		/**
514
+		 *    Resets detection of parse errors to their old values.
515
+		 *    This is to make sure the correct error code is returned
516
+		 *    from unattended scripts.
517
+		 *    @access private
518
+		 */
519
+		function _disableErrorReporting() {
520
+			ini_set('track_errors', $this->_old_track_errors);
521
+			if ($this->_xdebug_is_enabled) {
522
+				xdebug_enable();
523
+			}
524
+		}
525
+
526
+		/**
527
+		 *    Calculates the incoming test cases from a before
528
+		 *    and after list of loaded classes. Skips abstract
529
+		 *    classes.
530
+		 *    @param array $existing_classes   Classes before require().
531
+		 *    @param array $new_classes        Classes after require().
532
+		 *    @return array                    New classes which are test
533
+		 *                                     cases that shouldn't be ignored.
534
+		 *    @access private
535
+		 */
536
+		function _selectRunnableTests($existing_classes, $new_classes) {
537
+			$classes = array();
538
+			foreach ($new_classes as $class) {
539
+				if (in_array($class, $existing_classes)) {
540
+					continue;
541
+				}
542
+				if ($this->_getBaseTestCase($class)) {
543
+					$reflection = new SimpleReflection($class);
544
+					if ($reflection->isAbstract()) {
545
+						SimpleTest::ignore($class);
546
+					}
547
+					$classes[] = $class;
548
+				}
549
+			}
550
+			return $classes;
551
+		}
552
+
553
+		/**
554
+		 *    Builds a group test from a class list.
555
+		 *    @param string $title       Title of new group.
556
+		 *    @param array $classes      Test classes.
557
+		 *    @return GroupTest          Group loaded with the new
558
+		 *                               test cases.
559
+		 *    @access private
560
+		 */
561
+		function &_createGroupFromClasses($title, $classes) {
562
+			SimpleTest::ignoreParentsIfIgnored($classes);
563
+			$group = new GroupTest($title);
564
+			foreach ($classes as $class) {
565
+				if (! SimpleTest::isIgnored($class)) {
566
+					$group->addTestClass($class);
567
+				}
568
+			}
569
+			return $group;
570
+		}
571
+
572
+		/**
573
+		 *    Test to see if a class is derived from the
574
+		 *    SimpleTestCase class.
575
+		 *    @param string $class     Class name.
576
+		 *    @access private
577
+		 */
578
+		function _getBaseTestCase($class) {
579
+			while ($class = get_parent_class($class)) {
580
+				$class = strtolower($class);
581
+				if ($class == "simpletestcase" || $class == "grouptest") {
582
+					return $class;
583
+				}
584
+			}
585
+			return false;
586
+		}
587
+
588
+		/**
589
+		 *    Delegates to a visiting collector to add test
590
+		 *    files.
591
+		 *    @param string $path                  Path to scan from.
592
+		 *    @param SimpleCollector $collector    Directory scanner.
593
+		 *    @access public
594
+		 */
595
+		function collect($path, $collector) {
596
+			$collector->collect($this, $path);
597
+		}
598
+
599
+		/**
600
+		 *    Invokes run() on all of the held test cases, instantiating
601
+		 *    them if necessary.
602
+		 *    @param SimpleReporter $reporter    Current test reporter.
603
+		 *    @access public
604
+		 */
605
+		function run($reporter) {
606
+			$reporter->paintGroupStart($this->getLabel(), $this->getSize());
607
+			for ($i = 0, $count = count($this->_test_cases); $i < $count; $i++) {
608
+				if (is_string($this->_test_cases[$i])) {
609
+					$class = $this->_test_cases[$i];
610
+					$test = new $class();
611
+					$test->run($reporter);
612
+				} else {
613
+					$this->_test_cases[$i]->run($reporter);
614
+				}
615
+			}
616
+			$reporter->paintGroupEnd($this->getLabel());
617
+			return $reporter->getStatus();
618
+		}
619
+
620
+		/**
621
+		 *    Number of contained test cases.
622
+		 *    @return integer     Total count of cases in the group.
623
+		 *    @access public
624
+		 */
625
+		function getSize() {
626
+			$count = 0;
627
+			foreach ($this->_test_cases as $case) {
628
+				if (is_string($case)) {
629
+					$count++;
630
+				} else {
631
+					$count += $case->getSize();
632
+				}
633
+			}
634
+			return $count;
635
+		}
636
+	}
637
+
638
+	/**
639
+	 *    This is a failing group test for when a test suite hasn't
640
+	 *    loaded properly.
641 641
 	 *    @package		SimpleTest
642 642
 	 *    @subpackage	UnitTester
643
-     */
644
-    class BadGroupTest {
645
-        protected $_label;
646
-        protected $_error;
647
-
648
-        /**
649
-         *    Sets the name of the test suite and error message.
650
-         *    @param string $label    Name sent at the start and end
651
-         *                            of the test.
652
-         *    @access public
653
-         */
654
-        function BadGroupTest($label, $error) {
655
-            $this->_label = $label;
656
-            $this->_error = $error;
657
-        }
658
-
659
-        /**
660
-         *    Accessor for the test name for subclasses.
661
-         *    @return string           Name of the test.
662
-         *    @access public
663
-         */
664
-        function getLabel() {
665
-            return $this->_label;
666
-        }
667
-
668
-        /**
669
-         *    Sends a single error to the reporter.
670
-         *    @param SimpleReporter $reporter    Current test reporter.
671
-         *    @access public
672
-         */
673
-        function run($reporter) {
674
-            $reporter->paintGroupStart($this->getLabel(), $this->getSize());
675
-            $reporter->paintFail('Bad GroupTest [' . $this->getLabel() .
676
-                    '] with error [' . $this->_error . ']');
677
-            $reporter->paintGroupEnd($this->getLabel());
678
-            return $reporter->getStatus();
679
-        }
680
-
681
-        /**
682
-         *    Number of contained test cases. Always zero.
683
-         *    @return integer     Total count of cases in the group.
684
-         *    @access public
685
-         */
686
-        function getSize() {
687
-            return 0;
688
-        }
689
-    }
643
+	 */
644
+	class BadGroupTest {
645
+		protected $_label;
646
+		protected $_error;
647
+
648
+		/**
649
+		 *    Sets the name of the test suite and error message.
650
+		 *    @param string $label    Name sent at the start and end
651
+		 *                            of the test.
652
+		 *    @access public
653
+		 */
654
+		function BadGroupTest($label, $error) {
655
+			$this->_label = $label;
656
+			$this->_error = $error;
657
+		}
658
+
659
+		/**
660
+		 *    Accessor for the test name for subclasses.
661
+		 *    @return string           Name of the test.
662
+		 *    @access public
663
+		 */
664
+		function getLabel() {
665
+			return $this->_label;
666
+		}
667
+
668
+		/**
669
+		 *    Sends a single error to the reporter.
670
+		 *    @param SimpleReporter $reporter    Current test reporter.
671
+		 *    @access public
672
+		 */
673
+		function run($reporter) {
674
+			$reporter->paintGroupStart($this->getLabel(), $this->getSize());
675
+			$reporter->paintFail('Bad GroupTest [' . $this->getLabel() .
676
+					'] with error [' . $this->_error . ']');
677
+			$reporter->paintGroupEnd($this->getLabel());
678
+			return $reporter->getStatus();
679
+		}
680
+
681
+		/**
682
+		 *    Number of contained test cases. Always zero.
683
+		 *    @return integer     Total count of cases in the group.
684
+		 *    @access public
685
+		 */
686
+		function getSize() {
687
+			return 0;
688
+		}
689
+	}
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     } else {
24 24
         require_once(dirname(__FILE__) . '/reflection_php4.php');
25 25
     }
26
-    if (! defined('SIMPLE_TEST')) {
26
+    if (!defined('SIMPLE_TEST')) {
27 27
         /**
28 28
          * @ignore
29 29
          */
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
          */
131 131
         function _isTest($method) {
132 132
             if (strtolower(substr($method, 0, 4)) == 'test') {
133
-                return ! SimpleTestCompatibility::isA($this, strtolower($method));
133
+                return !SimpleTestCompatibility::isA($this, strtolower($method));
134 134
             }
135 135
             return false;
136 136
         }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
          *    @access public
191 191
          */
192 192
         function pass($message = "Pass") {
193
-            if (! isset($this->_reporter)) {
193
+            if (!isset($this->_reporter)) {
194 194
                 trigger_error('Can only make assertions within test methods');
195 195
             }
196 196
             $this->_reporter->paintPass(
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
          *    @access public
205 205
          */
206 206
         function fail($message = "Fail") {
207
-            if (! isset($this->_reporter)) {
207
+            if (!isset($this->_reporter)) {
208 208
                 trigger_error('Can only make assertions within test methods');
209 209
             }
210 210
             $this->_reporter->paintFail(
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
          *    @access public
223 223
          */
224 224
         function error($severity, $message, $file, $line) {
225
-            if (! isset($this->_reporter)) {
225
+            if (!isset($this->_reporter)) {
226 226
                 trigger_error('Can only make assertions within test methods');
227 227
             }
228 228
             $this->_reporter->paintError(
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
         function exception($exception) {
239 239
             $this->_reporter->paintError(
240 240
                     'Unexpected exception of type [' . get_class($exception) .
241
-                    '] with message ['. $exception->getMessage() .
242
-                    '] in ['. $exception->getFile() .
241
+                    '] with message [' . $exception->getMessage() .
242
+                    '] in [' . $exception->getFile() .
243 243
                     '] line [' . $exception->getLine() .
244
-					'] stack [' . $exception->getTraceAsString() .']');
244
+					'] stack [' . $exception->getTraceAsString() . ']');
245 245
         }
246 246
 
247 247
         /**
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
          *    @access public
255 255
          */
256 256
         function signal($type, $payload) {
257
-            if (! isset($this->_reporter)) {
257
+            if (!isset($this->_reporter)) {
258 258
                 trigger_error('Can only make assertions within test methods');
259 259
             }
260 260
             $this->_reporter->paintSignal($type, $payload);
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
          *    @access public
302 302
          */
303 303
         function assertTrue($result, $message = false) {
304
-            if (! $message) {
304
+            if (!$message) {
305 305
                 $message = 'True assertion got ' . ($result ? 'True' : 'False');
306 306
             }
307 307
             if ($result) {
@@ -322,10 +322,10 @@  discard block
 block discarded – undo
322 322
          *    @access public
323 323
          */
324 324
         function assertFalse($result, $message = false) {
325
-            if (! $message) {
325
+            if (!$message) {
326 326
                 $message = 'False assertion got ' . ($result ? 'True' : 'False');
327 327
             }
328
-            return $this->assertTrue(! $result, $message);
328
+            return $this->assertTrue(!$result, $message);
329 329
         }
330 330
 
331 331
         /**
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
             SimpleTest::ignoreParentsIfIgnored($classes);
563 563
             $group = new GroupTest($title);
564 564
             foreach ($classes as $class) {
565
-                if (! SimpleTest::isIgnored($class)) {
565
+                if (!SimpleTest::isIgnored($class)) {
566 566
                     $group->addTestClass($class);
567 567
                 }
568 568
             }
Please login to merge, or discard this patch.
tests/test_tools/simpletest/unit_tester.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
         /**
186 186
          *    Will trigger a pass if the two parameters have
187 187
          *    the different value or different type.
188
-         *    @param mixed $first           Value to compare.
188
+         *    @param TActiveRecord $first           Value to compare.
189 189
          *    @param mixed $second          Value to compare.
190 190
          *    @param string $message        Message to display.
191 191
          *    @return boolean               True on pass
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
          *    Creates an equality expectation if the
353 353
          *    object/value is not already some type
354 354
          *    of expectation.
355
-         *    @param mixed $expected      Expected value.
355
+         *    @param string $expected      Expected value.
356 356
          *    @return SimpleExpectation   Expectation object.
357 357
          *    @access private
358 358
          */
Please login to merge, or discard this patch.
Indentation   +343 added lines, -343 removed lines patch added patch discarded remove patch
@@ -1,372 +1,372 @@
 block discarded – undo
1 1
 <?php
2
-    /**
3
-     *	base include file for SimpleTest
4
-     *	@package	SimpleTest
5
-     *	@subpackage	UnitTester
6
-     *	@version	$Id: unit_tester.php 1398 2006-09-08 19:31:03Z xue $
7
-     */
2
+	/**
3
+	 *	base include file for SimpleTest
4
+	 *	@package	SimpleTest
5
+	 *	@subpackage	UnitTester
6
+	 *	@version	$Id: unit_tester.php 1398 2006-09-08 19:31:03Z xue $
7
+	 */
8 8
 
9
-    /**#@+
9
+	/**#@+
10 10
      *	include other SimpleTest class files
11 11
      */
12
-    require_once(dirname(__FILE__) . '/test_case.php');
13
-    require_once(dirname(__FILE__) . '/dumper.php');
14
-    /**#@-*/
12
+	require_once(dirname(__FILE__) . '/test_case.php');
13
+	require_once(dirname(__FILE__) . '/dumper.php');
14
+	/**#@-*/
15 15
 
16
-    /**
17
-     *    Standard unit test class for day to day testing
18
-     *    of PHP code XP style. Adds some useful standard
19
-     *    assertions.
16
+	/**
17
+	 *    Standard unit test class for day to day testing
18
+	 *    of PHP code XP style. Adds some useful standard
19
+	 *    assertions.
20 20
 	 *	  @package	SimpleTest
21 21
 	 *	  @subpackage	UnitTester
22
-     */
23
-    class UnitTestCase extends SimpleTestCase {
22
+	 */
23
+	class UnitTestCase extends SimpleTestCase {
24 24
 
25
-        /**
26
-         *    Creates an empty test case. Should be subclassed
27
-         *    with test methods for a functional test case.
28
-         *    @param string $label     Name of test case. Will use
29
-         *                             the class name if none specified.
30
-         *    @access public
31
-         */
32
-        function UnitTestCase($label = false) {
33
-            if (! $label) {
34
-                $label = get_class($this);
35
-            }
36
-            $this->SimpleTestCase($label);
37
-        }
25
+		/**
26
+		 *    Creates an empty test case. Should be subclassed
27
+		 *    with test methods for a functional test case.
28
+		 *    @param string $label     Name of test case. Will use
29
+		 *                             the class name if none specified.
30
+		 *    @access public
31
+		 */
32
+		function UnitTestCase($label = false) {
33
+			if (! $label) {
34
+				$label = get_class($this);
35
+			}
36
+			$this->SimpleTestCase($label);
37
+		}
38 38
 
39
-        /**
40
-         *    Will be true if the value is null.
41
-         *    @param null $value       Supposedly null value.
42
-         *    @param string $message   Message to display.
43
-         *    @return boolean                        True on pass
44
-         *    @access public
45
-         */
46
-        function assertNull($value, $message = "%s") {
47
-            $dumper = new SimpleDumper();
48
-            $message = sprintf(
49
-                    $message,
50
-                    "[" . $dumper->describeValue($value) . "] should be null");
51
-            return $this->assertTrue(! isset($value), $message);
52
-        }
39
+		/**
40
+		 *    Will be true if the value is null.
41
+		 *    @param null $value       Supposedly null value.
42
+		 *    @param string $message   Message to display.
43
+		 *    @return boolean                        True on pass
44
+		 *    @access public
45
+		 */
46
+		function assertNull($value, $message = "%s") {
47
+			$dumper = new SimpleDumper();
48
+			$message = sprintf(
49
+					$message,
50
+					"[" . $dumper->describeValue($value) . "] should be null");
51
+			return $this->assertTrue(! isset($value), $message);
52
+		}
53 53
 
54
-        /**
55
-         *    Will be true if the value is set.
56
-         *    @param mixed $value           Supposedly set value.
57
-         *    @param string $message        Message to display.
58
-         *    @return boolean               True on pass.
59
-         *    @access public
60
-         */
61
-        function assertNotNull($value, $message = "%s") {
62
-            $dumper = new SimpleDumper();
63
-            $message = sprintf(
64
-                    $message,
65
-                    "[" . $dumper->describeValue($value) . "] should not be null");
66
-            return $this->assertTrue(isset($value), $message);
67
-        }
54
+		/**
55
+		 *    Will be true if the value is set.
56
+		 *    @param mixed $value           Supposedly set value.
57
+		 *    @param string $message        Message to display.
58
+		 *    @return boolean               True on pass.
59
+		 *    @access public
60
+		 */
61
+		function assertNotNull($value, $message = "%s") {
62
+			$dumper = new SimpleDumper();
63
+			$message = sprintf(
64
+					$message,
65
+					"[" . $dumper->describeValue($value) . "] should not be null");
66
+			return $this->assertTrue(isset($value), $message);
67
+		}
68 68
 
69
-        /**
70
-         *    Type and class test. Will pass if class
71
-         *    matches the type name or is a subclass or
72
-         *    if not an object, but the type is correct.
73
-         *    @param mixed $object         Object to test.
74
-         *    @param string $type          Type name as string.
75
-         *    @param string $message       Message to display.
76
-         *    @return boolean              True on pass.
77
-         *    @access public
78
-         */
79
-        function assertIsA($object, $type, $message = "%s") {
80
-            return $this->assert(
81
-                    new IsAExpectation($type),
82
-                    $object,
83
-                    $message);
84
-        }
69
+		/**
70
+		 *    Type and class test. Will pass if class
71
+		 *    matches the type name or is a subclass or
72
+		 *    if not an object, but the type is correct.
73
+		 *    @param mixed $object         Object to test.
74
+		 *    @param string $type          Type name as string.
75
+		 *    @param string $message       Message to display.
76
+		 *    @return boolean              True on pass.
77
+		 *    @access public
78
+		 */
79
+		function assertIsA($object, $type, $message = "%s") {
80
+			return $this->assert(
81
+					new IsAExpectation($type),
82
+					$object,
83
+					$message);
84
+		}
85 85
 
86
-        /**
87
-         *    Type and class mismatch test. Will pass if class
88
-         *    name or underling type does not match the one
89
-         *    specified.
90
-         *    @param mixed $object         Object to test.
91
-         *    @param string $type          Type name as string.
92
-         *    @param string $message       Message to display.
93
-         *    @return boolean              True on pass.
94
-         *    @access public
95
-         */
96
-        function assertNotA($object, $type, $message = "%s") {
97
-            return $this->assert(
98
-                    new NotAExpectation($type),
99
-                    $object,
100
-                    $message);
101
-        }
86
+		/**
87
+		 *    Type and class mismatch test. Will pass if class
88
+		 *    name or underling type does not match the one
89
+		 *    specified.
90
+		 *    @param mixed $object         Object to test.
91
+		 *    @param string $type          Type name as string.
92
+		 *    @param string $message       Message to display.
93
+		 *    @return boolean              True on pass.
94
+		 *    @access public
95
+		 */
96
+		function assertNotA($object, $type, $message = "%s") {
97
+			return $this->assert(
98
+					new NotAExpectation($type),
99
+					$object,
100
+					$message);
101
+		}
102 102
 
103
-        /**
104
-         *    Will trigger a pass if the two parameters have
105
-         *    the same value only. Otherwise a fail.
106
-         *    @param mixed $first          Value to compare.
107
-         *    @param mixed $second         Value to compare.
108
-         *    @param string $message       Message to display.
109
-         *    @return boolean              True on pass
110
-         *    @access public
111
-         */
112
-        function assertEqual($first, $second, $message = "%s") {
113
-            return $this->assert(
114
-                    new EqualExpectation($first),
115
-                    $second,
116
-                    $message);
117
-        }
103
+		/**
104
+		 *    Will trigger a pass if the two parameters have
105
+		 *    the same value only. Otherwise a fail.
106
+		 *    @param mixed $first          Value to compare.
107
+		 *    @param mixed $second         Value to compare.
108
+		 *    @param string $message       Message to display.
109
+		 *    @return boolean              True on pass
110
+		 *    @access public
111
+		 */
112
+		function assertEqual($first, $second, $message = "%s") {
113
+			return $this->assert(
114
+					new EqualExpectation($first),
115
+					$second,
116
+					$message);
117
+		}
118 118
 
119
-        /**
120
-         *    Will trigger a pass if the two parameters have
121
-         *    a different value. Otherwise a fail.
122
-         *    @param mixed $first           Value to compare.
123
-         *    @param mixed $second          Value to compare.
124
-         *    @param string $message        Message to display.
125
-         *    @return boolean               True on pass
126
-         *    @access public
127
-         */
128
-        function assertNotEqual($first, $second, $message = "%s") {
129
-            return $this->assert(
130
-                    new NotEqualExpectation($first),
131
-                    $second,
132
-                    $message);
133
-        }
119
+		/**
120
+		 *    Will trigger a pass if the two parameters have
121
+		 *    a different value. Otherwise a fail.
122
+		 *    @param mixed $first           Value to compare.
123
+		 *    @param mixed $second          Value to compare.
124
+		 *    @param string $message        Message to display.
125
+		 *    @return boolean               True on pass
126
+		 *    @access public
127
+		 */
128
+		function assertNotEqual($first, $second, $message = "%s") {
129
+			return $this->assert(
130
+					new NotEqualExpectation($first),
131
+					$second,
132
+					$message);
133
+		}
134 134
 
135
-        /**
136
-         *    Will trigger a pass if the if the first parameter
137
-         *    is near enough to the second by the margin.
138
-         *    @param mixed $first          Value to compare.
139
-         *    @param mixed $second         Value to compare.
140
-         *    @param mixed $margin         Fuzziness of match.
141
-         *    @param string $message       Message to display.
142
-         *    @return boolean              True on pass
143
-         *    @access public
144
-         */
145
-        function assertWithinMargin($first, $second, $margin, $message = "%s") {
146
-            return $this->assert(
147
-                    new WithinMarginExpectation($first, $margin),
148
-                    $second,
149
-                    $message);
150
-        }
135
+		/**
136
+		 *    Will trigger a pass if the if the first parameter
137
+		 *    is near enough to the second by the margin.
138
+		 *    @param mixed $first          Value to compare.
139
+		 *    @param mixed $second         Value to compare.
140
+		 *    @param mixed $margin         Fuzziness of match.
141
+		 *    @param string $message       Message to display.
142
+		 *    @return boolean              True on pass
143
+		 *    @access public
144
+		 */
145
+		function assertWithinMargin($first, $second, $margin, $message = "%s") {
146
+			return $this->assert(
147
+					new WithinMarginExpectation($first, $margin),
148
+					$second,
149
+					$message);
150
+		}
151 151
 
152
-        /**
153
-         *    Will trigger a pass if the two parameters differ
154
-         *    by more than the margin.
155
-         *    @param mixed $first          Value to compare.
156
-         *    @param mixed $second         Value to compare.
157
-         *    @param mixed $margin         Fuzziness of match.
158
-         *    @param string $message       Message to display.
159
-         *    @return boolean              True on pass
160
-         *    @access public
161
-         */
162
-        function assertOutsideMargin($first, $second, $margin, $message = "%s") {
163
-            return $this->assert(
164
-                    new OutsideMarginExpectation($first, $margin),
165
-                    $second,
166
-                    $message);
167
-        }
152
+		/**
153
+		 *    Will trigger a pass if the two parameters differ
154
+		 *    by more than the margin.
155
+		 *    @param mixed $first          Value to compare.
156
+		 *    @param mixed $second         Value to compare.
157
+		 *    @param mixed $margin         Fuzziness of match.
158
+		 *    @param string $message       Message to display.
159
+		 *    @return boolean              True on pass
160
+		 *    @access public
161
+		 */
162
+		function assertOutsideMargin($first, $second, $margin, $message = "%s") {
163
+			return $this->assert(
164
+					new OutsideMarginExpectation($first, $margin),
165
+					$second,
166
+					$message);
167
+		}
168 168
 
169
-        /**
170
-         *    Will trigger a pass if the two parameters have
171
-         *    the same value and same type. Otherwise a fail.
172
-         *    @param mixed $first           Value to compare.
173
-         *    @param mixed $second          Value to compare.
174
-         *    @param string $message        Message to display.
175
-         *    @return boolean               True on pass
176
-         *    @access public
177
-         */
178
-        function assertIdentical($first, $second, $message = "%s") {
179
-            return $this->assert(
180
-                    new IdenticalExpectation($first),
181
-                    $second,
182
-                    $message);
183
-        }
169
+		/**
170
+		 *    Will trigger a pass if the two parameters have
171
+		 *    the same value and same type. Otherwise a fail.
172
+		 *    @param mixed $first           Value to compare.
173
+		 *    @param mixed $second          Value to compare.
174
+		 *    @param string $message        Message to display.
175
+		 *    @return boolean               True on pass
176
+		 *    @access public
177
+		 */
178
+		function assertIdentical($first, $second, $message = "%s") {
179
+			return $this->assert(
180
+					new IdenticalExpectation($first),
181
+					$second,
182
+					$message);
183
+		}
184 184
 
185
-        /**
186
-         *    Will trigger a pass if the two parameters have
187
-         *    the different value or different type.
188
-         *    @param mixed $first           Value to compare.
189
-         *    @param mixed $second          Value to compare.
190
-         *    @param string $message        Message to display.
191
-         *    @return boolean               True on pass
192
-         *    @access public
193
-         */
194
-        function assertNotIdentical($first, $second, $message = "%s") {
195
-            return $this->assert(
196
-                    new NotIdenticalExpectation($first),
197
-                    $second,
198
-                    $message);
199
-        }
185
+		/**
186
+		 *    Will trigger a pass if the two parameters have
187
+		 *    the different value or different type.
188
+		 *    @param mixed $first           Value to compare.
189
+		 *    @param mixed $second          Value to compare.
190
+		 *    @param string $message        Message to display.
191
+		 *    @return boolean               True on pass
192
+		 *    @access public
193
+		 */
194
+		function assertNotIdentical($first, $second, $message = "%s") {
195
+			return $this->assert(
196
+					new NotIdenticalExpectation($first),
197
+					$second,
198
+					$message);
199
+		}
200 200
 
201
-        /**
202
-         *    Will trigger a pass if both parameters refer
203
-         *    to the same object. Fail otherwise.
204
-         *    @param mixed $first           Object reference to check.
205
-         *    @param mixed $second          Hopefully the same object.
206
-         *    @param string $message        Message to display.
207
-         *    @return boolean               True on pass
208
-         *    @access public
209
-         */
210
-        function assertReference($first, $second, $message = "%s") {
211
-            $dumper = new SimpleDumper();
212
-            $message = sprintf(
213
-                    $message,
214
-                    "[" . $dumper->describeValue($first) .
215
-                            "] and [" . $dumper->describeValue($second) .
216
-                            "] should reference the same object");
217
-            return $this->assertTrue(
218
-                    SimpleTestCompatibility::isReference($first, $second),
219
-                    $message);
220
-        }
201
+		/**
202
+		 *    Will trigger a pass if both parameters refer
203
+		 *    to the same object. Fail otherwise.
204
+		 *    @param mixed $first           Object reference to check.
205
+		 *    @param mixed $second          Hopefully the same object.
206
+		 *    @param string $message        Message to display.
207
+		 *    @return boolean               True on pass
208
+		 *    @access public
209
+		 */
210
+		function assertReference($first, $second, $message = "%s") {
211
+			$dumper = new SimpleDumper();
212
+			$message = sprintf(
213
+					$message,
214
+					"[" . $dumper->describeValue($first) .
215
+							"] and [" . $dumper->describeValue($second) .
216
+							"] should reference the same object");
217
+			return $this->assertTrue(
218
+					SimpleTestCompatibility::isReference($first, $second),
219
+					$message);
220
+		}
221 221
 
222
-        /**
223
-         *    Will trigger a pass if both parameters refer
224
-         *    to different objects. Fail otherwise. The objects
225
-         *    have to be identical though.
226
-         *    @param mixed $first           Object reference to check.
227
-         *    @param mixed $second          Hopefully not the same object.
228
-         *    @param string $message        Message to display.
229
-         *    @return boolean               True on pass
230
-         *    @access public
231
-         */
232
-        function assertClone($first, $second, $message = "%s") {
233
-            $dumper = new SimpleDumper();
234
-            $message = sprintf(
235
-                    $message,
236
-                    "[" . $dumper->describeValue($first) .
237
-                            "] and [" . $dumper->describeValue($second) .
238
-                            "] should not be the same object");
239
-            $identical = new IdenticalExpectation($first);
240
-            return $this->assertTrue(
241
-                    $identical->test($second) &&
242
-                            ! SimpleTestCompatibility::isReference($first, $second),
243
-                    $message);
244
-        }
222
+		/**
223
+		 *    Will trigger a pass if both parameters refer
224
+		 *    to different objects. Fail otherwise. The objects
225
+		 *    have to be identical though.
226
+		 *    @param mixed $first           Object reference to check.
227
+		 *    @param mixed $second          Hopefully not the same object.
228
+		 *    @param string $message        Message to display.
229
+		 *    @return boolean               True on pass
230
+		 *    @access public
231
+		 */
232
+		function assertClone($first, $second, $message = "%s") {
233
+			$dumper = new SimpleDumper();
234
+			$message = sprintf(
235
+					$message,
236
+					"[" . $dumper->describeValue($first) .
237
+							"] and [" . $dumper->describeValue($second) .
238
+							"] should not be the same object");
239
+			$identical = new IdenticalExpectation($first);
240
+			return $this->assertTrue(
241
+					$identical->test($second) &&
242
+							! SimpleTestCompatibility::isReference($first, $second),
243
+					$message);
244
+		}
245 245
 
246
-        /**
247
-         *    @deprecated
248
-         */
249
-        function assertCopy($first, $second, $message = "%s") {
250
-            $dumper = new SimpleDumper();
251
-            $message = sprintf(
252
-                    $message,
253
-                    "[" . $dumper->describeValue($first) .
254
-                            "] and [" . $dumper->describeValue($second) .
255
-                            "] should not be the same object");
256
-            return $this->assertFalse(
257
-                    SimpleTestCompatibility::isReference($first, $second),
258
-                    $message);
259
-        }
246
+		/**
247
+		 *    @deprecated
248
+		 */
249
+		function assertCopy($first, $second, $message = "%s") {
250
+			$dumper = new SimpleDumper();
251
+			$message = sprintf(
252
+					$message,
253
+					"[" . $dumper->describeValue($first) .
254
+							"] and [" . $dumper->describeValue($second) .
255
+							"] should not be the same object");
256
+			return $this->assertFalse(
257
+					SimpleTestCompatibility::isReference($first, $second),
258
+					$message);
259
+		}
260 260
 
261
-        /**
262
-         *    Will trigger a pass if the Perl regex pattern
263
-         *    is found in the subject. Fail otherwise.
264
-         *    @param string $pattern    Perl regex to look for including
265
-         *                              the regex delimiters.
266
-         *    @param string $subject    String to search in.
267
-         *    @param string $message    Message to display.
268
-         *    @return boolean           True on pass
269
-         *    @access public
270
-         */
271
-        function assertPattern($pattern, $subject, $message = "%s") {
272
-            return $this->assert(
273
-                    new PatternExpectation($pattern),
274
-                    $subject,
275
-                    $message);
276
-        }
261
+		/**
262
+		 *    Will trigger a pass if the Perl regex pattern
263
+		 *    is found in the subject. Fail otherwise.
264
+		 *    @param string $pattern    Perl regex to look for including
265
+		 *                              the regex delimiters.
266
+		 *    @param string $subject    String to search in.
267
+		 *    @param string $message    Message to display.
268
+		 *    @return boolean           True on pass
269
+		 *    @access public
270
+		 */
271
+		function assertPattern($pattern, $subject, $message = "%s") {
272
+			return $this->assert(
273
+					new PatternExpectation($pattern),
274
+					$subject,
275
+					$message);
276
+		}
277 277
 
278
-        /**
279
-         *	  @deprecated
280
-         */
281
-        function assertWantedPattern($pattern, $subject, $message = "%s") {
282
-        	return $this->assertPattern($pattern, $subject, $message);
283
-        }
278
+		/**
279
+		 *	  @deprecated
280
+		 */
281
+		function assertWantedPattern($pattern, $subject, $message = "%s") {
282
+			return $this->assertPattern($pattern, $subject, $message);
283
+		}
284 284
 
285
-        /**
286
-         *    Will trigger a pass if the perl regex pattern
287
-         *    is not present in subject. Fail if found.
288
-         *    @param string $pattern    Perl regex to look for including
289
-         *                              the regex delimiters.
290
-         *    @param string $subject    String to search in.
291
-         *    @param string $message    Message to display.
292
-         *    @return boolean           True on pass
293
-         *    @access public
294
-         */
295
-        function assertNoPattern($pattern, $subject, $message = "%s") {
296
-            return $this->assert(
297
-                    new NoPatternExpectation($pattern),
298
-                    $subject,
299
-                    $message);
300
-        }
285
+		/**
286
+		 *    Will trigger a pass if the perl regex pattern
287
+		 *    is not present in subject. Fail if found.
288
+		 *    @param string $pattern    Perl regex to look for including
289
+		 *                              the regex delimiters.
290
+		 *    @param string $subject    String to search in.
291
+		 *    @param string $message    Message to display.
292
+		 *    @return boolean           True on pass
293
+		 *    @access public
294
+		 */
295
+		function assertNoPattern($pattern, $subject, $message = "%s") {
296
+			return $this->assert(
297
+					new NoPatternExpectation($pattern),
298
+					$subject,
299
+					$message);
300
+		}
301 301
 
302
-        /**
303
-         *	  @deprecated
304
-         */
305
-        function assertNoUnwantedPattern($pattern, $subject, $message = "%s") {
306
-        	return $this->assertNoPattern($pattern, $subject, $message);
307
-        }
302
+		/**
303
+		 *	  @deprecated
304
+		 */
305
+		function assertNoUnwantedPattern($pattern, $subject, $message = "%s") {
306
+			return $this->assertNoPattern($pattern, $subject, $message);
307
+		}
308 308
 
309
-        /**
310
-         *    Confirms that no errors have occoured so
311
-         *    far in the test method.
312
-         *    @param string $message    Message to display.
313
-         *    @return boolean           True on pass
314
-         *    @access public
315
-         */
316
-        function assertNoErrors($message = "%s") {
317
-            $queue = &SimpleErrorQueue::instance();
318
-            return $this->assertTrue(
319
-                    $queue->isEmpty(),
320
-                    sprintf($message, "Should be no errors"));
321
-        }
309
+		/**
310
+		 *    Confirms that no errors have occoured so
311
+		 *    far in the test method.
312
+		 *    @param string $message    Message to display.
313
+		 *    @return boolean           True on pass
314
+		 *    @access public
315
+		 */
316
+		function assertNoErrors($message = "%s") {
317
+			$queue = &SimpleErrorQueue::instance();
318
+			return $this->assertTrue(
319
+					$queue->isEmpty(),
320
+					sprintf($message, "Should be no errors"));
321
+		}
322 322
 
323
-        /**
324
-         *    Confirms that an error has occoured and
325
-         *    optionally that the error text matches exactly.
326
-         *    @param string $expected   Expected error text or
327
-         *                              false for no check.
328
-         *    @param string $message    Message to display.
329
-         *    @return boolean           True on pass
330
-         *    @access public
331
-         */
332
-        function assertError($expected = false, $message = "%s") {
333
-            $queue = &SimpleErrorQueue::instance();
334
-            if ($queue->isEmpty()) {
335
-                $this->fail(sprintf($message, "Expected error not found"));
336
-                return;
337
-            }
338
-            list($severity, $content, $file, $line, $globals) = $queue->extract();
339
-            $severity = SimpleErrorQueue::getSeverityAsString($severity);
340
-            if (! $expected) {
341
-                return $this->pass(
342
-                        "Captured a PHP error of [$content] severity [$severity] in [$file] line [$line] -> %s");
343
-            }
344
-            $expected = $this->_coerceToExpectation($expected);
345
-            return $this->assert(
346
-                    $expected,
347
-                    $content,
348
-                    "Expected PHP error [$content] severity [$severity] in [$file] line [$line] -> %s");
349
-        }
323
+		/**
324
+		 *    Confirms that an error has occoured and
325
+		 *    optionally that the error text matches exactly.
326
+		 *    @param string $expected   Expected error text or
327
+		 *                              false for no check.
328
+		 *    @param string $message    Message to display.
329
+		 *    @return boolean           True on pass
330
+		 *    @access public
331
+		 */
332
+		function assertError($expected = false, $message = "%s") {
333
+			$queue = &SimpleErrorQueue::instance();
334
+			if ($queue->isEmpty()) {
335
+				$this->fail(sprintf($message, "Expected error not found"));
336
+				return;
337
+			}
338
+			list($severity, $content, $file, $line, $globals) = $queue->extract();
339
+			$severity = SimpleErrorQueue::getSeverityAsString($severity);
340
+			if (! $expected) {
341
+				return $this->pass(
342
+						"Captured a PHP error of [$content] severity [$severity] in [$file] line [$line] -> %s");
343
+			}
344
+			$expected = $this->_coerceToExpectation($expected);
345
+			return $this->assert(
346
+					$expected,
347
+					$content,
348
+					"Expected PHP error [$content] severity [$severity] in [$file] line [$line] -> %s");
349
+		}
350 350
 
351
-        /**
352
-         *    Creates an equality expectation if the
353
-         *    object/value is not already some type
354
-         *    of expectation.
355
-         *    @param mixed $expected      Expected value.
356
-         *    @return SimpleExpectation   Expectation object.
357
-         *    @access private
358
-         */
359
-        function _coerceToExpectation($expected) {
360
-            if (SimpleTestCompatibility::isA($expected, 'SimpleExpectation')) {
361
-                return $expected;
362
-            }
363
-            return new EqualExpectation($expected);
364
-        }
351
+		/**
352
+		 *    Creates an equality expectation if the
353
+		 *    object/value is not already some type
354
+		 *    of expectation.
355
+		 *    @param mixed $expected      Expected value.
356
+		 *    @return SimpleExpectation   Expectation object.
357
+		 *    @access private
358
+		 */
359
+		function _coerceToExpectation($expected) {
360
+			if (SimpleTestCompatibility::isA($expected, 'SimpleExpectation')) {
361
+				return $expected;
362
+			}
363
+			return new EqualExpectation($expected);
364
+		}
365 365
 
366
-        /**
367
-         *    @deprecated
368
-         */
369
-        function assertErrorPattern($pattern, $message = "%s") {
370
-            return $this->assertError(new PatternExpectation($pattern), $message);
371
-        }
372
-    }
366
+		/**
367
+		 *    @deprecated
368
+		 */
369
+		function assertErrorPattern($pattern, $message = "%s") {
370
+			return $this->assertError(new PatternExpectation($pattern), $message);
371
+		}
372
+	}
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
          *    @access public
31 31
          */
32 32
         function UnitTestCase($label = false) {
33
-            if (! $label) {
33
+            if (!$label) {
34 34
                 $label = get_class($this);
35 35
             }
36 36
             $this->SimpleTestCase($label);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
             $message = sprintf(
49 49
                     $message,
50 50
                     "[" . $dumper->describeValue($value) . "] should be null");
51
-            return $this->assertTrue(! isset($value), $message);
51
+            return $this->assertTrue(!isset($value), $message);
52 52
         }
53 53
 
54 54
         /**
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
             $identical = new IdenticalExpectation($first);
240 240
             return $this->assertTrue(
241 241
                     $identical->test($second) &&
242
-                            ! SimpleTestCompatibility::isReference($first, $second),
242
+                            !SimpleTestCompatibility::isReference($first, $second),
243 243
                     $message);
244 244
         }
245 245
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
             }
338 338
             list($severity, $content, $file, $line, $globals) = $queue->extract();
339 339
             $severity = SimpleErrorQueue::getSeverityAsString($severity);
340
-            if (! $expected) {
340
+            if (!$expected) {
341 341
                 return $this->pass(
342 342
                         "Captured a PHP error of [$content] severity [$severity] in [$file] line [$line] -> %s");
343 343
             }
Please login to merge, or discard this patch.
tests/test_tools/simpletest/url.php 3 patches
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         /**
179 179
          *    Breaks the request down into an object.
180 180
          *    @param string $raw           Raw request.
181
-         *    @return SimpleFormEncoding    Parsed data.
181
+         *    @return SimpleGetEncoding    Parsed data.
182 182
          *    @access private
183 183
          */
184 184
         function _parseRequest($raw) {
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
         /**
267 267
          *    Accessor for page if any. This may be a
268 268
          *    directory name if ambiguious.
269
-         *    @return            Page name.
269
+         *    @return            false|string name.
270 270
          *    @access public
271 271
          */
272 272
         function getPage() {
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
          *    Replaces unknown sections to turn a relative
431 431
          *    URL into an absolute one. The base URL can
432 432
          *    be either a string or a SimpleUrl object.
433
-         *    @param string/SimpleUrl $base       Base URL.
433
+         *    @param SimpleUrl $base       Base URL.
434 434
          *    @access public
435 435
          */
436 436
         function makeAbsolute($base) {
@@ -463,6 +463,7 @@  discard block
 block discarded – undo
463 463
          *    @param string/SimpleUrl $base       Base URL.
464 464
          *    @param string                       Absolute path.
465 465
          *    @access private
466
+         * @return string
466 467
          */
467 468
         function _extractAbsolutePath($base) {
468 469
             if ($this->getHost()) {
Please login to merge, or discard this patch.
Indentation   +519 added lines, -519 removed lines patch added patch discarded remove patch
@@ -1,524 +1,524 @@
 block discarded – undo
1 1
 <?php
2
-    /**
3
-     *	base include file for SimpleTest
4
-     *	@package	SimpleTest
5
-     *	@subpackage	WebTester
6
-     *	@version	$Id: url.php 1532 2006-12-01 12:28:55Z xue $
7
-     */
8
-
9
-    /**#@+
2
+	/**
3
+	 *	base include file for SimpleTest
4
+	 *	@package	SimpleTest
5
+	 *	@subpackage	WebTester
6
+	 *	@version	$Id: url.php 1532 2006-12-01 12:28:55Z xue $
7
+	 */
8
+
9
+	/**#@+
10 10
      *	include other SimpleTest class files
11 11
      */
12
-    require_once(dirname(__FILE__) . '/encoding.php');
13
-    /**#@-*/
14
-
15
-    /**
16
-     *    URL parser to replace parse_url() PHP function which
17
-     *    got broken in PHP 4.3.0. Adds some browser specific
18
-     *    functionality such as expandomatics.
19
-     *    Guesses a bit trying to separate the host from
20
-     *    the path and tries to keep a raw, possibly unparsable,
21
-     *    request string as long as possible.
12
+	require_once(dirname(__FILE__) . '/encoding.php');
13
+	/**#@-*/
14
+
15
+	/**
16
+	 *    URL parser to replace parse_url() PHP function which
17
+	 *    got broken in PHP 4.3.0. Adds some browser specific
18
+	 *    functionality such as expandomatics.
19
+	 *    Guesses a bit trying to separate the host from
20
+	 *    the path and tries to keep a raw, possibly unparsable,
21
+	 *    request string as long as possible.
22 22
 	 *    @package SimpleTest
23 23
 	 *    @subpackage WebTester
24
-     */
25
-    class SimpleUrl {
26
-        protected $_scheme;
27
-        protected $_username;
28
-        protected $_password;
29
-        protected $_host;
30
-        protected $_port;
31
-        protected $_path;
32
-        protected $_request;
33
-        protected $_fragment;
34
-        protected $_x;
35
-        protected $_y;
36
-        protected $_target;
37
-        protected $_raw = false;
38
-
39
-        /**
40
-         *    Constructor. Parses URL into sections.
41
-         *    @param string $url        Incoming URL.
42
-         *    @access public
43
-         */
44
-        function SimpleUrl($url) {
45
-            list($x, $y) = $this->_chompCoordinates($url);
46
-            $this->setCoordinates($x, $y);
47
-            $this->_scheme = $this->_chompScheme($url);
48
-            list($this->_username, $this->_password) = $this->_chompLogin($url);
49
-            $this->_host = $this->_chompHost($url);
50
-            $this->_port = false;
51
-            if (preg_match('/(.*?):(.*)/', $this->_host, $host_parts)) {
52
-                $this->_host = $host_parts[1];
53
-                $this->_port = (integer)$host_parts[2];
54
-            }
55
-            $this->_path = $this->_chompPath($url);
56
-            $this->_request = $this->_parseRequest($this->_chompRequest($url));
57
-            $this->_fragment = (strncmp($url, "#", 1) == 0 ? substr($url, 1) : false);
58
-            $this->_target = false;
59
-        }
60
-
61
-        /**
62
-         *    Extracts the X, Y coordinate pair from an image map.
63
-         *    @param string $url   URL so far. The coordinates will be
64
-         *                         removed.
65
-         *    @return array        X, Y as a pair of integers.
66
-         *    @access private
67
-         */
68
-        function _chompCoordinates($url) {
69
-            if (preg_match('/(.*)\?(\d+),(\d+)$/', $url, $matches)) {
70
-                $url = $matches[1];
71
-                return array((integer)$matches[2], (integer)$matches[3]);
72
-            }
73
-            return array(false, false);
74
-        }
75
-
76
-        /**
77
-         *    Extracts the scheme part of an incoming URL.
78
-         *    @param string $url   URL so far. The scheme will be
79
-         *                         removed.
80
-         *    @return string       Scheme part or false.
81
-         *    @access private
82
-         */
83
-        function _chompScheme($url) {
84
-            if (preg_match('/(.*?):(\/\/)(.*)/', $url, $matches)) {
85
-                $url = $matches[2] . $matches[3];
86
-                return $matches[1];
87
-            }
88
-            return false;
89
-        }
90
-
91
-        /**
92
-         *    Extracts the username and password from the
93
-         *    incoming URL. The // prefix will be reattached
94
-         *    to the URL after the doublet is extracted.
95
-         *    @param string $url    URL so far. The username and
96
-         *                          password are removed.
97
-         *    @return array         Two item list of username and
98
-         *                          password. Will urldecode() them.
99
-         *    @access private
100
-         */
101
-        function _chompLogin($url) {
102
-            $prefix = '';
103
-            if (preg_match('/^(\/\/)(.*)/', $url, $matches)) {
104
-                $prefix = $matches[1];
105
-                $url = $matches[2];
106
-            }
107
-            if (preg_match('/(.*?)@(.*)/', $url, $matches)) {
108
-                $url = $prefix . $matches[2];
109
-                $parts = split(":", $matches[1]);
110
-                return array(
111
-                        urldecode($parts[0]),
112
-                        isset($parts[1]) ? urldecode($parts[1]) : false);
113
-            }
114
-            $url = $prefix . $url;
115
-            return array(false, false);
116
-        }
117
-
118
-        /**
119
-         *    Extracts the host part of an incoming URL.
120
-         *    Includes the port number part. Will extract
121
-         *    the host if it starts with // or it has
122
-         *    a top level domain or it has at least two
123
-         *    dots.
124
-         *    @param string $url    URL so far. The host will be
125
-         *                          removed.
126
-         *    @return string        Host part guess or false.
127
-         *    @access private
128
-         */
129
-        function _chompHost($url) {
130
-            if (preg_match('/^(\/\/)(.*?)(\/.*|\?.*|#.*|$)/', $url, $matches)) {
131
-                $url = $matches[3];
132
-                return $matches[2];
133
-            }
134
-            if (preg_match('/(.*?)(\.\.\/|\.\/|\/|\?|#|$)(.*)/', $url, $matches)) {
135
-                $tlds = SimpleUrl::getAllTopLevelDomains();
136
-                if (preg_match('/[a-z0-9\-]+\.(' . $tlds . ')/i', $matches[1])) {
137
-                    $url = $matches[2] . $matches[3];
138
-                    return $matches[1];
139
-                } elseif (preg_match('/[a-z0-9\-]+\.[a-z0-9\-]+\.[a-z0-9\-]+/i', $matches[1])) {
140
-                    $url = $matches[2] . $matches[3];
141
-                    return $matches[1];
142
-                }
143
-            }
144
-            return false;
145
-        }
146
-
147
-        /**
148
-         *    Extracts the path information from the incoming
149
-         *    URL. Strips this path from the URL.
150
-         *    @param string $url     URL so far. The host will be
151
-         *                           removed.
152
-         *    @return string         Path part or '/'.
153
-         *    @access private
154
-         */
155
-        function _chompPath($url) {
156
-            if (preg_match('/(.*?)(\?|#|$)(.*)/', $url, $matches)) {
157
-                $url = $matches[2] . $matches[3];
158
-                return ($matches[1] ? $matches[1] : '');
159
-            }
160
-            return '';
161
-        }
162
-
163
-        /**
164
-         *    Strips off the request data.
165
-         *    @param string $url  URL so far. The request will be
166
-         *                        removed.
167
-         *    @return string      Raw request part.
168
-         *    @access private
169
-         */
170
-        function _chompRequest($url) {
171
-            if (preg_match('/\?(.*?)(#|$)(.*)/', $url, $matches)) {
172
-                $url = $matches[2] . $matches[3];
173
-                return $matches[1];
174
-            }
175
-            return '';
176
-        }
177
-
178
-        /**
179
-         *    Breaks the request down into an object.
180
-         *    @param string $raw           Raw request.
181
-         *    @return SimpleFormEncoding    Parsed data.
182
-         *    @access private
183
-         */
184
-        function _parseRequest($raw) {
185
-            $this->_raw = $raw;
186
-            $request = new SimpleGetEncoding();
187
-            foreach (split("&", $raw) as $pair) {
188
-                if (preg_match('/(.*?)=(.*)/', $pair, $matches)) {
189
-                    $request->add($matches[1], urldecode($matches[2]));
190
-                } elseif ($pair) {
191
-                    $request->add($pair, '');
192
-                }
193
-            }
194
-            return $request;
195
-        }
196
-
197
-        /**
198
-         *    Accessor for protocol part.
199
-         *    @param string $default    Value to use if not present.
200
-         *    @return string            Scheme name, e.g "http".
201
-         *    @access public
202
-         */
203
-        function getScheme($default = false) {
204
-            return $this->_scheme ? $this->_scheme : $default;
205
-        }
206
-
207
-        /**
208
-         *    Accessor for user name.
209
-         *    @return string    Username preceding host.
210
-         *    @access public
211
-         */
212
-        function getUsername() {
213
-            return $this->_username;
214
-        }
215
-
216
-        /**
217
-         *    Accessor for password.
218
-         *    @return string    Password preceding host.
219
-         *    @access public
220
-         */
221
-        function getPassword() {
222
-            return $this->_password;
223
-        }
224
-
225
-        /**
226
-         *    Accessor for hostname and port.
227
-         *    @param string $default    Value to use if not present.
228
-         *    @return string            Hostname only.
229
-         *    @access public
230
-         */
231
-        function getHost($default = false) {
232
-            return $this->_host ? $this->_host : $default;
233
-        }
234
-
235
-        /**
236
-         *    Accessor for top level domain.
237
-         *    @return string       Last part of host.
238
-         *    @access public
239
-         */
240
-        function getTld() {
241
-            $path_parts = pathinfo($this->getHost());
242
-            return (isset($path_parts['extension']) ? $path_parts['extension'] : false);
243
-        }
244
-
245
-        /**
246
-         *    Accessor for port number.
247
-         *    @return integer    TCP/IP port number.
248
-         *    @access public
249
-         */
250
-        function getPort() {
251
-            return $this->_port;
252
-        }
253
-
254
-       /**
255
-         *    Accessor for path.
256
-         *    @return string    Full path including leading slash if implied.
257
-         *    @access public
258
-         */
259
-        function getPath() {
260
-            if (! $this->_path && $this->_host) {
261
-                return '/';
262
-            }
263
-            return $this->_path;
264
-        }
265
-
266
-        /**
267
-         *    Accessor for page if any. This may be a
268
-         *    directory name if ambiguious.
269
-         *    @return            Page name.
270
-         *    @access public
271
-         */
272
-        function getPage() {
273
-            if (! preg_match('/([^\/]*?)$/', $this->getPath(), $matches)) {
274
-                return false;
275
-            }
276
-            return $matches[1];
277
-        }
278
-
279
-        /**
280
-         *    Gets the path to the page.
281
-         *    @return string       Path less the page.
282
-         *    @access public
283
-         */
284
-        function getBasePath() {
285
-            if (! preg_match('/(.*\/)[^\/]*?$/', $this->getPath(), $matches)) {
286
-                return false;
287
-            }
288
-            return $matches[1];
289
-        }
290
-
291
-        /**
292
-         *    Accessor for fragment at end of URL after the "#".
293
-         *    @return string    Part after "#".
294
-         *    @access public
295
-         */
296
-        function getFragment() {
297
-            return $this->_fragment;
298
-        }
299
-
300
-        /**
301
-         *    Sets image coordinates. Set to false to clear
302
-         *    them.
303
-         *    @param integer $x    Horizontal position.
304
-         *    @param integer $y    Vertical position.
305
-         *    @access public
306
-         */
307
-        function setCoordinates($x = false, $y = false) {
308
-            if (($x === false) || ($y === false)) {
309
-                $this->_x = $this->_y = false;
310
-                return;
311
-            }
312
-            $this->_x = (integer)$x;
313
-            $this->_y = (integer)$y;
314
-        }
315
-
316
-        /**
317
-         *    Accessor for horizontal image coordinate.
318
-         *    @return integer        X value.
319
-         *    @access public
320
-         */
321
-        function getX() {
322
-            return $this->_x;
323
-        }
324
-
325
-        /**
326
-         *    Accessor for vertical image coordinate.
327
-         *    @return integer        Y value.
328
-         *    @access public
329
-         */
330
-        function getY() {
331
-            return $this->_y;
332
-        }
333
-
334
-        /**
335
-         *    Accessor for current request parameters
336
-         *    in URL string form. Will return teh original request
337
-         *    if at all possible even if it doesn't make much
338
-         *    sense.
339
-         *    @return string   Form is string "?a=1&b=2", etc.
340
-         *    @access public
341
-         */
342
-        function getEncodedRequest() {
343
-            if ($this->_raw) {
344
-                $encoded = $this->_raw;
345
-            } else {
346
-                $encoded = $this->_request->asUrlRequest();
347
-            }
348
-            if ($encoded) {
349
-                return '?' . preg_replace('/^\?/', '', $encoded);
350
-            }
351
-            return '';
352
-        }
353
-
354
-        /**
355
-         *    Adds an additional parameter to the request.
356
-         *    @param string $key            Name of parameter.
357
-         *    @param string $value          Value as string.
358
-         *    @access public
359
-         */
360
-        function addRequestParameter($key, $value) {
361
-            $this->_raw = false;
362
-            $this->_request->add($key, $value);
363
-        }
364
-
365
-        /**
366
-         *    Adds additional parameters to the request.
367
-         *    @param hash/SimpleFormEncoding $parameters   Additional
368
-         *                                                parameters.
369
-         *    @access public
370
-         */
371
-        function addRequestParameters($parameters) {
372
-            $this->_raw = false;
373
-            $this->_request->merge($parameters);
374
-        }
375
-
376
-        /**
377
-         *    Clears down all parameters.
378
-         *    @access public
379
-         */
380
-        function clearRequest() {
381
-            $this->_raw = false;
382
-            $this->_request = new SimpleGetEncoding();
383
-        }
384
-
385
-        /**
386
-         *    Gets the frame target if present. Although
387
-         *    not strictly part of the URL specification it
388
-         *    acts as similarily to the browser.
389
-         *    @return boolean/string    Frame name or false if none.
390
-         *    @access public
391
-         */
392
-        function getTarget() {
393
-            return $this->_target;
394
-        }
395
-
396
-        /**
397
-         *    Attaches a frame target.
398
-         *    @param string $frame        Name of frame.
399
-         *    @access public
400
-         */
401
-        function setTarget($frame) {
402
-            $this->_raw = false;
403
-            $this->_target = $frame;
404
-        }
405
-
406
-        /**
407
-         *    Renders the URL back into a string.
408
-         *    @return string        URL in canonical form.
409
-         *    @access public
410
-         */
411
-        function asString() {
412
-            $scheme = $identity = $host = $path = $encoded = $fragment = '';
413
-            if ($this->_username && $this->_password) {
414
-                $identity = $this->_username . ':' . $this->_password . '@';
415
-            }
416
-            if ($this->getHost()) {
417
-                $scheme = $this->getScheme() ? $this->getScheme() : 'http';
418
-                $host = $this->getHost();
419
-            }
420
-            if (substr($this->_path, 0, 1) == '/') {
421
-                $path = $this->normalisePath($this->_path);
422
-            }
423
-            $encoded = $this->getEncodedRequest();
424
-            $fragment = $this->getFragment() ? '#'. $this->getFragment() : '';
425
-            $coords = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();
426
-            return "$scheme://$identity$host$path$encoded$fragment$coords";
427
-        }
428
-
429
-        /**
430
-         *    Replaces unknown sections to turn a relative
431
-         *    URL into an absolute one. The base URL can
432
-         *    be either a string or a SimpleUrl object.
433
-         *    @param string/SimpleUrl $base       Base URL.
434
-         *    @access public
435
-         */
436
-        function makeAbsolute($base) {
437
-            if (! is_object($base)) {
438
-                $base = new SimpleUrl($base);
439
-            }
440
-            $scheme = $this->getScheme() ? $this->getScheme() : $base->getScheme();
441
-            if ($this->getHost()) {
442
-                $host = $this->getHost();
443
-                $port = $this->getPort() ? ':' . $this->getPort() : '';
444
-                $identity = $this->getIdentity() ? $this->getIdentity() . '@' : '';
445
-                if (! $identity) {
446
-                    $identity = $base->getIdentity() ? $base->getIdentity() . '@' : '';
447
-                }
448
-            } else {
449
-                $host = $base->getHost();
450
-                $port = $base->getPort() ? ':' . $base->getPort() : '';
451
-                $identity = $base->getIdentity() ? $base->getIdentity() . '@' : '';
452
-            }
453
-            $path = $this->normalisePath($this->_extractAbsolutePath($base));
454
-            $encoded = $this->getEncodedRequest();
455
-            $fragment = $this->getFragment() ? '#'. $this->getFragment() : '';
456
-            $coords = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();
457
-            return new SimpleUrl("$scheme://$identity$host$port$path$encoded$fragment$coords");
458
-        }
459
-
460
-        /**
461
-         *    Replaces unknown sections of the path with base parts
462
-         *    to return a complete absolute one.
463
-         *    @param string/SimpleUrl $base       Base URL.
464
-         *    @param string                       Absolute path.
465
-         *    @access private
466
-         */
467
-        function _extractAbsolutePath($base) {
468
-            if ($this->getHost()) {
469
-                return $this->_path;
470
-            }
471
-            if (! $this->_isRelativePath($this->_path)) {
472
-                return $this->_path;
473
-            }
474
-            if ($this->_path) {
475
-                return $base->getBasePath() . $this->_path;
476
-            }
477
-            return $base->getPath();
478
-        }
479
-
480
-        /**
481
-         *    Simple test to see if a path part is relative.
482
-         *    @param string $path        Path to test.
483
-         *    @return boolean            True if starts with a "/".
484
-         *    @access private
485
-         */
486
-        function _isRelativePath($path) {
487
-            return (substr($path, 0, 1) != '/');
488
-        }
489
-
490
-        /**
491
-         *    Extracts the username and password for use in rendering
492
-         *    a URL.
493
-         *    @return string/boolean    Form of username:password or false.
494
-         *    @access public
495
-         */
496
-        function getIdentity() {
497
-            if ($this->_username && $this->_password) {
498
-                return $this->_username . ':' . $this->_password;
499
-            }
500
-            return false;
501
-        }
502
-
503
-        /**
504
-         *    Replaces . and .. sections of the path.
505
-         *    @param string $path    Unoptimised path.
506
-         *    @return string         Path with dots removed if possible.
507
-         *    @access public
508
-         */
509
-        function normalisePath($path) {
510
-            $path = preg_replace('|/[^/]+/\.\./|', '/', $path);
511
-            return preg_replace('|/\./|', '/', $path);
512
-        }
513
-
514
-        /**
515
-         *    A pipe seperated list of all TLDs that result in two part
516
-         *    domain names.
517
-         *    @return string        Pipe separated list.
518
-         *    @access public
519
-         *    @static
520
-         */
521
-        static function getAllTopLevelDomains() {
522
-            return 'com|edu|net|org|gov|mil|int|biz|info|name|pro|aero|coop|museum';
523
-        }
524
-    }
525 24
\ No newline at end of file
25
+	 */
26
+	class SimpleUrl {
27
+		protected $_scheme;
28
+		protected $_username;
29
+		protected $_password;
30
+		protected $_host;
31
+		protected $_port;
32
+		protected $_path;
33
+		protected $_request;
34
+		protected $_fragment;
35
+		protected $_x;
36
+		protected $_y;
37
+		protected $_target;
38
+		protected $_raw = false;
39
+
40
+		/**
41
+		 *    Constructor. Parses URL into sections.
42
+		 *    @param string $url        Incoming URL.
43
+		 *    @access public
44
+		 */
45
+		function SimpleUrl($url) {
46
+			list($x, $y) = $this->_chompCoordinates($url);
47
+			$this->setCoordinates($x, $y);
48
+			$this->_scheme = $this->_chompScheme($url);
49
+			list($this->_username, $this->_password) = $this->_chompLogin($url);
50
+			$this->_host = $this->_chompHost($url);
51
+			$this->_port = false;
52
+			if (preg_match('/(.*?):(.*)/', $this->_host, $host_parts)) {
53
+				$this->_host = $host_parts[1];
54
+				$this->_port = (integer)$host_parts[2];
55
+			}
56
+			$this->_path = $this->_chompPath($url);
57
+			$this->_request = $this->_parseRequest($this->_chompRequest($url));
58
+			$this->_fragment = (strncmp($url, "#", 1) == 0 ? substr($url, 1) : false);
59
+			$this->_target = false;
60
+		}
61
+
62
+		/**
63
+		 *    Extracts the X, Y coordinate pair from an image map.
64
+		 *    @param string $url   URL so far. The coordinates will be
65
+		 *                         removed.
66
+		 *    @return array        X, Y as a pair of integers.
67
+		 *    @access private
68
+		 */
69
+		function _chompCoordinates($url) {
70
+			if (preg_match('/(.*)\?(\d+),(\d+)$/', $url, $matches)) {
71
+				$url = $matches[1];
72
+				return array((integer)$matches[2], (integer)$matches[3]);
73
+			}
74
+			return array(false, false);
75
+		}
76
+
77
+		/**
78
+		 *    Extracts the scheme part of an incoming URL.
79
+		 *    @param string $url   URL so far. The scheme will be
80
+		 *                         removed.
81
+		 *    @return string       Scheme part or false.
82
+		 *    @access private
83
+		 */
84
+		function _chompScheme($url) {
85
+			if (preg_match('/(.*?):(\/\/)(.*)/', $url, $matches)) {
86
+				$url = $matches[2] . $matches[3];
87
+				return $matches[1];
88
+			}
89
+			return false;
90
+		}
91
+
92
+		/**
93
+		 *    Extracts the username and password from the
94
+		 *    incoming URL. The // prefix will be reattached
95
+		 *    to the URL after the doublet is extracted.
96
+		 *    @param string $url    URL so far. The username and
97
+		 *                          password are removed.
98
+		 *    @return array         Two item list of username and
99
+		 *                          password. Will urldecode() them.
100
+		 *    @access private
101
+		 */
102
+		function _chompLogin($url) {
103
+			$prefix = '';
104
+			if (preg_match('/^(\/\/)(.*)/', $url, $matches)) {
105
+				$prefix = $matches[1];
106
+				$url = $matches[2];
107
+			}
108
+			if (preg_match('/(.*?)@(.*)/', $url, $matches)) {
109
+				$url = $prefix . $matches[2];
110
+				$parts = split(":", $matches[1]);
111
+				return array(
112
+						urldecode($parts[0]),
113
+						isset($parts[1]) ? urldecode($parts[1]) : false);
114
+			}
115
+			$url = $prefix . $url;
116
+			return array(false, false);
117
+		}
118
+
119
+		/**
120
+		 *    Extracts the host part of an incoming URL.
121
+		 *    Includes the port number part. Will extract
122
+		 *    the host if it starts with // or it has
123
+		 *    a top level domain or it has at least two
124
+		 *    dots.
125
+		 *    @param string $url    URL so far. The host will be
126
+		 *                          removed.
127
+		 *    @return string        Host part guess or false.
128
+		 *    @access private
129
+		 */
130
+		function _chompHost($url) {
131
+			if (preg_match('/^(\/\/)(.*?)(\/.*|\?.*|#.*|$)/', $url, $matches)) {
132
+				$url = $matches[3];
133
+				return $matches[2];
134
+			}
135
+			if (preg_match('/(.*?)(\.\.\/|\.\/|\/|\?|#|$)(.*)/', $url, $matches)) {
136
+				$tlds = SimpleUrl::getAllTopLevelDomains();
137
+				if (preg_match('/[a-z0-9\-]+\.(' . $tlds . ')/i', $matches[1])) {
138
+					$url = $matches[2] . $matches[3];
139
+					return $matches[1];
140
+				} elseif (preg_match('/[a-z0-9\-]+\.[a-z0-9\-]+\.[a-z0-9\-]+/i', $matches[1])) {
141
+					$url = $matches[2] . $matches[3];
142
+					return $matches[1];
143
+				}
144
+			}
145
+			return false;
146
+		}
147
+
148
+		/**
149
+		 *    Extracts the path information from the incoming
150
+		 *    URL. Strips this path from the URL.
151
+		 *    @param string $url     URL so far. The host will be
152
+		 *                           removed.
153
+		 *    @return string         Path part or '/'.
154
+		 *    @access private
155
+		 */
156
+		function _chompPath($url) {
157
+			if (preg_match('/(.*?)(\?|#|$)(.*)/', $url, $matches)) {
158
+				$url = $matches[2] . $matches[3];
159
+				return ($matches[1] ? $matches[1] : '');
160
+			}
161
+			return '';
162
+		}
163
+
164
+		/**
165
+		 *    Strips off the request data.
166
+		 *    @param string $url  URL so far. The request will be
167
+		 *                        removed.
168
+		 *    @return string      Raw request part.
169
+		 *    @access private
170
+		 */
171
+		function _chompRequest($url) {
172
+			if (preg_match('/\?(.*?)(#|$)(.*)/', $url, $matches)) {
173
+				$url = $matches[2] . $matches[3];
174
+				return $matches[1];
175
+			}
176
+			return '';
177
+		}
178
+
179
+		/**
180
+		 *    Breaks the request down into an object.
181
+		 *    @param string $raw           Raw request.
182
+		 *    @return SimpleFormEncoding    Parsed data.
183
+		 *    @access private
184
+		 */
185
+		function _parseRequest($raw) {
186
+			$this->_raw = $raw;
187
+			$request = new SimpleGetEncoding();
188
+			foreach (split("&", $raw) as $pair) {
189
+				if (preg_match('/(.*?)=(.*)/', $pair, $matches)) {
190
+					$request->add($matches[1], urldecode($matches[2]));
191
+				} elseif ($pair) {
192
+					$request->add($pair, '');
193
+				}
194
+			}
195
+			return $request;
196
+		}
197
+
198
+		/**
199
+		 *    Accessor for protocol part.
200
+		 *    @param string $default    Value to use if not present.
201
+		 *    @return string            Scheme name, e.g "http".
202
+		 *    @access public
203
+		 */
204
+		function getScheme($default = false) {
205
+			return $this->_scheme ? $this->_scheme : $default;
206
+		}
207
+
208
+		/**
209
+		 *    Accessor for user name.
210
+		 *    @return string    Username preceding host.
211
+		 *    @access public
212
+		 */
213
+		function getUsername() {
214
+			return $this->_username;
215
+		}
216
+
217
+		/**
218
+		 *    Accessor for password.
219
+		 *    @return string    Password preceding host.
220
+		 *    @access public
221
+		 */
222
+		function getPassword() {
223
+			return $this->_password;
224
+		}
225
+
226
+		/**
227
+		 *    Accessor for hostname and port.
228
+		 *    @param string $default    Value to use if not present.
229
+		 *    @return string            Hostname only.
230
+		 *    @access public
231
+		 */
232
+		function getHost($default = false) {
233
+			return $this->_host ? $this->_host : $default;
234
+		}
235
+
236
+		/**
237
+		 *    Accessor for top level domain.
238
+		 *    @return string       Last part of host.
239
+		 *    @access public
240
+		 */
241
+		function getTld() {
242
+			$path_parts = pathinfo($this->getHost());
243
+			return (isset($path_parts['extension']) ? $path_parts['extension'] : false);
244
+		}
245
+
246
+		/**
247
+		 *    Accessor for port number.
248
+		 *    @return integer    TCP/IP port number.
249
+		 *    @access public
250
+		 */
251
+		function getPort() {
252
+			return $this->_port;
253
+		}
254
+
255
+	   /**
256
+	    *    Accessor for path.
257
+	    *    @return string    Full path including leading slash if implied.
258
+	    *    @access public
259
+	    */
260
+		function getPath() {
261
+			if (! $this->_path && $this->_host) {
262
+				return '/';
263
+			}
264
+			return $this->_path;
265
+		}
266
+
267
+		/**
268
+		 *    Accessor for page if any. This may be a
269
+		 *    directory name if ambiguious.
270
+		 *    @return            Page name.
271
+		 *    @access public
272
+		 */
273
+		function getPage() {
274
+			if (! preg_match('/([^\/]*?)$/', $this->getPath(), $matches)) {
275
+				return false;
276
+			}
277
+			return $matches[1];
278
+		}
279
+
280
+		/**
281
+		 *    Gets the path to the page.
282
+		 *    @return string       Path less the page.
283
+		 *    @access public
284
+		 */
285
+		function getBasePath() {
286
+			if (! preg_match('/(.*\/)[^\/]*?$/', $this->getPath(), $matches)) {
287
+				return false;
288
+			}
289
+			return $matches[1];
290
+		}
291
+
292
+		/**
293
+		 *    Accessor for fragment at end of URL after the "#".
294
+		 *    @return string    Part after "#".
295
+		 *    @access public
296
+		 */
297
+		function getFragment() {
298
+			return $this->_fragment;
299
+		}
300
+
301
+		/**
302
+		 *    Sets image coordinates. Set to false to clear
303
+		 *    them.
304
+		 *    @param integer $x    Horizontal position.
305
+		 *    @param integer $y    Vertical position.
306
+		 *    @access public
307
+		 */
308
+		function setCoordinates($x = false, $y = false) {
309
+			if (($x === false) || ($y === false)) {
310
+				$this->_x = $this->_y = false;
311
+				return;
312
+			}
313
+			$this->_x = (integer)$x;
314
+			$this->_y = (integer)$y;
315
+		}
316
+
317
+		/**
318
+		 *    Accessor for horizontal image coordinate.
319
+		 *    @return integer        X value.
320
+		 *    @access public
321
+		 */
322
+		function getX() {
323
+			return $this->_x;
324
+		}
325
+
326
+		/**
327
+		 *    Accessor for vertical image coordinate.
328
+		 *    @return integer        Y value.
329
+		 *    @access public
330
+		 */
331
+		function getY() {
332
+			return $this->_y;
333
+		}
334
+
335
+		/**
336
+		 *    Accessor for current request parameters
337
+		 *    in URL string form. Will return teh original request
338
+		 *    if at all possible even if it doesn't make much
339
+		 *    sense.
340
+		 *    @return string   Form is string "?a=1&b=2", etc.
341
+		 *    @access public
342
+		 */
343
+		function getEncodedRequest() {
344
+			if ($this->_raw) {
345
+				$encoded = $this->_raw;
346
+			} else {
347
+				$encoded = $this->_request->asUrlRequest();
348
+			}
349
+			if ($encoded) {
350
+				return '?' . preg_replace('/^\?/', '', $encoded);
351
+			}
352
+			return '';
353
+		}
354
+
355
+		/**
356
+		 *    Adds an additional parameter to the request.
357
+		 *    @param string $key            Name of parameter.
358
+		 *    @param string $value          Value as string.
359
+		 *    @access public
360
+		 */
361
+		function addRequestParameter($key, $value) {
362
+			$this->_raw = false;
363
+			$this->_request->add($key, $value);
364
+		}
365
+
366
+		/**
367
+		 *    Adds additional parameters to the request.
368
+		 *    @param hash/SimpleFormEncoding $parameters   Additional
369
+		 *                                                parameters.
370
+		 *    @access public
371
+		 */
372
+		function addRequestParameters($parameters) {
373
+			$this->_raw = false;
374
+			$this->_request->merge($parameters);
375
+		}
376
+
377
+		/**
378
+		 *    Clears down all parameters.
379
+		 *    @access public
380
+		 */
381
+		function clearRequest() {
382
+			$this->_raw = false;
383
+			$this->_request = new SimpleGetEncoding();
384
+		}
385
+
386
+		/**
387
+		 *    Gets the frame target if present. Although
388
+		 *    not strictly part of the URL specification it
389
+		 *    acts as similarily to the browser.
390
+		 *    @return boolean/string    Frame name or false if none.
391
+		 *    @access public
392
+		 */
393
+		function getTarget() {
394
+			return $this->_target;
395
+		}
396
+
397
+		/**
398
+		 *    Attaches a frame target.
399
+		 *    @param string $frame        Name of frame.
400
+		 *    @access public
401
+		 */
402
+		function setTarget($frame) {
403
+			$this->_raw = false;
404
+			$this->_target = $frame;
405
+		}
406
+
407
+		/**
408
+		 *    Renders the URL back into a string.
409
+		 *    @return string        URL in canonical form.
410
+		 *    @access public
411
+		 */
412
+		function asString() {
413
+			$scheme = $identity = $host = $path = $encoded = $fragment = '';
414
+			if ($this->_username && $this->_password) {
415
+				$identity = $this->_username . ':' . $this->_password . '@';
416
+			}
417
+			if ($this->getHost()) {
418
+				$scheme = $this->getScheme() ? $this->getScheme() : 'http';
419
+				$host = $this->getHost();
420
+			}
421
+			if (substr($this->_path, 0, 1) == '/') {
422
+				$path = $this->normalisePath($this->_path);
423
+			}
424
+			$encoded = $this->getEncodedRequest();
425
+			$fragment = $this->getFragment() ? '#'. $this->getFragment() : '';
426
+			$coords = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();
427
+			return "$scheme://$identity$host$path$encoded$fragment$coords";
428
+		}
429
+
430
+		/**
431
+		 *    Replaces unknown sections to turn a relative
432
+		 *    URL into an absolute one. The base URL can
433
+		 *    be either a string or a SimpleUrl object.
434
+		 *    @param string/SimpleUrl $base       Base URL.
435
+		 *    @access public
436
+		 */
437
+		function makeAbsolute($base) {
438
+			if (! is_object($base)) {
439
+				$base = new SimpleUrl($base);
440
+			}
441
+			$scheme = $this->getScheme() ? $this->getScheme() : $base->getScheme();
442
+			if ($this->getHost()) {
443
+				$host = $this->getHost();
444
+				$port = $this->getPort() ? ':' . $this->getPort() : '';
445
+				$identity = $this->getIdentity() ? $this->getIdentity() . '@' : '';
446
+				if (! $identity) {
447
+					$identity = $base->getIdentity() ? $base->getIdentity() . '@' : '';
448
+				}
449
+			} else {
450
+				$host = $base->getHost();
451
+				$port = $base->getPort() ? ':' . $base->getPort() : '';
452
+				$identity = $base->getIdentity() ? $base->getIdentity() . '@' : '';
453
+			}
454
+			$path = $this->normalisePath($this->_extractAbsolutePath($base));
455
+			$encoded = $this->getEncodedRequest();
456
+			$fragment = $this->getFragment() ? '#'. $this->getFragment() : '';
457
+			$coords = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();
458
+			return new SimpleUrl("$scheme://$identity$host$port$path$encoded$fragment$coords");
459
+		}
460
+
461
+		/**
462
+		 *    Replaces unknown sections of the path with base parts
463
+		 *    to return a complete absolute one.
464
+		 *    @param string/SimpleUrl $base       Base URL.
465
+		 *    @param string                       Absolute path.
466
+		 *    @access private
467
+		 */
468
+		function _extractAbsolutePath($base) {
469
+			if ($this->getHost()) {
470
+				return $this->_path;
471
+			}
472
+			if (! $this->_isRelativePath($this->_path)) {
473
+				return $this->_path;
474
+			}
475
+			if ($this->_path) {
476
+				return $base->getBasePath() . $this->_path;
477
+			}
478
+			return $base->getPath();
479
+		}
480
+
481
+		/**
482
+		 *    Simple test to see if a path part is relative.
483
+		 *    @param string $path        Path to test.
484
+		 *    @return boolean            True if starts with a "/".
485
+		 *    @access private
486
+		 */
487
+		function _isRelativePath($path) {
488
+			return (substr($path, 0, 1) != '/');
489
+		}
490
+
491
+		/**
492
+		 *    Extracts the username and password for use in rendering
493
+		 *    a URL.
494
+		 *    @return string/boolean    Form of username:password or false.
495
+		 *    @access public
496
+		 */
497
+		function getIdentity() {
498
+			if ($this->_username && $this->_password) {
499
+				return $this->_username . ':' . $this->_password;
500
+			}
501
+			return false;
502
+		}
503
+
504
+		/**
505
+		 *    Replaces . and .. sections of the path.
506
+		 *    @param string $path    Unoptimised path.
507
+		 *    @return string         Path with dots removed if possible.
508
+		 *    @access public
509
+		 */
510
+		function normalisePath($path) {
511
+			$path = preg_replace('|/[^/]+/\.\./|', '/', $path);
512
+			return preg_replace('|/\./|', '/', $path);
513
+		}
514
+
515
+		/**
516
+		 *    A pipe seperated list of all TLDs that result in two part
517
+		 *    domain names.
518
+		 *    @return string        Pipe separated list.
519
+		 *    @access public
520
+		 *    @static
521
+		 */
522
+		static function getAllTopLevelDomains() {
523
+			return 'com|edu|net|org|gov|mil|int|biz|info|name|pro|aero|coop|museum';
524
+		}
525
+	}
526 526
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
             $this->_port = false;
51 51
             if (preg_match('/(.*?):(.*)/', $this->_host, $host_parts)) {
52 52
                 $this->_host = $host_parts[1];
53
-                $this->_port = (integer)$host_parts[2];
53
+                $this->_port = (integer) $host_parts[2];
54 54
             }
55 55
             $this->_path = $this->_chompPath($url);
56 56
             $this->_request = $this->_parseRequest($this->_chompRequest($url));
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         function _chompCoordinates($url) {
69 69
             if (preg_match('/(.*)\?(\d+),(\d+)$/', $url, $matches)) {
70 70
                 $url = $matches[1];
71
-                return array((integer)$matches[2], (integer)$matches[3]);
71
+                return array((integer) $matches[2], (integer) $matches[3]);
72 72
             }
73 73
             return array(false, false);
74 74
         }
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
          *    @access public
258 258
          */
259 259
         function getPath() {
260
-            if (! $this->_path && $this->_host) {
260
+            if (!$this->_path && $this->_host) {
261 261
                 return '/';
262 262
             }
263 263
             return $this->_path;
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
          *    @access public
271 271
          */
272 272
         function getPage() {
273
-            if (! preg_match('/([^\/]*?)$/', $this->getPath(), $matches)) {
273
+            if (!preg_match('/([^\/]*?)$/', $this->getPath(), $matches)) {
274 274
                 return false;
275 275
             }
276 276
             return $matches[1];
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
          *    @access public
283 283
          */
284 284
         function getBasePath() {
285
-            if (! preg_match('/(.*\/)[^\/]*?$/', $this->getPath(), $matches)) {
285
+            if (!preg_match('/(.*\/)[^\/]*?$/', $this->getPath(), $matches)) {
286 286
                 return false;
287 287
             }
288 288
             return $matches[1];
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
                 $this->_x = $this->_y = false;
310 310
                 return;
311 311
             }
312
-            $this->_x = (integer)$x;
313
-            $this->_y = (integer)$y;
312
+            $this->_x = (integer) $x;
313
+            $this->_y = (integer) $y;
314 314
         }
315 315
 
316 316
         /**
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
                 $path = $this->normalisePath($this->_path);
422 422
             }
423 423
             $encoded = $this->getEncodedRequest();
424
-            $fragment = $this->getFragment() ? '#'. $this->getFragment() : '';
424
+            $fragment = $this->getFragment() ? '#' . $this->getFragment() : '';
425 425
             $coords = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();
426 426
             return "$scheme://$identity$host$path$encoded$fragment$coords";
427 427
         }
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
          *    @access public
435 435
          */
436 436
         function makeAbsolute($base) {
437
-            if (! is_object($base)) {
437
+            if (!is_object($base)) {
438 438
                 $base = new SimpleUrl($base);
439 439
             }
440 440
             $scheme = $this->getScheme() ? $this->getScheme() : $base->getScheme();
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
                 $host = $this->getHost();
443 443
                 $port = $this->getPort() ? ':' . $this->getPort() : '';
444 444
                 $identity = $this->getIdentity() ? $this->getIdentity() . '@' : '';
445
-                if (! $identity) {
445
+                if (!$identity) {
446 446
                     $identity = $base->getIdentity() ? $base->getIdentity() . '@' : '';
447 447
                 }
448 448
             } else {
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
             }
453 453
             $path = $this->normalisePath($this->_extractAbsolutePath($base));
454 454
             $encoded = $this->getEncodedRequest();
455
-            $fragment = $this->getFragment() ? '#'. $this->getFragment() : '';
455
+            $fragment = $this->getFragment() ? '#' . $this->getFragment() : '';
456 456
             $coords = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();
457 457
             return new SimpleUrl("$scheme://$identity$host$port$path$encoded$fragment$coords");
458 458
         }
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
             if ($this->getHost()) {
469 469
                 return $this->_path;
470 470
             }
471
-            if (! $this->_isRelativePath($this->_path)) {
471
+            if (!$this->_isRelativePath($this->_path)) {
472 472
                 return $this->_path;
473 473
             }
474 474
             if ($this->_path) {
Please login to merge, or discard this patch.
tests/test_tools/simpletest/user_agent.php 3 patches
Doc Comments   +1 added lines, -4 removed lines patch added patch discarded remove patch
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
          *    Fetches the page until no longer redirected or
234 234
          *    until the redirect limit runs out.
235 235
          *    @param SimpleUrl $url                  Target to fetch.
236
-         *    @param SimpelFormEncoding $encoding    Additional parameters for request.
236
+         *    @param SimpleEncoding $encoding    Additional parameters for request.
237 237
          *    @return SimpleHttpResponse             Hopefully the target page.
238 238
          *    @access private
239 239
          */
@@ -291,9 +291,6 @@  discard block
 block discarded – undo
291 291
         /**
292 292
          *    Builds the appropriate HTTP request object.
293 293
          *    @param SimpleUrl $url                  Target to fetch as url object.
294
-         *    @param SimpleFormEncoding $parameters  POST/GET parameters.
295
-         *    @return SimpleHttpRequest              New request object.
296
-         *    @access protected
297 294
          */
298 295
         function &_createHttpRequest($url, $encoding) {
299 296
             $request = new SimpleHttpRequest($this->_createRoute($url), $encoding);
Please login to merge, or discard this patch.
Indentation   +302 added lines, -302 removed lines patch added patch discarded remove patch
@@ -1,332 +1,332 @@
 block discarded – undo
1 1
 <?php
2
-    /**
3
-     *	Base include file for SimpleTest
4
-     *	@package	SimpleTest
5
-     *	@subpackage	WebTester
6
-     *	@version	$Id: user_agent.php 1398 2006-09-08 19:31:03Z xue $
7
-     */
2
+	/**
3
+	 *	Base include file for SimpleTest
4
+	 *	@package	SimpleTest
5
+	 *	@subpackage	WebTester
6
+	 *	@version	$Id: user_agent.php 1398 2006-09-08 19:31:03Z xue $
7
+	 */
8 8
 
9
-    /**#@+
9
+	/**#@+
10 10
      *	include other SimpleTest class files
11 11
      */
12
-    require_once(dirname(__FILE__) . '/cookies.php');
13
-    require_once(dirname(__FILE__) . '/http.php');
14
-    require_once(dirname(__FILE__) . '/encoding.php');
15
-    require_once(dirname(__FILE__) . '/authentication.php');
16
-    /**#@-*/
12
+	require_once(dirname(__FILE__) . '/cookies.php');
13
+	require_once(dirname(__FILE__) . '/http.php');
14
+	require_once(dirname(__FILE__) . '/encoding.php');
15
+	require_once(dirname(__FILE__) . '/authentication.php');
16
+	/**#@-*/
17 17
 
18
-    if (! defined('DEFAULT_MAX_REDIRECTS')) {
19
-        define('DEFAULT_MAX_REDIRECTS', 3);
20
-    }
18
+	if (! defined('DEFAULT_MAX_REDIRECTS')) {
19
+		define('DEFAULT_MAX_REDIRECTS', 3);
20
+	}
21 21
 
22
-    if (! defined('DEFAULT_CONNECTION_TIMEOUT')) {
23
-        define('DEFAULT_CONNECTION_TIMEOUT', 15);
24
-    }
22
+	if (! defined('DEFAULT_CONNECTION_TIMEOUT')) {
23
+		define('DEFAULT_CONNECTION_TIMEOUT', 15);
24
+	}
25 25
 
26
-    /**
27
-     *    Fetches web pages whilst keeping track of
28
-     *    cookies and authentication.
26
+	/**
27
+	 *    Fetches web pages whilst keeping track of
28
+	 *    cookies and authentication.
29 29
 	 *    @package SimpleTest
30 30
 	 *    @subpackage WebTester
31
-     */
32
-    class SimpleUserAgent {
33
-        protected $_cookie_jar;
34
-        protected $_cookies_enabled = true;
35
-        protected $_authenticator;
36
-        protected $_max_redirects = DEFAULT_MAX_REDIRECTS;
37
-        protected $_proxy = false;
38
-        protected $_proxy_username = false;
39
-        protected $_proxy_password = false;
40
-        protected $_connection_timeout = DEFAULT_CONNECTION_TIMEOUT;
41
-        protected $_additional_headers = array();
31
+	 */
32
+	class SimpleUserAgent {
33
+		protected $_cookie_jar;
34
+		protected $_cookies_enabled = true;
35
+		protected $_authenticator;
36
+		protected $_max_redirects = DEFAULT_MAX_REDIRECTS;
37
+		protected $_proxy = false;
38
+		protected $_proxy_username = false;
39
+		protected $_proxy_password = false;
40
+		protected $_connection_timeout = DEFAULT_CONNECTION_TIMEOUT;
41
+		protected $_additional_headers = array();
42 42
 
43
-        /**
44
-         *    Starts with no cookies, realms or proxies.
45
-         *    @access public
46
-         */
47
-        function SimpleUserAgent() {
48
-            $this->_cookie_jar = new SimpleCookieJar();
49
-            $this->_authenticator = new SimpleAuthenticator();
50
-        }
43
+		/**
44
+		 *    Starts with no cookies, realms or proxies.
45
+		 *    @access public
46
+		 */
47
+		function SimpleUserAgent() {
48
+			$this->_cookie_jar = new SimpleCookieJar();
49
+			$this->_authenticator = new SimpleAuthenticator();
50
+		}
51 51
 
52
-        /**
53
-         *    Removes expired and temporary cookies as if
54
-         *    the browser was closed and re-opened. Authorisation
55
-         *    has to be obtained again as well.
56
-         *    @param string/integer $date   Time when session restarted.
57
-         *                                  If omitted then all persistent
58
-         *                                  cookies are kept.
59
-         *    @access public
60
-         */
61
-        function restart($date = false) {
62
-            $this->_cookie_jar->restartSession($date);
63
-            $this->_authenticator->restartSession();
64
-        }
52
+		/**
53
+		 *    Removes expired and temporary cookies as if
54
+		 *    the browser was closed and re-opened. Authorisation
55
+		 *    has to be obtained again as well.
56
+		 *    @param string/integer $date   Time when session restarted.
57
+		 *                                  If omitted then all persistent
58
+		 *                                  cookies are kept.
59
+		 *    @access public
60
+		 */
61
+		function restart($date = false) {
62
+			$this->_cookie_jar->restartSession($date);
63
+			$this->_authenticator->restartSession();
64
+		}
65 65
 
66
-        /**
67
-         *    Adds a header to every fetch.
68
-         *    @param string $header       Header line to add to every
69
-         *                                request until cleared.
70
-         *    @access public
71
-         */
72
-        function addHeader($header) {
73
-            $this->_additional_headers[] = $header;
74
-        }
66
+		/**
67
+		 *    Adds a header to every fetch.
68
+		 *    @param string $header       Header line to add to every
69
+		 *                                request until cleared.
70
+		 *    @access public
71
+		 */
72
+		function addHeader($header) {
73
+			$this->_additional_headers[] = $header;
74
+		}
75 75
 
76
-        /**
77
-         *    Ages the cookies by the specified time.
78
-         *    @param integer $interval    Amount in seconds.
79
-         *    @access public
80
-         */
81
-        function ageCookies($interval) {
82
-            $this->_cookie_jar->agePrematurely($interval);
83
-        }
76
+		/**
77
+		 *    Ages the cookies by the specified time.
78
+		 *    @param integer $interval    Amount in seconds.
79
+		 *    @access public
80
+		 */
81
+		function ageCookies($interval) {
82
+			$this->_cookie_jar->agePrematurely($interval);
83
+		}
84 84
 
85
-        /**
86
-         *    Sets an additional cookie. If a cookie has
87
-         *    the same name and path it is replaced.
88
-         *    @param string $name            Cookie key.
89
-         *    @param string $value           Value of cookie.
90
-         *    @param string $host            Host upon which the cookie is valid.
91
-         *    @param string $path            Cookie path if not host wide.
92
-         *    @param string $expiry          Expiry date.
93
-         *    @access public
94
-         */
95
-        function setCookie($name, $value, $host = false, $path = '/', $expiry = false) {
96
-            $this->_cookie_jar->setCookie($name, $value, $host, $path, $expiry);
97
-        }
85
+		/**
86
+		 *    Sets an additional cookie. If a cookie has
87
+		 *    the same name and path it is replaced.
88
+		 *    @param string $name            Cookie key.
89
+		 *    @param string $value           Value of cookie.
90
+		 *    @param string $host            Host upon which the cookie is valid.
91
+		 *    @param string $path            Cookie path if not host wide.
92
+		 *    @param string $expiry          Expiry date.
93
+		 *    @access public
94
+		 */
95
+		function setCookie($name, $value, $host = false, $path = '/', $expiry = false) {
96
+			$this->_cookie_jar->setCookie($name, $value, $host, $path, $expiry);
97
+		}
98 98
 
99
-        /**
100
-         *    Reads the most specific cookie value from the
101
-         *    browser cookies.
102
-         *    @param string $host        Host to search.
103
-         *    @param string $path        Applicable path.
104
-         *    @param string $name        Name of cookie to read.
105
-         *    @return string             False if not present, else the
106
-         *                               value as a string.
107
-         *    @access public
108
-         */
109
-        function getCookieValue($host, $path, $name) {
110
-            return $this->_cookie_jar->getCookieValue($host, $path, $name);
111
-        }
99
+		/**
100
+		 *    Reads the most specific cookie value from the
101
+		 *    browser cookies.
102
+		 *    @param string $host        Host to search.
103
+		 *    @param string $path        Applicable path.
104
+		 *    @param string $name        Name of cookie to read.
105
+		 *    @return string             False if not present, else the
106
+		 *                               value as a string.
107
+		 *    @access public
108
+		 */
109
+		function getCookieValue($host, $path, $name) {
110
+			return $this->_cookie_jar->getCookieValue($host, $path, $name);
111
+		}
112 112
 
113
-        /**
114
-         *    Reads the current cookies within the base URL.
115
-         *    @param string $name     Key of cookie to find.
116
-         *    @param SimpleUrl $base  Base URL to search from.
117
-         *    @return string/boolean  Null if there is no base URL, false
118
-         *                            if the cookie is not set.
119
-         *    @access public
120
-         */
121
-        function getBaseCookieValue($name, $base) {
122
-            if (! $base) {
123
-                return null;
124
-            }
125
-            return $this->getCookieValue($base->getHost(), $base->getPath(), $name);
126
-        }
113
+		/**
114
+		 *    Reads the current cookies within the base URL.
115
+		 *    @param string $name     Key of cookie to find.
116
+		 *    @param SimpleUrl $base  Base URL to search from.
117
+		 *    @return string/boolean  Null if there is no base URL, false
118
+		 *                            if the cookie is not set.
119
+		 *    @access public
120
+		 */
121
+		function getBaseCookieValue($name, $base) {
122
+			if (! $base) {
123
+				return null;
124
+			}
125
+			return $this->getCookieValue($base->getHost(), $base->getPath(), $name);
126
+		}
127 127
 
128
-        /**
129
-         *    Switches off cookie sending and recieving.
130
-         *    @access public
131
-         */
132
-        function ignoreCookies() {
133
-            $this->_cookies_enabled = false;
134
-        }
128
+		/**
129
+		 *    Switches off cookie sending and recieving.
130
+		 *    @access public
131
+		 */
132
+		function ignoreCookies() {
133
+			$this->_cookies_enabled = false;
134
+		}
135 135
 
136
-        /**
137
-         *    Switches back on the cookie sending and recieving.
138
-         *    @access public
139
-         */
140
-        function useCookies() {
141
-            $this->_cookies_enabled = true;
142
-        }
136
+		/**
137
+		 *    Switches back on the cookie sending and recieving.
138
+		 *    @access public
139
+		 */
140
+		function useCookies() {
141
+			$this->_cookies_enabled = true;
142
+		}
143 143
 
144
-        /**
145
-         *    Sets the socket timeout for opening a connection.
146
-         *    @param integer $timeout      Maximum time in seconds.
147
-         *    @access public
148
-         */
149
-        function setConnectionTimeout($timeout) {
150
-            $this->_connection_timeout = $timeout;
151
-        }
144
+		/**
145
+		 *    Sets the socket timeout for opening a connection.
146
+		 *    @param integer $timeout      Maximum time in seconds.
147
+		 *    @access public
148
+		 */
149
+		function setConnectionTimeout($timeout) {
150
+			$this->_connection_timeout = $timeout;
151
+		}
152 152
 
153
-        /**
154
-         *    Sets the maximum number of redirects before
155
-         *    a page will be loaded anyway.
156
-         *    @param integer $max        Most hops allowed.
157
-         *    @access public
158
-         */
159
-        function setMaximumRedirects($max) {
160
-            $this->_max_redirects = $max;
161
-        }
153
+		/**
154
+		 *    Sets the maximum number of redirects before
155
+		 *    a page will be loaded anyway.
156
+		 *    @param integer $max        Most hops allowed.
157
+		 *    @access public
158
+		 */
159
+		function setMaximumRedirects($max) {
160
+			$this->_max_redirects = $max;
161
+		}
162 162
 
163
-        /**
164
-         *    Sets proxy to use on all requests for when
165
-         *    testing from behind a firewall. Set URL
166
-         *    to false to disable.
167
-         *    @param string $proxy        Proxy URL.
168
-         *    @param string $username     Proxy username for authentication.
169
-         *    @param string $password     Proxy password for authentication.
170
-         *    @access public
171
-         */
172
-        function useProxy($proxy, $username, $password) {
173
-            if (! $proxy) {
174
-                $this->_proxy = false;
175
-                return;
176
-            }
177
-            if ((strncmp($proxy, 'http://', 7) != 0) && (strncmp($proxy, 'https://', 8) != 0)) {
178
-                $proxy = 'http://'. $proxy;
179
-            }
180
-            $this->_proxy = new SimpleUrl($proxy);
181
-            $this->_proxy_username = $username;
182
-            $this->_proxy_password = $password;
183
-        }
163
+		/**
164
+		 *    Sets proxy to use on all requests for when
165
+		 *    testing from behind a firewall. Set URL
166
+		 *    to false to disable.
167
+		 *    @param string $proxy        Proxy URL.
168
+		 *    @param string $username     Proxy username for authentication.
169
+		 *    @param string $password     Proxy password for authentication.
170
+		 *    @access public
171
+		 */
172
+		function useProxy($proxy, $username, $password) {
173
+			if (! $proxy) {
174
+				$this->_proxy = false;
175
+				return;
176
+			}
177
+			if ((strncmp($proxy, 'http://', 7) != 0) && (strncmp($proxy, 'https://', 8) != 0)) {
178
+				$proxy = 'http://'. $proxy;
179
+			}
180
+			$this->_proxy = new SimpleUrl($proxy);
181
+			$this->_proxy_username = $username;
182
+			$this->_proxy_password = $password;
183
+		}
184 184
 
185
-        /**
186
-         *    Test to see if the redirect limit is passed.
187
-         *    @param integer $redirects        Count so far.
188
-         *    @return boolean                  True if over.
189
-         *    @access private
190
-         */
191
-        function _isTooManyRedirects($redirects) {
192
-            return ($redirects > $this->_max_redirects);
193
-        }
185
+		/**
186
+		 *    Test to see if the redirect limit is passed.
187
+		 *    @param integer $redirects        Count so far.
188
+		 *    @return boolean                  True if over.
189
+		 *    @access private
190
+		 */
191
+		function _isTooManyRedirects($redirects) {
192
+			return ($redirects > $this->_max_redirects);
193
+		}
194 194
 
195
-        /**
196
-         *    Sets the identity for the current realm.
197
-         *    @param string $host        Host to which realm applies.
198
-         *    @param string $realm       Full name of realm.
199
-         *    @param string $username    Username for realm.
200
-         *    @param string $password    Password for realm.
201
-         *    @access public
202
-         */
203
-        function setIdentity($host, $realm, $username, $password) {
204
-            $this->_authenticator->setIdentityForRealm($host, $realm, $username, $password);
205
-        }
195
+		/**
196
+		 *    Sets the identity for the current realm.
197
+		 *    @param string $host        Host to which realm applies.
198
+		 *    @param string $realm       Full name of realm.
199
+		 *    @param string $username    Username for realm.
200
+		 *    @param string $password    Password for realm.
201
+		 *    @access public
202
+		 */
203
+		function setIdentity($host, $realm, $username, $password) {
204
+			$this->_authenticator->setIdentityForRealm($host, $realm, $username, $password);
205
+		}
206 206
 
207
-        /**
208
-         *    Fetches a URL as a response object. Will keep trying if redirected.
209
-         *    It will also collect authentication realm information.
210
-         *    @param string/SimpleUrl $url      Target to fetch.
211
-         *    @param SimpleEncoding $encoding   Additional parameters for request.
212
-         *    @return SimpleHttpResponse        Hopefully the target page.
213
-         *    @access public
214
-         */
215
-        function &fetchResponse($url, $encoding) {
216
-            if ($encoding->getMethod() != 'POST') {
217
-                $url->addRequestParameters($encoding);
218
-                $encoding->clear();
219
-            }
220
-            $response = $this->_fetchWhileRedirected($url, $encoding);
221
-            if ($headers = $response->getHeaders()) {
222
-                if ($headers->isChallenge()) {
223
-                    $this->_authenticator->addRealm(
224
-                            $url,
225
-                            $headers->getAuthentication(),
226
-                            $headers->getRealm());
227
-                }
228
-            }
229
-            return $response;
230
-        }
207
+		/**
208
+		 *    Fetches a URL as a response object. Will keep trying if redirected.
209
+		 *    It will also collect authentication realm information.
210
+		 *    @param string/SimpleUrl $url      Target to fetch.
211
+		 *    @param SimpleEncoding $encoding   Additional parameters for request.
212
+		 *    @return SimpleHttpResponse        Hopefully the target page.
213
+		 *    @access public
214
+		 */
215
+		function &fetchResponse($url, $encoding) {
216
+			if ($encoding->getMethod() != 'POST') {
217
+				$url->addRequestParameters($encoding);
218
+				$encoding->clear();
219
+			}
220
+			$response = $this->_fetchWhileRedirected($url, $encoding);
221
+			if ($headers = $response->getHeaders()) {
222
+				if ($headers->isChallenge()) {
223
+					$this->_authenticator->addRealm(
224
+							$url,
225
+							$headers->getAuthentication(),
226
+							$headers->getRealm());
227
+				}
228
+			}
229
+			return $response;
230
+		}
231 231
 
232
-        /**
233
-         *    Fetches the page until no longer redirected or
234
-         *    until the redirect limit runs out.
235
-         *    @param SimpleUrl $url                  Target to fetch.
236
-         *    @param SimpelFormEncoding $encoding    Additional parameters for request.
237
-         *    @return SimpleHttpResponse             Hopefully the target page.
238
-         *    @access private
239
-         */
240
-        function &_fetchWhileRedirected($url, $encoding) {
241
-            $redirects = 0;
242
-            do {
243
-                $response = $this->_fetch($url, $encoding);
244
-                if ($response->isError()) {
245
-                    return $response;
246
-                }
247
-                $headers = $response->getHeaders();
248
-                $location = new SimpleUrl($headers->getLocation());
249
-                $url = $location->makeAbsolute($url);
250
-                if ($this->_cookies_enabled) {
251
-                    $headers->writeCookiesToJar($this->_cookie_jar, $url);
252
-                }
253
-                if (! $headers->isRedirect()) {
254
-                    break;
255
-                }
256
-                $encoding = new SimpleGetEncoding();
257
-            } while (! $this->_isTooManyRedirects(++$redirects));
258
-            return $response;
259
-        }
232
+		/**
233
+		 *    Fetches the page until no longer redirected or
234
+		 *    until the redirect limit runs out.
235
+		 *    @param SimpleUrl $url                  Target to fetch.
236
+		 *    @param SimpelFormEncoding $encoding    Additional parameters for request.
237
+		 *    @return SimpleHttpResponse             Hopefully the target page.
238
+		 *    @access private
239
+		 */
240
+		function &_fetchWhileRedirected($url, $encoding) {
241
+			$redirects = 0;
242
+			do {
243
+				$response = $this->_fetch($url, $encoding);
244
+				if ($response->isError()) {
245
+					return $response;
246
+				}
247
+				$headers = $response->getHeaders();
248
+				$location = new SimpleUrl($headers->getLocation());
249
+				$url = $location->makeAbsolute($url);
250
+				if ($this->_cookies_enabled) {
251
+					$headers->writeCookiesToJar($this->_cookie_jar, $url);
252
+				}
253
+				if (! $headers->isRedirect()) {
254
+					break;
255
+				}
256
+				$encoding = new SimpleGetEncoding();
257
+			} while (! $this->_isTooManyRedirects(++$redirects));
258
+			return $response;
259
+		}
260 260
 
261
-        /**
262
-         *    Actually make the web request.
263
-         *    @param SimpleUrl $url                   Target to fetch.
264
-         *    @param SimpleFormEncoding $encoding     Additional parameters for request.
265
-         *    @return SimpleHttpResponse              Headers and hopefully content.
266
-         *    @access protected
267
-         */
268
-        function &_fetch($url, $encoding) {
269
-            $request = $this->_createRequest($url, $encoding);
270
-            $response = $request->fetch($this->_connection_timeout);
271
-            return $response;
272
-        }
261
+		/**
262
+		 *    Actually make the web request.
263
+		 *    @param SimpleUrl $url                   Target to fetch.
264
+		 *    @param SimpleFormEncoding $encoding     Additional parameters for request.
265
+		 *    @return SimpleHttpResponse              Headers and hopefully content.
266
+		 *    @access protected
267
+		 */
268
+		function &_fetch($url, $encoding) {
269
+			$request = $this->_createRequest($url, $encoding);
270
+			$response = $request->fetch($this->_connection_timeout);
271
+			return $response;
272
+		}
273 273
 
274
-        /**
275
-         *    Creates a full page request.
276
-         *    @param SimpleUrl $url                 Target to fetch as url object.
277
-         *    @param SimpleFormEncoding $encoding   POST/GET parameters.
278
-         *    @return SimpleHttpRequest             New request.
279
-         *    @access private
280
-         */
281
-        function &_createRequest($url, $encoding) {
282
-            $request = $this->_createHttpRequest($url, $encoding);
283
-            $this->_addAdditionalHeaders($request);
284
-            if ($this->_cookies_enabled) {
285
-                $request->readCookiesFromJar($this->_cookie_jar, $url);
286
-            }
287
-            $this->_authenticator->addHeaders($request, $url);
288
-            return $request;
289
-        }
274
+		/**
275
+		 *    Creates a full page request.
276
+		 *    @param SimpleUrl $url                 Target to fetch as url object.
277
+		 *    @param SimpleFormEncoding $encoding   POST/GET parameters.
278
+		 *    @return SimpleHttpRequest             New request.
279
+		 *    @access private
280
+		 */
281
+		function &_createRequest($url, $encoding) {
282
+			$request = $this->_createHttpRequest($url, $encoding);
283
+			$this->_addAdditionalHeaders($request);
284
+			if ($this->_cookies_enabled) {
285
+				$request->readCookiesFromJar($this->_cookie_jar, $url);
286
+			}
287
+			$this->_authenticator->addHeaders($request, $url);
288
+			return $request;
289
+		}
290 290
 
291
-        /**
292
-         *    Builds the appropriate HTTP request object.
293
-         *    @param SimpleUrl $url                  Target to fetch as url object.
294
-         *    @param SimpleFormEncoding $parameters  POST/GET parameters.
295
-         *    @return SimpleHttpRequest              New request object.
296
-         *    @access protected
297
-         */
298
-        function &_createHttpRequest($url, $encoding) {
299
-            $request = new SimpleHttpRequest($this->_createRoute($url), $encoding);
300
-            return $request;
301
-        }
291
+		/**
292
+		 *    Builds the appropriate HTTP request object.
293
+		 *    @param SimpleUrl $url                  Target to fetch as url object.
294
+		 *    @param SimpleFormEncoding $parameters  POST/GET parameters.
295
+		 *    @return SimpleHttpRequest              New request object.
296
+		 *    @access protected
297
+		 */
298
+		function &_createHttpRequest($url, $encoding) {
299
+			$request = new SimpleHttpRequest($this->_createRoute($url), $encoding);
300
+			return $request;
301
+		}
302 302
 
303
-        /**
304
-         *    Sets up either a direct route or via a proxy.
305
-         *    @param SimpleUrl $url   Target to fetch as url object.
306
-         *    @return SimpleRoute     Route to take to fetch URL.
307
-         *    @access protected
308
-         */
309
-        function &_createRoute($url) {
310
-            if ($this->_proxy) {
311
-                $route = new SimpleProxyRoute(
312
-                        $url,
313
-                        $this->_proxy,
314
-                        $this->_proxy_username,
315
-                        $this->_proxy_password);
316
-            } else {
317
-                $route = new SimpleRoute($url);
318
-            }
319
-            return $route;
320
-        }
303
+		/**
304
+		 *    Sets up either a direct route or via a proxy.
305
+		 *    @param SimpleUrl $url   Target to fetch as url object.
306
+		 *    @return SimpleRoute     Route to take to fetch URL.
307
+		 *    @access protected
308
+		 */
309
+		function &_createRoute($url) {
310
+			if ($this->_proxy) {
311
+				$route = new SimpleProxyRoute(
312
+						$url,
313
+						$this->_proxy,
314
+						$this->_proxy_username,
315
+						$this->_proxy_password);
316
+			} else {
317
+				$route = new SimpleRoute($url);
318
+			}
319
+			return $route;
320
+		}
321 321
 
322
-        /**
323
-         *    Adds additional manual headers.
324
-         *    @param SimpleHttpRequest $request    Outgoing request.
325
-         *    @access private
326
-         */
327
-        function _addAdditionalHeaders($request) {
328
-            foreach ($this->_additional_headers as $header) {
329
-                $request->addHeaderLine($header);
330
-            }
331
-        }
332
-    }
333 322
\ No newline at end of file
323
+		/**
324
+		 *    Adds additional manual headers.
325
+		 *    @param SimpleHttpRequest $request    Outgoing request.
326
+		 *    @access private
327
+		 */
328
+		function _addAdditionalHeaders($request) {
329
+			foreach ($this->_additional_headers as $header) {
330
+				$request->addHeaderLine($header);
331
+			}
332
+		}
333
+	}
334 334
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
     require_once(dirname(__FILE__) . '/authentication.php');
16 16
     /**#@-*/
17 17
 
18
-    if (! defined('DEFAULT_MAX_REDIRECTS')) {
18
+    if (!defined('DEFAULT_MAX_REDIRECTS')) {
19 19
         define('DEFAULT_MAX_REDIRECTS', 3);
20 20
     }
21 21
 
22
-    if (! defined('DEFAULT_CONNECTION_TIMEOUT')) {
22
+    if (!defined('DEFAULT_CONNECTION_TIMEOUT')) {
23 23
         define('DEFAULT_CONNECTION_TIMEOUT', 15);
24 24
     }
25 25
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
          *    @access public
120 120
          */
121 121
         function getBaseCookieValue($name, $base) {
122
-            if (! $base) {
122
+            if (!$base) {
123 123
                 return null;
124 124
             }
125 125
             return $this->getCookieValue($base->getHost(), $base->getPath(), $name);
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
          *    @access public
171 171
          */
172 172
         function useProxy($proxy, $username, $password) {
173
-            if (! $proxy) {
173
+            if (!$proxy) {
174 174
                 $this->_proxy = false;
175 175
                 return;
176 176
             }
177 177
             if ((strncmp($proxy, 'http://', 7) != 0) && (strncmp($proxy, 'https://', 8) != 0)) {
178
-                $proxy = 'http://'. $proxy;
178
+                $proxy = 'http://' . $proxy;
179 179
             }
180 180
             $this->_proxy = new SimpleUrl($proxy);
181 181
             $this->_proxy_username = $username;
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
                 if ($this->_cookies_enabled) {
251 251
                     $headers->writeCookiesToJar($this->_cookie_jar, $url);
252 252
                 }
253
-                if (! $headers->isRedirect()) {
253
+                if (!$headers->isRedirect()) {
254 254
                     break;
255 255
                 }
256 256
                 $encoding = new SimpleGetEncoding();
257
-            } while (! $this->_isTooManyRedirects(++$redirects));
257
+            } while (!$this->_isTooManyRedirects(++$redirects));
258 258
             return $response;
259 259
         }
260 260
 
Please login to merge, or discard this patch.
tests/test_tools/simpletest/web_tester.php 3 patches
Doc Comments   +1 added lines, -12 removed lines patch added patch discarded remove patch
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
         /**
500 500
          *    Creates a new default web browser object.
501 501
          *    Will be cleared at the end of the test method.
502
-         *    @return TestBrowser           New browser.
502
+         *    @return SimpleBrowser           New browser.
503 503
          *    @access public
504 504
          */
505 505
         function &createBrowser() {
@@ -1065,10 +1065,6 @@  discard block
 block discarded – undo
1065 1065
         /**
1066 1066
          *    Sets all form fields with that label, or name if there
1067 1067
          *    is no label attached.
1068
-         *    @param string $name    Name of field in forms.
1069
-         *    @param string $value   New value of field.
1070
-         *    @return boolean        True if field exists, otherwise false.
1071
-         *    @access public
1072 1068
          */
1073 1069
         function setField($label, $value) {
1074 1070
             return $this->_browser->setField($label, $value);
@@ -1101,13 +1097,6 @@  discard block
 block discarded – undo
1101 1097
          *    to the expected value. A missing form will always
1102 1098
          *    fail. If no value is given then only the existence
1103 1099
          *    of the field is checked.
1104
-         *    @param string $name       Name of field in forms.
1105
-         *    @param mixed $expected    Expected string/array value or
1106
-         *                              false for unset fields.
1107
-         *    @param string $message    Message to display. Default
1108
-         *                              can be embedded with %s.
1109
-         *    @return boolean           True if pass.
1110
-         *    @access public
1111 1100
          */
1112 1101
         function assertField($label, $expected = true, $message = '%s') {
1113 1102
             $value = $this->_browser->getField($label);
Please login to merge, or discard this patch.
Indentation   +1439 added lines, -1439 removed lines patch added patch discarded remove patch
@@ -1,1454 +1,1454 @@
 block discarded – undo
1 1
 <?php
2
-    /**
3
-     *	Base include file for SimpleTest.
4
-     *	@package	SimpleTest
5
-     *	@subpackage	WebTester
6
-     *	@version	$Id: web_tester.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: web_tester.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__) . '/test_case.php');
13
-    require_once(dirname(__FILE__) . '/browser.php');
14
-    require_once(dirname(__FILE__) . '/page.php');
15
-    require_once(dirname(__FILE__) . '/expectation.php');
16
-    /**#@-*/
17
-
18
-    /**
19
-     *    Test for an HTML widget value match.
12
+	require_once(dirname(__FILE__) . '/test_case.php');
13
+	require_once(dirname(__FILE__) . '/browser.php');
14
+	require_once(dirname(__FILE__) . '/page.php');
15
+	require_once(dirname(__FILE__) . '/expectation.php');
16
+	/**#@-*/
17
+
18
+	/**
19
+	 *    Test for an HTML widget value match.
20 20
 	 *	  @package SimpleTest
21 21
 	 *	  @subpackage WebTester
22
-     */
23
-    class FieldExpectation extends SimpleExpectation {
24
-        protected $_value;
25
-
26
-        /**
27
-         *    Sets the field value to compare against.
28
-         *    @param mixed $value     Test value to match. Can be an
29
-         *                            expectation for say pattern matching.
30
-         *    @param string $message  Optiona message override. Can use %s as
31
-         *                            a placeholder for the original message.
32
-         *    @access public
33
-         */
34
-        function FieldExpectation($value, $message = '%s') {
35
-            $this->SimpleExpectation($message);
36
-            if (is_array($value)) {
37
-                sort($value);
38
-            }
39
-            $this->_value = $value;
40
-        }
41
-
42
-        /**
43
-         *    Tests the expectation. True if it matches
44
-         *    a string value or an array value in any order.
45
-         *    @param mixed $compare        Comparison value. False for
46
-         *                                 an unset field.
47
-         *    @return boolean              True if correct.
48
-         *    @access public
49
-         */
50
-        function test($compare) {
51
-            if ($this->_value === false) {
52
-                return ($compare === false);
53
-            }
54
-            if ($this->_isSingle($this->_value)) {
55
-                return $this->_testSingle($compare);
56
-            }
57
-            if (is_array($this->_value)) {
58
-                return $this->_testMultiple($compare);
59
-            }
60
-            return false;
61
-        }
62
-
63
-        /**
64
-         *    Tests for valid field comparisons with a single option.
65
-         *    @param mixed $value       Value to type check.
66
-         *    @return boolean           True if integer, string or float.
67
-         *    @access private
68
-         */
69
-        function _isSingle($value) {
70
-            return is_string($value) || is_integer($value) || is_float($value);
71
-        }
72
-
73
-        /**
74
-         *    String comparison for simple field with a single option.
75
-         *    @param mixed $compare    String to test against.
76
-         *    @returns boolean         True if matching.
77
-         *    @access private
78
-         */
79
-        function _testSingle($compare) {
80
-            if (is_array($compare) && count($compare) == 1) {
81
-                $compare = $compare[0];
82
-            }
83
-            if (! $this->_isSingle($compare)) {
84
-                return false;
85
-            }
86
-            return ($this->_value == $compare);
87
-        }
88
-
89
-        /**
90
-         *    List comparison for multivalue field.
91
-         *    @param mixed $compare    List in any order to test against.
92
-         *    @returns boolean         True if matching.
93
-         *    @access private
94
-         */
95
-        function _testMultiple($compare) {
96
-            if (is_string($compare)) {
97
-                $compare = array($compare);
98
-            }
99
-            if (! is_array($compare)) {
100
-                return false;
101
-            }
102
-            sort($compare);
103
-            return ($this->_value === $compare);
104
-        }
105
-
106
-        /**
107
-         *    Returns a human readable test message.
108
-         *    @param mixed $compare      Comparison value.
109
-         *    @return string             Description of success
110
-         *                               or failure.
111
-         *    @access public
112
-         */
113
-        function testMessage($compare) {
114
-            $dumper = $this->_getDumper();
115
-            if (is_array($compare)) {
116
-                sort($compare);
117
-            }
118
-            if ($this->test($compare)) {
119
-                return "Field expectation [" . $dumper->describeValue($this->_value) . "]";
120
-            } else {
121
-                return "Field expectation [" . $dumper->describeValue($this->_value) .
122
-                        "] fails with [" .
123
-                        $this->_dumper->describeValue($compare) . "] " .
124
-                        $this->_dumper->describeDifference($this->_value, $compare);
125
-            }
126
-        }
127
-    }
128
-
129
-    /**
130
-     *    Test for a specific HTTP header within a header block.
22
+	 */
23
+	class FieldExpectation extends SimpleExpectation {
24
+		protected $_value;
25
+
26
+		/**
27
+		 *    Sets the field value to compare against.
28
+		 *    @param mixed $value     Test value to match. Can be an
29
+		 *                            expectation for say pattern matching.
30
+		 *    @param string $message  Optiona message override. Can use %s as
31
+		 *                            a placeholder for the original message.
32
+		 *    @access public
33
+		 */
34
+		function FieldExpectation($value, $message = '%s') {
35
+			$this->SimpleExpectation($message);
36
+			if (is_array($value)) {
37
+				sort($value);
38
+			}
39
+			$this->_value = $value;
40
+		}
41
+
42
+		/**
43
+		 *    Tests the expectation. True if it matches
44
+		 *    a string value or an array value in any order.
45
+		 *    @param mixed $compare        Comparison value. False for
46
+		 *                                 an unset field.
47
+		 *    @return boolean              True if correct.
48
+		 *    @access public
49
+		 */
50
+		function test($compare) {
51
+			if ($this->_value === false) {
52
+				return ($compare === false);
53
+			}
54
+			if ($this->_isSingle($this->_value)) {
55
+				return $this->_testSingle($compare);
56
+			}
57
+			if (is_array($this->_value)) {
58
+				return $this->_testMultiple($compare);
59
+			}
60
+			return false;
61
+		}
62
+
63
+		/**
64
+		 *    Tests for valid field comparisons with a single option.
65
+		 *    @param mixed $value       Value to type check.
66
+		 *    @return boolean           True if integer, string or float.
67
+		 *    @access private
68
+		 */
69
+		function _isSingle($value) {
70
+			return is_string($value) || is_integer($value) || is_float($value);
71
+		}
72
+
73
+		/**
74
+		 *    String comparison for simple field with a single option.
75
+		 *    @param mixed $compare    String to test against.
76
+		 *    @returns boolean         True if matching.
77
+		 *    @access private
78
+		 */
79
+		function _testSingle($compare) {
80
+			if (is_array($compare) && count($compare) == 1) {
81
+				$compare = $compare[0];
82
+			}
83
+			if (! $this->_isSingle($compare)) {
84
+				return false;
85
+			}
86
+			return ($this->_value == $compare);
87
+		}
88
+
89
+		/**
90
+		 *    List comparison for multivalue field.
91
+		 *    @param mixed $compare    List in any order to test against.
92
+		 *    @returns boolean         True if matching.
93
+		 *    @access private
94
+		 */
95
+		function _testMultiple($compare) {
96
+			if (is_string($compare)) {
97
+				$compare = array($compare);
98
+			}
99
+			if (! is_array($compare)) {
100
+				return false;
101
+			}
102
+			sort($compare);
103
+			return ($this->_value === $compare);
104
+		}
105
+
106
+		/**
107
+		 *    Returns a human readable test message.
108
+		 *    @param mixed $compare      Comparison value.
109
+		 *    @return string             Description of success
110
+		 *                               or failure.
111
+		 *    @access public
112
+		 */
113
+		function testMessage($compare) {
114
+			$dumper = $this->_getDumper();
115
+			if (is_array($compare)) {
116
+				sort($compare);
117
+			}
118
+			if ($this->test($compare)) {
119
+				return "Field expectation [" . $dumper->describeValue($this->_value) . "]";
120
+			} else {
121
+				return "Field expectation [" . $dumper->describeValue($this->_value) .
122
+						"] fails with [" .
123
+						$this->_dumper->describeValue($compare) . "] " .
124
+						$this->_dumper->describeDifference($this->_value, $compare);
125
+			}
126
+		}
127
+	}
128
+
129
+	/**
130
+	 *    Test for a specific HTTP header within a header block.
131 131
 	 *	  @package SimpleTest
132 132
 	 *	  @subpackage WebTester
133
-     */
134
-    class HttpHeaderExpectation extends SimpleExpectation {
135
-        protected $_expected_header;
136
-        protected $_expected_value;
137
-
138
-        /**
139
-         *    Sets the field and value to compare against.
140
-         *    @param string $header   Case insenstive trimmed header name.
141
-         *    @param mixed $value     Optional value to compare. If not
142
-         *                            given then any value will match. If
143
-         *                            an expectation object then that will
144
-         *                            be used instead.
145
-         *    @param string $message  Optiona message override. Can use %s as
146
-         *                            a placeholder for the original message.
147
-         */
148
-        function HttpHeaderExpectation($header, $value = false, $message = '%s') {
149
-            $this->SimpleExpectation($message);
150
-            $this->_expected_header = $this->_normaliseHeader($header);
151
-            $this->_expected_value = $value;
152
-        }
153
-
154
-        /**
155
-         *    Accessor for aggregated object.
156
-         *    @return mixed        Expectation set in constructor.
157
-         *    @access protected
158
-         */
159
-        function _getExpectation() {
160
-            return $this->_expected_value;
161
-        }
162
-
163
-        /**
164
-         *    Removes whitespace at ends and case variations.
165
-         *    @param string $header    Name of header.
166
-         *    @param string            Trimmed and lowecased header
167
-         *                             name.
168
-         *    @access private
169
-         */
170
-        function _normaliseHeader($header) {
171
-            return strtolower(trim($header));
172
-        }
173
-
174
-        /**
175
-         *    Tests the expectation. True if it matches
176
-         *    a string value or an array value in any order.
177
-         *    @param mixed $compare   Raw header block to search.
178
-         *    @return boolean         True if header present.
179
-         *    @access public
180
-         */
181
-        function test($compare) {
182
-            return is_string($this->_findHeader($compare));
183
-        }
184
-
185
-        /**
186
-         *    Searches the incoming result. Will extract the matching
187
-         *    line as text.
188
-         *    @param mixed $compare   Raw header block to search.
189
-         *    @return string          Matching header line.
190
-         *    @access protected
191
-         */
192
-        function _findHeader($compare) {
193
-            $lines = split("\r\n", $compare);
194
-            foreach ($lines as $line) {
195
-                if ($this->_testHeaderLine($line)) {
196
-                    return $line;
197
-                }
198
-            }
199
-            return false;
200
-        }
201
-
202
-        /**
203
-         *    Compares a single header line against the expectation.
204
-         *    @param string $line      A single line to compare.
205
-         *    @return boolean          True if matched.
206
-         *    @access private
207
-         */
208
-        function _testHeaderLine($line) {
209
-            if (count($parsed = split(':', $line, 2)) < 2) {
210
-                return false;
211
-            }
212
-            list($header, $value) = $parsed;
213
-            if ($this->_normaliseHeader($header) != $this->_expected_header) {
214
-                return false;
215
-            }
216
-            return $this->_testHeaderValue($value, $this->_expected_value);
217
-        }
218
-
219
-        /**
220
-         *    Tests the value part of the header.
221
-         *    @param string $value        Value to test.
222
-         *    @param mixed $expected      Value to test against.
223
-         *    @return boolean             True if matched.
224
-         *    @access protected
225
-         */
226
-        function _testHeaderValue($value, $expected) {
227
-            if ($expected === false) {
228
-                return true;
229
-            }
230
-            if (SimpleExpectation::isExpectation($expected)) {
231
-                return $expected->test(trim($value));
232
-            }
233
-            return (trim($value) == trim($expected));
234
-        }
235
-
236
-        /**
237
-         *    Returns a human readable test message.
238
-         *    @param mixed $compare      Raw header block to search.
239
-         *    @return string             Description of success
240
-         *                               or failure.
241
-         *    @access public
242
-         */
243
-        function testMessage($compare) {
244
-            if (SimpleExpectation::isExpectation($this->_expected_value)) {
245
-                $message = $this->_expected_value->testMessage($compare);
246
-            } else {
247
-                $message = $this->_expected_header .
248
-                        ($this->_expected_value ? ': ' . $this->_expected_value : '');
249
-            }
250
-            if (is_string($line = $this->_findHeader($compare))) {
251
-                return "Searching for header [$message] found [$line]";
252
-            } else {
253
-                return "Failed to find header [$message]";
254
-            }
255
-        }
256
-    }
257
-
258
-    /**
259
-     *    Test for a specific HTTP header within a header block that
260
-     *    should not be found.
133
+	 */
134
+	class HttpHeaderExpectation extends SimpleExpectation {
135
+		protected $_expected_header;
136
+		protected $_expected_value;
137
+
138
+		/**
139
+		 *    Sets the field and value to compare against.
140
+		 *    @param string $header   Case insenstive trimmed header name.
141
+		 *    @param mixed $value     Optional value to compare. If not
142
+		 *                            given then any value will match. If
143
+		 *                            an expectation object then that will
144
+		 *                            be used instead.
145
+		 *    @param string $message  Optiona message override. Can use %s as
146
+		 *                            a placeholder for the original message.
147
+		 */
148
+		function HttpHeaderExpectation($header, $value = false, $message = '%s') {
149
+			$this->SimpleExpectation($message);
150
+			$this->_expected_header = $this->_normaliseHeader($header);
151
+			$this->_expected_value = $value;
152
+		}
153
+
154
+		/**
155
+		 *    Accessor for aggregated object.
156
+		 *    @return mixed        Expectation set in constructor.
157
+		 *    @access protected
158
+		 */
159
+		function _getExpectation() {
160
+			return $this->_expected_value;
161
+		}
162
+
163
+		/**
164
+		 *    Removes whitespace at ends and case variations.
165
+		 *    @param string $header    Name of header.
166
+		 *    @param string            Trimmed and lowecased header
167
+		 *                             name.
168
+		 *    @access private
169
+		 */
170
+		function _normaliseHeader($header) {
171
+			return strtolower(trim($header));
172
+		}
173
+
174
+		/**
175
+		 *    Tests the expectation. True if it matches
176
+		 *    a string value or an array value in any order.
177
+		 *    @param mixed $compare   Raw header block to search.
178
+		 *    @return boolean         True if header present.
179
+		 *    @access public
180
+		 */
181
+		function test($compare) {
182
+			return is_string($this->_findHeader($compare));
183
+		}
184
+
185
+		/**
186
+		 *    Searches the incoming result. Will extract the matching
187
+		 *    line as text.
188
+		 *    @param mixed $compare   Raw header block to search.
189
+		 *    @return string          Matching header line.
190
+		 *    @access protected
191
+		 */
192
+		function _findHeader($compare) {
193
+			$lines = split("\r\n", $compare);
194
+			foreach ($lines as $line) {
195
+				if ($this->_testHeaderLine($line)) {
196
+					return $line;
197
+				}
198
+			}
199
+			return false;
200
+		}
201
+
202
+		/**
203
+		 *    Compares a single header line against the expectation.
204
+		 *    @param string $line      A single line to compare.
205
+		 *    @return boolean          True if matched.
206
+		 *    @access private
207
+		 */
208
+		function _testHeaderLine($line) {
209
+			if (count($parsed = split(':', $line, 2)) < 2) {
210
+				return false;
211
+			}
212
+			list($header, $value) = $parsed;
213
+			if ($this->_normaliseHeader($header) != $this->_expected_header) {
214
+				return false;
215
+			}
216
+			return $this->_testHeaderValue($value, $this->_expected_value);
217
+		}
218
+
219
+		/**
220
+		 *    Tests the value part of the header.
221
+		 *    @param string $value        Value to test.
222
+		 *    @param mixed $expected      Value to test against.
223
+		 *    @return boolean             True if matched.
224
+		 *    @access protected
225
+		 */
226
+		function _testHeaderValue($value, $expected) {
227
+			if ($expected === false) {
228
+				return true;
229
+			}
230
+			if (SimpleExpectation::isExpectation($expected)) {
231
+				return $expected->test(trim($value));
232
+			}
233
+			return (trim($value) == trim($expected));
234
+		}
235
+
236
+		/**
237
+		 *    Returns a human readable test message.
238
+		 *    @param mixed $compare      Raw header block to search.
239
+		 *    @return string             Description of success
240
+		 *                               or failure.
241
+		 *    @access public
242
+		 */
243
+		function testMessage($compare) {
244
+			if (SimpleExpectation::isExpectation($this->_expected_value)) {
245
+				$message = $this->_expected_value->testMessage($compare);
246
+			} else {
247
+				$message = $this->_expected_header .
248
+						($this->_expected_value ? ': ' . $this->_expected_value : '');
249
+			}
250
+			if (is_string($line = $this->_findHeader($compare))) {
251
+				return "Searching for header [$message] found [$line]";
252
+			} else {
253
+				return "Failed to find header [$message]";
254
+			}
255
+		}
256
+	}
257
+
258
+	/**
259
+	 *    Test for a specific HTTP header within a header block that
260
+	 *    should not be found.
261 261
 	 *	  @package SimpleTest
262 262
 	 *	  @subpackage WebTester
263
-     */
264
-    class NoHttpHeaderExpectation extends HttpHeaderExpectation {
265
-        protected $_expected_header;
266
-        protected $_expected_value;
267
-
268
-        /**
269
-         *    Sets the field and value to compare against.
270
-         *    @param string $unwanted   Case insenstive trimmed header name.
271
-         *    @param string $message    Optiona message override. Can use %s as
272
-         *                              a placeholder for the original message.
273
-         */
274
-        function NoHttpHeaderExpectation($unwanted, $message = '%s') {
275
-            $this->HttpHeaderExpectation($unwanted, false, $message);
276
-        }
277
-
278
-        /**
279
-         *    Tests that the unwanted header is not found.
280
-         *    @param mixed $compare   Raw header block to search.
281
-         *    @return boolean         True if header present.
282
-         *    @access public
283
-         */
284
-        function test($compare) {
285
-            return ($this->_findHeader($compare) === false);
286
-        }
287
-
288
-        /**
289
-         *    Returns a human readable test message.
290
-         *    @param mixed $compare      Raw header block to search.
291
-         *    @return string             Description of success
292
-         *                               or failure.
293
-         *    @access public
294
-         */
295
-        function testMessage($compare) {
296
-            $expectation = $this->_getExpectation();
297
-            if (is_string($line = $this->_findHeader($compare))) {
298
-                return "Found unwanted header [$expectation] with [$line]";
299
-            } else {
300
-                return "Did not find unwanted header [$expectation]";
301
-            }
302
-        }
303
-    }
304
-
305
-    /**
306
-     *    Test for a text substring.
263
+	 */
264
+	class NoHttpHeaderExpectation extends HttpHeaderExpectation {
265
+		protected $_expected_header;
266
+		protected $_expected_value;
267
+
268
+		/**
269
+		 *    Sets the field and value to compare against.
270
+		 *    @param string $unwanted   Case insenstive trimmed header name.
271
+		 *    @param string $message    Optiona message override. Can use %s as
272
+		 *                              a placeholder for the original message.
273
+		 */
274
+		function NoHttpHeaderExpectation($unwanted, $message = '%s') {
275
+			$this->HttpHeaderExpectation($unwanted, false, $message);
276
+		}
277
+
278
+		/**
279
+		 *    Tests that the unwanted header is not found.
280
+		 *    @param mixed $compare   Raw header block to search.
281
+		 *    @return boolean         True if header present.
282
+		 *    @access public
283
+		 */
284
+		function test($compare) {
285
+			return ($this->_findHeader($compare) === false);
286
+		}
287
+
288
+		/**
289
+		 *    Returns a human readable test message.
290
+		 *    @param mixed $compare      Raw header block to search.
291
+		 *    @return string             Description of success
292
+		 *                               or failure.
293
+		 *    @access public
294
+		 */
295
+		function testMessage($compare) {
296
+			$expectation = $this->_getExpectation();
297
+			if (is_string($line = $this->_findHeader($compare))) {
298
+				return "Found unwanted header [$expectation] with [$line]";
299
+			} else {
300
+				return "Did not find unwanted header [$expectation]";
301
+			}
302
+		}
303
+	}
304
+
305
+	/**
306
+	 *    Test for a text substring.
307 307
 	 *	  @package SimpleTest
308 308
 	 *	  @subpackage UnitTester
309
-     */
310
-    class TextExpectation extends SimpleExpectation {
311
-        protected $_substring;
312
-
313
-        /**
314
-         *    Sets the value to compare against.
315
-         *    @param string $substring  Text to search for.
316
-         *    @param string $message    Customised message on failure.
317
-         *    @access public
318
-         */
319
-        function TextExpectation($substring, $message = '%s') {
320
-            $this->SimpleExpectation($message);
321
-            $this->_substring = $substring;
322
-        }
323
-
324
-        /**
325
-         *    Accessor for the substring.
326
-         *    @return string       Text to match.
327
-         *    @access protected
328
-         */
329
-        function _getSubstring() {
330
-            return $this->_substring;
331
-        }
332
-
333
-        /**
334
-         *    Tests the expectation. True if the text contains the
335
-         *    substring.
336
-         *    @param string $compare        Comparison value.
337
-         *    @return boolean               True if correct.
338
-         *    @access public
339
-         */
340
-        function test($compare) {
341
-            return (strpos($compare, $this->_substring) !== false);
342
-        }
343
-
344
-        /**
345
-         *    Returns a human readable test message.
346
-         *    @param mixed $compare      Comparison value.
347
-         *    @return string             Description of success
348
-         *                               or failure.
349
-         *    @access public
350
-         */
351
-        function testMessage($compare) {
352
-            if ($this->test($compare)) {
353
-                return $this->_describeTextMatch($this->_getSubstring(), $compare);
354
-            } else {
355
-                $dumper = $this->_getDumper();
356
-                return "Text [" . $this->_getSubstring() .
357
-                        "] not detected in [" .
358
-                        $dumper->describeValue($compare) . "]";
359
-            }
360
-        }
361
-
362
-        /**
363
-         *    Describes a pattern match including the string
364
-         *    found and it's position.
365
-         *    @param string $substring      Text to search for.
366
-         *    @param string $subject        Subject to search.
367
-         *    @access protected
368
-         */
369
-        function _describeTextMatch($substring, $subject) {
370
-            $position = strpos($subject, $substring);
371
-            $dumper = $this->_getDumper();
372
-            return "Text [$substring] detected at character [$position] in [" .
373
-                    $dumper->describeValue($subject) . "] in region [" .
374
-                    $dumper->clipString($subject, 100, $position) . "]";
375
-        }
376
-    }
377
-
378
-    /**
379
-     *    Fail if a substring is detected within the
380
-     *    comparison text.
309
+	 */
310
+	class TextExpectation extends SimpleExpectation {
311
+		protected $_substring;
312
+
313
+		/**
314
+		 *    Sets the value to compare against.
315
+		 *    @param string $substring  Text to search for.
316
+		 *    @param string $message    Customised message on failure.
317
+		 *    @access public
318
+		 */
319
+		function TextExpectation($substring, $message = '%s') {
320
+			$this->SimpleExpectation($message);
321
+			$this->_substring = $substring;
322
+		}
323
+
324
+		/**
325
+		 *    Accessor for the substring.
326
+		 *    @return string       Text to match.
327
+		 *    @access protected
328
+		 */
329
+		function _getSubstring() {
330
+			return $this->_substring;
331
+		}
332
+
333
+		/**
334
+		 *    Tests the expectation. True if the text contains the
335
+		 *    substring.
336
+		 *    @param string $compare        Comparison value.
337
+		 *    @return boolean               True if correct.
338
+		 *    @access public
339
+		 */
340
+		function test($compare) {
341
+			return (strpos($compare, $this->_substring) !== false);
342
+		}
343
+
344
+		/**
345
+		 *    Returns a human readable test message.
346
+		 *    @param mixed $compare      Comparison value.
347
+		 *    @return string             Description of success
348
+		 *                               or failure.
349
+		 *    @access public
350
+		 */
351
+		function testMessage($compare) {
352
+			if ($this->test($compare)) {
353
+				return $this->_describeTextMatch($this->_getSubstring(), $compare);
354
+			} else {
355
+				$dumper = $this->_getDumper();
356
+				return "Text [" . $this->_getSubstring() .
357
+						"] not detected in [" .
358
+						$dumper->describeValue($compare) . "]";
359
+			}
360
+		}
361
+
362
+		/**
363
+		 *    Describes a pattern match including the string
364
+		 *    found and it's position.
365
+		 *    @param string $substring      Text to search for.
366
+		 *    @param string $subject        Subject to search.
367
+		 *    @access protected
368
+		 */
369
+		function _describeTextMatch($substring, $subject) {
370
+			$position = strpos($subject, $substring);
371
+			$dumper = $this->_getDumper();
372
+			return "Text [$substring] detected at character [$position] in [" .
373
+					$dumper->describeValue($subject) . "] in region [" .
374
+					$dumper->clipString($subject, 100, $position) . "]";
375
+		}
376
+	}
377
+
378
+	/**
379
+	 *    Fail if a substring is detected within the
380
+	 *    comparison text.
381 381
 	 *	  @package SimpleTest
382 382
 	 *	  @subpackage UnitTester
383
-     */
384
-    class NoTextExpectation extends TextExpectation {
385
-
386
-        /**
387
-         *    Sets the reject pattern
388
-         *    @param string $substring  Text to search for.
389
-         *    @param string $message    Customised message on failure.
390
-         *    @access public
391
-         */
392
-        function NoTextExpectation($substring, $message = '%s') {
393
-            $this->TextExpectation($substring, $message);
394
-        }
395
-
396
-        /**
397
-         *    Tests the expectation. False if the substring appears
398
-         *    in the text.
399
-         *    @param string $compare        Comparison value.
400
-         *    @return boolean               True if correct.
401
-         *    @access public
402
-         */
403
-        function test($compare) {
404
-            return ! parent::test($compare);
405
-        }
406
-
407
-        /**
408
-         *    Returns a human readable test message.
409
-         *    @param string $compare      Comparison value.
410
-         *    @return string              Description of success
411
-         *                                or failure.
412
-         *    @access public
413
-         */
414
-        function testMessage($compare) {
415
-            if ($this->test($compare)) {
416
-                $dumper = $this->_getDumper();
417
-                return "Text [" . $this->_getSubstring() .
418
-                        "] not detected in [" .
419
-                        $dumper->describeValue($compare) . "]";
420
-            } else {
421
-                return $this->_describeTextMatch($this->_getSubstring(), $compare);
422
-            }
423
-        }
424
-    }
425
-
426
-    /**
427
-     *    Test case for testing of web pages. Allows
428
-     *    fetching of pages, parsing of HTML and
429
-     *    submitting forms.
383
+	 */
384
+	class NoTextExpectation extends TextExpectation {
385
+
386
+		/**
387
+		 *    Sets the reject pattern
388
+		 *    @param string $substring  Text to search for.
389
+		 *    @param string $message    Customised message on failure.
390
+		 *    @access public
391
+		 */
392
+		function NoTextExpectation($substring, $message = '%s') {
393
+			$this->TextExpectation($substring, $message);
394
+		}
395
+
396
+		/**
397
+		 *    Tests the expectation. False if the substring appears
398
+		 *    in the text.
399
+		 *    @param string $compare        Comparison value.
400
+		 *    @return boolean               True if correct.
401
+		 *    @access public
402
+		 */
403
+		function test($compare) {
404
+			return ! parent::test($compare);
405
+		}
406
+
407
+		/**
408
+		 *    Returns a human readable test message.
409
+		 *    @param string $compare      Comparison value.
410
+		 *    @return string              Description of success
411
+		 *                                or failure.
412
+		 *    @access public
413
+		 */
414
+		function testMessage($compare) {
415
+			if ($this->test($compare)) {
416
+				$dumper = $this->_getDumper();
417
+				return "Text [" . $this->_getSubstring() .
418
+						"] not detected in [" .
419
+						$dumper->describeValue($compare) . "]";
420
+			} else {
421
+				return $this->_describeTextMatch($this->_getSubstring(), $compare);
422
+			}
423
+		}
424
+	}
425
+
426
+	/**
427
+	 *    Test case for testing of web pages. Allows
428
+	 *    fetching of pages, parsing of HTML and
429
+	 *    submitting forms.
430 430
 	 *    @package SimpleTest
431 431
 	 *    @subpackage WebTester
432
-     */
433
-    class WebTestCase extends SimpleTestCase {
434
-        protected $_browser;
435
-        protected $_ignore_errors = false;
436
-
437
-        /**
438
-         *    Creates an empty test case. Should be subclassed
439
-         *    with test methods for a functional test case.
440
-         *    @param string $label     Name of test case. Will use
441
-         *                             the class name if none specified.
442
-         *    @access public
443
-         */
444
-        function WebTestCase($label = false) {
445
-            $this->SimpleTestCase($label);
446
-        }
447
-
448
-        /**
449
-         *    Announces the start of the test.
450
-         *    @param string $method    Test method just started.
451
-         *    @access public
452
-         */
453
-        function before($method) {
454
-            parent::before($method);
455
-            $this->setBrowser($this->createBrowser());
456
-        }
457
-
458
-        /**
459
-         *    Announces the end of the test. Includes private clean up.
460
-         *    @param string $method    Test method just finished.
461
-         *    @access public
462
-         */
463
-        function after($method) {
464
-            $this->unsetBrowser();
465
-            parent::after($method);
466
-        }
467
-
468
-        /**
469
-         *    Gets a current browser reference for setting
470
-         *    special expectations or for detailed
471
-         *    examination of page fetches.
472
-         *    @return SimpleBrowser     Current test browser object.
473
-         *    @access public
474
-         */
475
-        function &getBrowser() {
476
-            return $this->_browser;
477
-        }
478
-
479
-        /**
480
-         *    Gets a current browser reference for setting
481
-         *    special expectations or for detailed
482
-         *    examination of page fetches.
483
-         *    @param SimpleBrowser $browser    New test browser object.
484
-         *    @access public
485
-         */
486
-        function setBrowser($browser) {
487
-            return $this->_browser = $browser;
488
-        }
489
-
490
-        /**
491
-         *    Clears the current browser reference to help the
492
-         *    PHP garbage collector.
493
-         *    @access public
494
-         */
495
-        function unsetBrowser() {
496
-            unset($this->_browser);
497
-        }
498
-
499
-        /**
500
-         *    Creates a new default web browser object.
501
-         *    Will be cleared at the end of the test method.
502
-         *    @return TestBrowser           New browser.
503
-         *    @access public
504
-         */
505
-        function &createBrowser() {
506
-            $browser = new SimpleBrowser();
507
-            return $browser;
508
-        }
509
-
510
-        /**
511
-         *    Gets the last response error.
512
-         *    @return string    Last low level HTTP error.
513
-         *    @access public
514
-         */
515
-        function getTransportError() {
516
-            return $this->_browser->getTransportError();
517
-        }
518
-
519
-        /**
520
-         *    Accessor for the currently selected URL.
521
-         *    @return string        Current location or false if
522
-         *                          no page yet fetched.
523
-         *    @access public
524
-         */
525
-        function getUrl() {
526
-            return $this->_browser->getUrl();
527
-        }
528
-
529
-        /**
530
-         *    Dumps the current request for debugging.
531
-         *    @access public
532
-         */
533
-        function showRequest() {
534
-            $this->dump($this->_browser->getRequest());
535
-        }
536
-
537
-        /**
538
-         *    Dumps the current HTTP headers for debugging.
539
-         *    @access public
540
-         */
541
-        function showHeaders() {
542
-            $this->dump($this->_browser->getHeaders());
543
-        }
544
-
545
-        /**
546
-         *    Dumps the current HTML source for debugging.
547
-         *    @access public
548
-         */
549
-        function showSource() {
550
-            $this->dump($this->_browser->getContent());
551
-        }
552
-
553
-        /**
554
-         *    Dumps the visible text only for debugging.
555
-         *    @access public
556
-         */
557
-        function showText() {
558
-            $this->dump(wordwrap($this->_browser->getContentAsText(), 80));
559
-        }
560
-
561
-        /**
562
-         *    Simulates the closing and reopening of the browser.
563
-         *    Temporary cookies will be discarded and timed
564
-         *    cookies will be expired if later than the
565
-         *    specified time.
566
-         *    @param string/integer $date Time when session restarted.
567
-         *                                If ommitted then all persistent
568
-         *                                cookies are kept. Time is either
569
-         *                                Cookie format string or timestamp.
570
-         *    @access public
571
-         */
572
-        function restart($date = false) {
573
-            if ($date === false) {
574
-                $date = time();
575
-            }
576
-            $this->_browser->restart($date);
577
-        }
578
-
579
-        /**
580
-         *    Moves cookie expiry times back into the past.
581
-         *    Useful for testing timeouts and expiries.
582
-         *    @param integer $interval    Amount to age in seconds.
583
-         *    @access public
584
-         */
585
-        function ageCookies($interval) {
586
-            $this->_browser->ageCookies($interval);
587
-        }
588
-
589
-        /**
590
-         *    Disables frames support. Frames will not be fetched
591
-         *    and the frameset page will be used instead.
592
-         *    @access public
593
-         */
594
-        function ignoreFrames() {
595
-            $this->_browser->ignoreFrames();
596
-        }
597
-
598
-        /**
599
-         *    Switches off cookie sending and recieving.
600
-         *    @access public
601
-         */
602
-        function ignoreCookies() {
603
-            $this->_browser->ignoreCookies();
604
-        }
605
-
606
-        /**
607
-         *    Skips errors for the next request only. You might
608
-         *    want to confirm that a page is unreachable for
609
-         *    example.
610
-         *    @access public
611
-         */
612
-        function ignoreErrors() {
613
-            $this->_ignore_errors = true;
614
-        }
615
-
616
-        /**
617
-         *    Issues a fail if there is a transport error anywhere
618
-         *    in the current frameset. Only one such error is
619
-         *    reported.
620
-         *    @param string/boolean $result   HTML or failure.
621
-         *    @return string/boolean $result  Passes through result.
622
-         *    @access private
623
-         */
624
-        function _failOnError($result) {
625
-            if (! $this->_ignore_errors) {
626
-                if ($error = $this->_browser->getTransportError()) {
627
-                    $this->fail($error);
628
-                }
629
-            }
630
-            $this->_ignore_errors = false;
631
-            return $result;
632
-        }
633
-
634
-        /**
635
-         *    Adds a header to every fetch.
636
-         *    @param string $header       Header line to add to every
637
-         *                                request until cleared.
638
-         *    @access public
639
-         */
640
-        function addHeader($header) {
641
-            $this->_browser->addHeader($header);
642
-        }
643
-
644
-        /**
645
-         *    Sets the maximum number of redirects before
646
-         *    the web page is loaded regardless.
647
-         *    @param integer $max        Maximum hops.
648
-         *    @access public
649
-         */
650
-        function setMaximumRedirects($max) {
651
-            if (! $this->_browser) {
652
-                trigger_error(
653
-                        'Can only set maximum redirects in a test method, setUp() or tearDown()');
654
-            }
655
-            $this->_browser->setMaximumRedirects($max);
656
-        }
657
-
658
-        /**
659
-         *    Sets the socket timeout for opening a connection and
660
-         *    receiving at least one byte of information.
661
-         *    @param integer $timeout      Maximum time in seconds.
662
-         *    @access public
663
-         */
664
-        function setConnectionTimeout($timeout) {
665
-            $this->_browser->setConnectionTimeout($timeout);
666
-        }
667
-
668
-        /**
669
-         *    Sets proxy to use on all requests for when
670
-         *    testing from behind a firewall. Set URL
671
-         *    to false to disable.
672
-         *    @param string $proxy        Proxy URL.
673
-         *    @param string $username     Proxy username for authentication.
674
-         *    @param string $password     Proxy password for authentication.
675
-         *    @access public
676
-         */
677
-        function useProxy($proxy, $username = false, $password = false) {
678
-            $this->_browser->useProxy($proxy, $username, $password);
679
-        }
680
-
681
-        /**
682
-         *    Fetches a page into the page buffer. If
683
-         *    there is no base for the URL then the
684
-         *    current base URL is used. After the fetch
685
-         *    the base URL reflects the new location.
686
-         *    @param string $url          URL to fetch.
687
-         *    @param hash $parameters     Optional additional GET data.
688
-         *    @return boolean/string      Raw page on success.
689
-         *    @access public
690
-         */
691
-        function get($url, $parameters = false) {
692
-            return $this->_failOnError($this->_browser->get($url, $parameters));
693
-        }
694
-
695
-        /**
696
-         *    Fetches a page by POST into the page buffer.
697
-         *    If there is no base for the URL then the
698
-         *    current base URL is used. After the fetch
699
-         *    the base URL reflects the new location.
700
-         *    @param string $url          URL to fetch.
701
-         *    @param hash $parameters     Optional additional GET data.
702
-         *    @return boolean/string      Raw page on success.
703
-         *    @access public
704
-         */
705
-        function post($url, $parameters = false) {
706
-            return $this->_failOnError($this->_browser->post($url, $parameters));
707
-        }
708
-
709
-        /**
710
-         *    Does a HTTP HEAD fetch, fetching only the page
711
-         *    headers. The current base URL is unchanged by this.
712
-         *    @param string $url          URL to fetch.
713
-         *    @param hash $parameters     Optional additional GET data.
714
-         *    @return boolean             True on success.
715
-         *    @access public
716
-         */
717
-        function head($url, $parameters = false) {
718
-            return $this->_failOnError($this->_browser->head($url, $parameters));
719
-        }
720
-
721
-        /**
722
-         *    Equivalent to hitting the retry button on the
723
-         *    browser. Will attempt to repeat the page fetch.
724
-         *    @return boolean     True if fetch succeeded.
725
-         *    @access public
726
-         */
727
-        function retry() {
728
-            return $this->_failOnError($this->_browser->retry());
729
-        }
730
-
731
-        /**
732
-         *    Equivalent to hitting the back button on the
733
-         *    browser.
734
-         *    @return boolean     True if history entry and
735
-         *                        fetch succeeded.
736
-         *    @access public
737
-         */
738
-        function back() {
739
-            return $this->_failOnError($this->_browser->back());
740
-        }
741
-
742
-        /**
743
-         *    Equivalent to hitting the forward button on the
744
-         *    browser.
745
-         *    @return boolean     True if history entry and
746
-         *                        fetch succeeded.
747
-         *    @access public
748
-         */
749
-        function forward() {
750
-            return $this->_failOnError($this->_browser->forward());
751
-        }
752
-
753
-        /**
754
-         *    Retries a request after setting the authentication
755
-         *    for the current realm.
756
-         *    @param string $username    Username for realm.
757
-         *    @param string $password    Password for realm.
758
-         *    @return boolean/string     HTML on successful fetch. Note
759
-         *                               that authentication may still have
760
-         *                               failed.
761
-         *    @access public
762
-         */
763
-        function authenticate($username, $password) {
764
-            return $this->_failOnError(
765
-                    $this->_browser->authenticate($username, $password));
766
-        }
767
-
768
-        /**
769
-         *    Gets the cookie value for the current browser context.
770
-         *    @param string $name          Name of cookie.
771
-         *    @return string               Value of cookie or false if unset.
772
-         *    @access public
773
-         */
774
-        function getCookie($name) {
775
-            return $this->_browser->getCurrentCookieValue($name);
776
-        }
777
-
778
-        /**
779
-         *    Sets a cookie in the current browser.
780
-         *    @param string $name          Name of cookie.
781
-         *    @param string $value         Cookie value.
782
-         *    @param string $host          Host upon which the cookie is valid.
783
-         *    @param string $path          Cookie path if not host wide.
784
-         *    @param string $expiry        Expiry date.
785
-         *    @access public
786
-         */
787
-        function setCookie($name, $value, $host = false, $path = "/", $expiry = false) {
788
-            $this->_browser->setCookie($name, $value, $host, $path, $expiry);
789
-        }
790
-
791
-        /**
792
-         *    Accessor for current frame focus. Will be
793
-         *    false if no frame has focus.
794
-         *    @return integer/string/boolean    Label if any, otherwise
795
-         *                                      the position in the frameset
796
-         *                                      or false if none.
797
-         *    @access public
798
-         */
799
-        function getFrameFocus() {
800
-            return $this->_browser->getFrameFocus();
801
-        }
802
-
803
-        /**
804
-         *    Sets the focus by index. The integer index starts from 1.
805
-         *    @param integer $choice    Chosen frame.
806
-         *    @return boolean           True if frame exists.
807
-         *    @access public
808
-         */
809
-        function setFrameFocusByIndex($choice) {
810
-            return $this->_browser->setFrameFocusByIndex($choice);
811
-        }
812
-
813
-        /**
814
-         *    Sets the focus by name.
815
-         *    @param string $name    Chosen frame.
816
-         *    @return boolean        True if frame exists.
817
-         *    @access public
818
-         */
819
-        function setFrameFocus($name) {
820
-            return $this->_browser->setFrameFocus($name);
821
-        }
822
-
823
-        /**
824
-         *    Clears the frame focus. All frames will be searched
825
-         *    for content.
826
-         *    @access public
827
-         */
828
-        function clearFrameFocus() {
829
-            return $this->_browser->clearFrameFocus();
830
-        }
831
-
832
-        /**
833
-         *    Clicks a visible text item. Will first try buttons,
834
-         *    then links and then images.
835
-         *    @param string $label        Visible text or alt text.
836
-         *    @return string/boolean      Raw page or false.
837
-         *    @access public
838
-         */
839
-        function click($label) {
840
-            return $this->_failOnError($this->_browser->click($label));
841
-        }
842
-
843
-        /**
844
-         *    Clicks the submit button by label. The owning
845
-         *    form will be submitted by this.
846
-         *    @param string $label    Button label. An unlabeled
847
-         *                            button can be triggered by 'Submit'.
848
-         *    @param hash $additional Additional form values.
849
-         *    @return boolean/string  Page on success, else false.
850
-         *    @access public
851
-         */
852
-        function clickSubmit($label = 'Submit', $additional = false) {
853
-            return $this->_failOnError(
854
-                    $this->_browser->clickSubmit($label, $additional));
855
-        }
856
-
857
-        /**
858
-         *    Clicks the submit button by name attribute. The owning
859
-         *    form will be submitted by this.
860
-         *    @param string $name     Name attribute of button.
861
-         *    @param hash $additional Additional form values.
862
-         *    @return boolean/string  Page on success.
863
-         *    @access public
864
-         */
865
-        function clickSubmitByName($name, $additional = false) {
866
-            return $this->_failOnError(
867
-                    $this->_browser->clickSubmitByName($name, $additional));
868
-        }
869
-
870
-        /**
871
-         *    Clicks the submit button by ID attribute. The owning
872
-         *    form will be submitted by this.
873
-         *    @param string $id       ID attribute of button.
874
-         *    @param hash $additional Additional form values.
875
-         *    @return boolean/string  Page on success.
876
-         *    @access public
877
-         */
878
-        function clickSubmitById($id, $additional = false) {
879
-            return $this->_failOnError(
880
-                    $this->_browser->clickSubmitById($id, $additional));
881
-        }
882
-
883
-        /**
884
-         *    Clicks the submit image by some kind of label. Usually
885
-         *    the alt tag or the nearest equivalent. The owning
886
-         *    form will be submitted by this. Clicking outside of
887
-         *    the boundary of the coordinates will result in
888
-         *    a failure.
889
-         *    @param string $label    Alt attribute of button.
890
-         *    @param integer $x       X-coordinate of imaginary click.
891
-         *    @param integer $y       Y-coordinate of imaginary click.
892
-         *    @param hash $additional Additional form values.
893
-         *    @return boolean/string  Page on success.
894
-         *    @access public
895
-         */
896
-        function clickImage($label, $x = 1, $y = 1, $additional = false) {
897
-            return $this->_failOnError(
898
-                    $this->_browser->clickImage($label, $x, $y, $additional));
899
-        }
900
-
901
-        /**
902
-         *    Clicks the submit image by the name. Usually
903
-         *    the alt tag or the nearest equivalent. The owning
904
-         *    form will be submitted by this. Clicking outside of
905
-         *    the boundary of the coordinates will result in
906
-         *    a failure.
907
-         *    @param string $name     Name attribute of button.
908
-         *    @param integer $x       X-coordinate of imaginary click.
909
-         *    @param integer $y       Y-coordinate of imaginary click.
910
-         *    @param hash $additional Additional form values.
911
-         *    @return boolean/string  Page on success.
912
-         *    @access public
913
-         */
914
-        function clickImageByName($name, $x = 1, $y = 1, $additional = false) {
915
-            return $this->_failOnError(
916
-                    $this->_browser->clickImageByName($name, $x, $y, $additional));
917
-        }
918
-
919
-        /**
920
-         *    Clicks the submit image by ID attribute. The owning
921
-         *    form will be submitted by this. Clicking outside of
922
-         *    the boundary of the coordinates will result in
923
-         *    a failure.
924
-         *    @param integer/string $id   ID attribute of button.
925
-         *    @param integer $x           X-coordinate of imaginary click.
926
-         *    @param integer $y           Y-coordinate of imaginary click.
927
-         *    @param hash $additional     Additional form values.
928
-         *    @return boolean/string      Page on success.
929
-         *    @access public
930
-         */
931
-        function clickImageById($id, $x = 1, $y = 1, $additional = false) {
932
-            return $this->_failOnError(
933
-                    $this->_browser->clickImageById($id, $x, $y, $additional));
934
-        }
935
-
936
-        /**
937
-         *    Submits a form by the ID.
938
-         *    @param string $id       Form ID. No button information
939
-         *                            is submitted this way.
940
-         *    @return boolean/string  Page on success.
941
-         *    @access public
942
-         */
943
-        function submitFormById($id) {
944
-            return $this->_failOnError($this->_browser->submitFormById($id));
945
-        }
946
-
947
-        /**
948
-         *    Follows a link by name. Will click the first link
949
-         *    found with this link text by default, or a later
950
-         *    one if an index is given. Match is case insensitive
951
-         *    with normalised space.
952
-         *    @param string $label     Text between the anchor tags.
953
-         *    @param integer $index    Link position counting from zero.
954
-         *    @return boolean/string   Page on success.
955
-         *    @access public
956
-         */
957
-        function clickLink($label, $index = 0) {
958
-            return $this->_failOnError($this->_browser->clickLink($label, $index));
959
-        }
960
-
961
-        /**
962
-         *    Follows a link by id attribute.
963
-         *    @param string $id        ID attribute value.
964
-         *    @return boolean/string   Page on success.
965
-         *    @access public
966
-         */
967
-        function clickLinkById($id) {
968
-            return $this->_failOnError($this->_browser->clickLinkById($id));
969
-        }
970
-
971
-        /**
972
-         *    Will trigger a pass if the two parameters have
973
-         *    the same value only. Otherwise a fail. This
974
-         *    is for testing hand extracted text, etc.
975
-         *    @param mixed $first          Value to compare.
976
-         *    @param mixed $second         Value to compare.
977
-         *    @param string $message       Message to display.
978
-         *    @return boolean              True on pass
979
-         *    @access public
980
-         */
981
-        function assertEqual($first, $second, $message = "%s") {
982
-            return $this->assert(
983
-                    new EqualExpectation($first),
984
-                    $second,
985
-                    $message);
986
-        }
987
-
988
-        /**
989
-         *    Will trigger a pass if the two parameters have
990
-         *    a different value. Otherwise a fail. This
991
-         *    is for testing hand extracted text, etc.
992
-         *    @param mixed $first           Value to compare.
993
-         *    @param mixed $second          Value to compare.
994
-         *    @param string $message        Message to display.
995
-         *    @return boolean               True on pass
996
-         *    @access public
997
-         */
998
-        function assertNotEqual($first, $second, $message = "%s") {
999
-            return $this->assert(
1000
-                    new NotEqualExpectation($first),
1001
-                    $second,
1002
-                    $message);
1003
-        }
1004
-
1005
-        /**
1006
-         *    Tests for the presence of a link label. Match is
1007
-         *    case insensitive with normalised space.
1008
-         *    @param string $label     Text between the anchor tags.
1009
-         *    @param string $message   Message to display. Default
1010
-         *                             can be embedded with %s.
1011
-         *    @return boolean          True if link present.
1012
-         *    @access public
1013
-         */
1014
-        function assertLink($label, $message = "%s") {
1015
-            return $this->assertTrue(
1016
-                    $this->_browser->isLink($label),
1017
-                    sprintf($message, "Link [$label] should exist"));
1018
-        }
1019
-
1020
-        /**
1021
-         *    Tests for the non-presence of a link label. Match is
1022
-         *    case insensitive with normalised space.
1023
-         *    @param string/integer $label    Text between the anchor tags
1024
-         *                                    or ID attribute.
1025
-         *    @param string $message          Message to display. Default
1026
-         *                                    can be embedded with %s.
1027
-         *    @return boolean                 True if link missing.
1028
-         *    @access public
1029
-         */
1030
-        function assertNoLink($label, $message = "%s") {
1031
-            return $this->assertFalse(
1032
-                    $this->_browser->isLink($label),
1033
-                    sprintf($message, "Link [$label] should not exist"));
1034
-        }
1035
-
1036
-        /**
1037
-         *    Tests for the presence of a link id attribute.
1038
-         *    @param string $id        Id attribute value.
1039
-         *    @param string $message   Message to display. Default
1040
-         *                             can be embedded with %s.
1041
-         *    @return boolean          True if link present.
1042
-         *    @access public
1043
-         */
1044
-        function assertLinkById($id, $message = "%s") {
1045
-            return $this->assertTrue(
1046
-                    $this->_browser->isLinkById($id),
1047
-                    sprintf($message, "Link ID [$id] should exist"));
1048
-        }
1049
-
1050
-        /**
1051
-         *    Tests for the non-presence of a link label. Match is
1052
-         *    case insensitive with normalised space.
1053
-         *    @param string $id        Id attribute value.
1054
-         *    @param string $message   Message to display. Default
1055
-         *                             can be embedded with %s.
1056
-         *    @return boolean          True if link missing.
1057
-         *    @access public
1058
-         */
1059
-        function assertNoLinkById($id, $message = "%s") {
1060
-            return $this->assertFalse(
1061
-                    $this->_browser->isLinkById($id),
1062
-                    sprintf($message, "Link ID [$id] should not exist"));
1063
-        }
1064
-
1065
-        /**
1066
-         *    Sets all form fields with that label, or name if there
1067
-         *    is no label attached.
1068
-         *    @param string $name    Name of field in forms.
1069
-         *    @param string $value   New value of field.
1070
-         *    @return boolean        True if field exists, otherwise false.
1071
-         *    @access public
1072
-         */
1073
-        function setField($label, $value) {
1074
-            return $this->_browser->setField($label, $value);
1075
-        }
1076
-
1077
-        /**
1078
-         *    Sets all form fields with that name.
1079
-         *    @param string $name    Name of field in forms.
1080
-         *    @param string $value   New value of field.
1081
-         *    @return boolean        True if field exists, otherwise false.
1082
-         *    @access public
1083
-         */
1084
-        function setFieldByName($name, $value) {
1085
-            return $this->_browser->setFieldByName($name, $value);
1086
-        }
1087
-
1088
-        /**
1089
-         *    Sets all form fields with that name.
1090
-         *    @param string/integer $id   Id of field in forms.
1091
-         *    @param string $value        New value of field.
1092
-         *    @return boolean             True if field exists, otherwise false.
1093
-         *    @access public
1094
-         */
1095
-        function setFieldById($id, $value) {
1096
-            return $this->_browser->setFieldById($id, $value);
1097
-        }
1098
-
1099
-        /**
1100
-         *    Confirms that the form element is currently set
1101
-         *    to the expected value. A missing form will always
1102
-         *    fail. If no value is given then only the existence
1103
-         *    of the field is checked.
1104
-         *    @param string $name       Name of field in forms.
1105
-         *    @param mixed $expected    Expected string/array value or
1106
-         *                              false for unset fields.
1107
-         *    @param string $message    Message to display. Default
1108
-         *                              can be embedded with %s.
1109
-         *    @return boolean           True if pass.
1110
-         *    @access public
1111
-         */
1112
-        function assertField($label, $expected = true, $message = '%s') {
1113
-            $value = $this->_browser->getField($label);
1114
-            return $this->_assertFieldValue($label, $value, $expected, $message);
1115
-        }
1116
-
1117
-        /**
1118
-         *    Confirms that the form element is currently set
1119
-         *    to the expected value. A missing form element will always
1120
-         *    fail. If no value is given then only the existence
1121
-         *    of the field is checked.
1122
-         *    @param string $name       Name of field in forms.
1123
-         *    @param mixed $expected    Expected string/array value or
1124
-         *                              false for unset fields.
1125
-         *    @param string $message    Message to display. Default
1126
-         *                              can be embedded with %s.
1127
-         *    @return boolean           True if pass.
1128
-         *    @access public
1129
-         */
1130
-        function assertFieldByName($name, $expected = true, $message = '%s') {
1131
-            $value = $this->_browser->getFieldByName($name);
1132
-            return $this->_assertFieldValue($name, $value, $expected, $message);
1133
-        }
1134
-
1135
-        /**
1136
-         *    Confirms that the form element is currently set
1137
-         *    to the expected value. A missing form will always
1138
-         *    fail. If no ID is given then only the existence
1139
-         *    of the field is checked.
1140
-         *    @param string/integer $id  Name of field in forms.
1141
-         *    @param mixed $expected     Expected string/array value or
1142
-         *                               false for unset fields.
1143
-         *    @param string $message     Message to display. Default
1144
-         *                               can be embedded with %s.
1145
-         *    @return boolean            True if pass.
1146
-         *    @access public
1147
-         */
1148
-        function assertFieldById($id, $expected = true, $message = '%s') {
1149
-            $value = $this->_browser->getFieldById($id);
1150
-            return $this->_assertFieldValue($id, $value, $expected, $message);
1151
-        }
1152
-
1153
-        /**
1154
-         *    Tests the field value against the expectation.
1155
-         *    @param string $identifier      Name, ID or label.
1156
-         *    @param mixed $value            Current field value.
1157
-         *    @param mixed $expected         Expected value to match.
1158
-         *    @param string $message         Failure message.
1159
-         *    @return boolean                True if pass
1160
-         *    @access protected
1161
-         */
1162
-        function _assertFieldValue($identifier, $value, $expected, $message) {
1163
-            if ($expected === true) {
1164
-                return $this->assertTrue(
1165
-                        isset($value),
1166
-                        sprintf($message, "Field [$identifier] should exist"));
1167
-            }
1168
-            if (! SimpleExpectation::isExpectation($expected)) {
1169
-                $identifier = str_replace('%', '%%', $identifier);
1170
-                $expected = new FieldExpectation(
1171
-                        $expected,
1172
-                        "Field [$identifier] should match with [%s]");
1173
-            }
1174
-            return $this->assert($expected, $value, $message);
1175
-        }
1176
-
1177
-        /**
1178
-         *    Checks the response code against a list
1179
-         *    of possible values.
1180
-         *    @param array $responses    Possible responses for a pass.
1181
-         *    @param string $message     Message to display. Default
1182
-         *                               can be embedded with %s.
1183
-         *    @return boolean            True if pass.
1184
-         *    @access public
1185
-         */
1186
-        function assertResponse($responses, $message = '%s') {
1187
-            $responses = (is_array($responses) ? $responses : array($responses));
1188
-            $code = $this->_browser->getResponseCode();
1189
-            $message = sprintf($message, "Expecting response in [" .
1190
-                    implode(", ", $responses) . "] got [$code]");
1191
-            return $this->assertTrue(in_array($code, $responses), $message);
1192
-        }
1193
-
1194
-        /**
1195
-         *    Checks the mime type against a list
1196
-         *    of possible values.
1197
-         *    @param array $types      Possible mime types for a pass.
1198
-         *    @param string $message   Message to display.
1199
-         *    @return boolean          True if pass.
1200
-         *    @access public
1201
-         */
1202
-        function assertMime($types, $message = '%s') {
1203
-            $types = (is_array($types) ? $types : array($types));
1204
-            $type = $this->_browser->getMimeType();
1205
-            $message = sprintf($message, "Expecting mime type in [" .
1206
-                    implode(", ", $types) . "] got [$type]");
1207
-            return $this->assertTrue(in_array($type, $types), $message);
1208
-        }
1209
-
1210
-        /**
1211
-         *    Attempt to match the authentication type within
1212
-         *    the security realm we are currently matching.
1213
-         *    @param string $authentication   Usually basic.
1214
-         *    @param string $message          Message to display.
1215
-         *    @return boolean                 True if pass.
1216
-         *    @access public
1217
-         */
1218
-        function assertAuthentication($authentication = false, $message = '%s') {
1219
-            if (! $authentication) {
1220
-                $message = sprintf($message, "Expected any authentication type, got [" .
1221
-                        $this->_browser->getAuthentication() . "]");
1222
-                return $this->assertTrue(
1223
-                        $this->_browser->getAuthentication(),
1224
-                        $message);
1225
-            } else {
1226
-                $message = sprintf($message, "Expected authentication [$authentication] got [" .
1227
-                        $this->_browser->getAuthentication() . "]");
1228
-                return $this->assertTrue(
1229
-                        strtolower($this->_browser->getAuthentication()) == strtolower($authentication),
1230
-                        $message);
1231
-            }
1232
-        }
1233
-
1234
-        /**
1235
-         *    Checks that no authentication is necessary to view
1236
-         *    the desired page.
1237
-         *    @param string $message     Message to display.
1238
-         *    @return boolean            True if pass.
1239
-         *    @access public
1240
-         */
1241
-        function assertNoAuthentication($message = '%s') {
1242
-            $message = sprintf($message, "Expected no authentication type, got [" .
1243
-                    $this->_browser->getAuthentication() . "]");
1244
-            return $this->assertFalse($this->_browser->getAuthentication(), $message);
1245
-        }
1246
-
1247
-        /**
1248
-         *    Attempts to match the current security realm.
1249
-         *    @param string $realm     Name of security realm.
1250
-         *    @param string $message   Message to display.
1251
-         *    @return boolean          True if pass.
1252
-         *    @access public
1253
-         */
1254
-        function assertRealm($realm, $message = '%s') {
1255
-            if (! SimpleExpectation::isExpectation($realm)) {
1256
-                $realm = new EqualExpectation($realm);
1257
-            }
1258
-            return $this->assert(
1259
-                    $realm,
1260
-                    $this->_browser->getRealm(),
1261
-                    "Expected realm -> $message");
1262
-        }
1263
-
1264
-        /**
1265
-         *    Checks each header line for the required value. If no
1266
-         *    value is given then only an existence check is made.
1267
-         *    @param string $header    Case insensitive header name.
1268
-         *    @param mixed $value      Case sensitive trimmed string to
1269
-         *                             match against. An expectation object
1270
-         *                             can be used for pattern matching.
1271
-         *    @return boolean          True if pass.
1272
-         *    @access public
1273
-         */
1274
-        function assertHeader($header, $value = false, $message = '%s') {
1275
-            return $this->assert(
1276
-                    new HttpHeaderExpectation($header, $value),
1277
-                    $this->_browser->getHeaders(),
1278
-                    $message);
1279
-        }
1280
-
1281
-        /**
1282
-         *    @deprecated
1283
-         */
1284
-        function assertHeaderPattern($header, $pattern, $message = '%s') {
1285
-            return $this->assert(
1286
-                    new HttpHeaderExpectation($header, new PatternExpectation($pattern)),
1287
-                    $this->_browser->getHeaders(),
1288
-                    $message);
1289
-        }
1290
-
1291
-        /**
1292
-         *    Confirms that the header type has not been received.
1293
-         *    Only the landing page is checked. If you want to check
1294
-         *    redirect pages, then you should limit redirects so
1295
-         *    as to capture the page you want.
1296
-         *    @param string $header    Case insensitive header name.
1297
-         *    @return boolean          True if pass.
1298
-         *    @access public
1299
-         */
1300
-        function assertNoHeader($header, $message = '%s') {
1301
-            return $this->assert(
1302
-                    new NoHttpHeaderExpectation($header),
1303
-                    $this->_browser->getHeaders(),
1304
-                    $message);
1305
-        }
1306
-
1307
-        /**
1308
-         *    @deprecated
1309
-         */
1310
-        function assertNoUnwantedHeader($header, $message = '%s') {
1311
-            return $this->assertNoHeader($header, $message);
1312
-        }
1313
-
1314
-        /**
1315
-         *    Tests the text between the title tags.
1316
-         *    @param string $title      Expected title.
1317
-         *    @param string $message    Message to display.
1318
-         *    @return boolean           True if pass.
1319
-         *    @access public
1320
-         */
1321
-        function assertTitle($title = false, $message = '%s') {
1322
-            if (! SimpleExpectation::isExpectation($title)) {
1323
-                $title = new EqualExpectation($title);
1324
-            }
1325
-            return $this->assert($title, $this->_browser->getTitle(), $message);
1326
-        }
1327
-
1328
-        /**
1329
-         *    Will trigger a pass if the text is found in the plain
1330
-         *    text form of the page.
1331
-         *    @param string $text       Text to look for.
1332
-         *    @param string $message    Message to display.
1333
-         *    @return boolean           True if pass.
1334
-         *    @access public
1335
-         */
1336
-        function assertText($text, $message = '%s') {
1337
-            return $this->assert(
1338
-                    new TextExpectation($text),
1339
-                    $this->_browser->getContentAsText(),
1340
-                    $message);
1341
-        }
1342
-
1343
-        /**
1344
-         *	  @deprecated
1345
-         */
1346
-        function assertWantedText($text, $message = '%s') {
1347
-        	return $this->assertText($text, $message);
1348
-        }
1349
-
1350
-        /**
1351
-         *    Will trigger a pass if the text is not found in the plain
1352
-         *    text form of the page.
1353
-         *    @param string $text       Text to look for.
1354
-         *    @param string $message    Message to display.
1355
-         *    @return boolean           True if pass.
1356
-         *    @access public
1357
-         */
1358
-        function assertNoText($text, $message = '%s') {
1359
-            return $this->assert(
1360
-                    new NoTextExpectation($text),
1361
-                    $this->_browser->getContentAsText(),
1362
-                    $message);
1363
-        }
1364
-
1365
-        /**
1366
-         *	  @deprecated
1367
-         */
1368
-        function assertNoUnwantedText($text, $message = '%s') {
1369
-        	return $this->assertNoText($text, $message);
1370
-        }
1371
-
1372
-        /**
1373
-         *    Will trigger a pass if the Perl regex pattern
1374
-         *    is found in the raw content.
1375
-         *    @param string $pattern    Perl regex to look for including
1376
-         *                              the regex delimiters.
1377
-         *    @param string $message    Message to display.
1378
-         *    @return boolean           True if pass.
1379
-         *    @access public
1380
-         */
1381
-        function assertPattern($pattern, $message = '%s') {
1382
-            return $this->assert(
1383
-                    new PatternExpectation($pattern),
1384
-                    $this->_browser->getContent(),
1385
-                    $message);
1386
-        }
1387
-
1388
-        /**
1389
-         *	  @deprecated
1390
-         */
1391
-        function assertWantedPattern($pattern, $message = '%s') {
1392
-        	return $this->assertPattern($pattern, $message);
1393
-        }
1394
-
1395
-        /**
1396
-         *    Will trigger a pass if the perl regex pattern
1397
-         *    is not present in raw content.
1398
-         *    @param string $pattern    Perl regex to look for including
1399
-         *                              the regex delimiters.
1400
-         *    @param string $message    Message to display.
1401
-         *    @return boolean           True if pass.
1402
-         *    @access public
1403
-         */
1404
-        function assertNoPattern($pattern, $message = '%s') {
1405
-            return $this->assert(
1406
-                    new NoPatternExpectation($pattern),
1407
-                    $this->_browser->getContent(),
1408
-                    $message);
1409
-        }
1410
-
1411
-        /**
1412
-         *	  @deprecated
1413
-         */
1414
-        function assertNoUnwantedPattern($pattern, $message = '%s') {
1415
-        	return $this->assertNoPattern($pattern, $message);
1416
-        }
1417
-
1418
-        /**
1419
-         *    Checks that a cookie is set for the current page
1420
-         *    and optionally checks the value.
1421
-         *    @param string $name        Name of cookie to test.
1422
-         *    @param string $expected    Expected value as a string or
1423
-         *                               false if any value will do.
1424
-         *    @param string $message     Message to display.
1425
-         *    @return boolean            True if pass.
1426
-         *    @access public
1427
-         */
1428
-        function assertCookie($name, $expected = false, $message = '%s') {
1429
-            $value = $this->getCookie($name);
1430
-            if (! $expected) {
1431
-                return $this->assertTrue(
1432
-                        $value,
1433
-                        sprintf($message, "Expecting cookie [$name]"));
1434
-            }
1435
-            if (! SimpleExpectation::isExpectation($expected)) {
1436
-                $expected = new EqualExpectation($expected);
1437
-            }
1438
-            return $this->assert($expected, $value, "Expecting cookie [$name] -> $message");
1439
-        }
1440
-
1441
-        /**
1442
-         *    Checks that no cookie is present or that it has
1443
-         *    been successfully cleared.
1444
-         *    @param string $name        Name of cookie to test.
1445
-         *    @param string $message     Message to display.
1446
-         *    @return boolean            True if pass.
1447
-         *    @access public
1448
-         */
1449
-        function assertNoCookie($name, $message = '%s') {
1450
-            return $this->assertTrue(
1451
-                    $this->getCookie($name) === false,
1452
-                    sprintf($message, "Not expecting cookie [$name]"));
1453
-        }
1454
-    }
1455 432
\ No newline at end of file
433
+	 */
434
+	class WebTestCase extends SimpleTestCase {
435
+		protected $_browser;
436
+		protected $_ignore_errors = false;
437
+
438
+		/**
439
+		 *    Creates an empty test case. Should be subclassed
440
+		 *    with test methods for a functional test case.
441
+		 *    @param string $label     Name of test case. Will use
442
+		 *                             the class name if none specified.
443
+		 *    @access public
444
+		 */
445
+		function WebTestCase($label = false) {
446
+			$this->SimpleTestCase($label);
447
+		}
448
+
449
+		/**
450
+		 *    Announces the start of the test.
451
+		 *    @param string $method    Test method just started.
452
+		 *    @access public
453
+		 */
454
+		function before($method) {
455
+			parent::before($method);
456
+			$this->setBrowser($this->createBrowser());
457
+		}
458
+
459
+		/**
460
+		 *    Announces the end of the test. Includes private clean up.
461
+		 *    @param string $method    Test method just finished.
462
+		 *    @access public
463
+		 */
464
+		function after($method) {
465
+			$this->unsetBrowser();
466
+			parent::after($method);
467
+		}
468
+
469
+		/**
470
+		 *    Gets a current browser reference for setting
471
+		 *    special expectations or for detailed
472
+		 *    examination of page fetches.
473
+		 *    @return SimpleBrowser     Current test browser object.
474
+		 *    @access public
475
+		 */
476
+		function &getBrowser() {
477
+			return $this->_browser;
478
+		}
479
+
480
+		/**
481
+		 *    Gets a current browser reference for setting
482
+		 *    special expectations or for detailed
483
+		 *    examination of page fetches.
484
+		 *    @param SimpleBrowser $browser    New test browser object.
485
+		 *    @access public
486
+		 */
487
+		function setBrowser($browser) {
488
+			return $this->_browser = $browser;
489
+		}
490
+
491
+		/**
492
+		 *    Clears the current browser reference to help the
493
+		 *    PHP garbage collector.
494
+		 *    @access public
495
+		 */
496
+		function unsetBrowser() {
497
+			unset($this->_browser);
498
+		}
499
+
500
+		/**
501
+		 *    Creates a new default web browser object.
502
+		 *    Will be cleared at the end of the test method.
503
+		 *    @return TestBrowser           New browser.
504
+		 *    @access public
505
+		 */
506
+		function &createBrowser() {
507
+			$browser = new SimpleBrowser();
508
+			return $browser;
509
+		}
510
+
511
+		/**
512
+		 *    Gets the last response error.
513
+		 *    @return string    Last low level HTTP error.
514
+		 *    @access public
515
+		 */
516
+		function getTransportError() {
517
+			return $this->_browser->getTransportError();
518
+		}
519
+
520
+		/**
521
+		 *    Accessor for the currently selected URL.
522
+		 *    @return string        Current location or false if
523
+		 *                          no page yet fetched.
524
+		 *    @access public
525
+		 */
526
+		function getUrl() {
527
+			return $this->_browser->getUrl();
528
+		}
529
+
530
+		/**
531
+		 *    Dumps the current request for debugging.
532
+		 *    @access public
533
+		 */
534
+		function showRequest() {
535
+			$this->dump($this->_browser->getRequest());
536
+		}
537
+
538
+		/**
539
+		 *    Dumps the current HTTP headers for debugging.
540
+		 *    @access public
541
+		 */
542
+		function showHeaders() {
543
+			$this->dump($this->_browser->getHeaders());
544
+		}
545
+
546
+		/**
547
+		 *    Dumps the current HTML source for debugging.
548
+		 *    @access public
549
+		 */
550
+		function showSource() {
551
+			$this->dump($this->_browser->getContent());
552
+		}
553
+
554
+		/**
555
+		 *    Dumps the visible text only for debugging.
556
+		 *    @access public
557
+		 */
558
+		function showText() {
559
+			$this->dump(wordwrap($this->_browser->getContentAsText(), 80));
560
+		}
561
+
562
+		/**
563
+		 *    Simulates the closing and reopening of the browser.
564
+		 *    Temporary cookies will be discarded and timed
565
+		 *    cookies will be expired if later than the
566
+		 *    specified time.
567
+		 *    @param string/integer $date Time when session restarted.
568
+		 *                                If ommitted then all persistent
569
+		 *                                cookies are kept. Time is either
570
+		 *                                Cookie format string or timestamp.
571
+		 *    @access public
572
+		 */
573
+		function restart($date = false) {
574
+			if ($date === false) {
575
+				$date = time();
576
+			}
577
+			$this->_browser->restart($date);
578
+		}
579
+
580
+		/**
581
+		 *    Moves cookie expiry times back into the past.
582
+		 *    Useful for testing timeouts and expiries.
583
+		 *    @param integer $interval    Amount to age in seconds.
584
+		 *    @access public
585
+		 */
586
+		function ageCookies($interval) {
587
+			$this->_browser->ageCookies($interval);
588
+		}
589
+
590
+		/**
591
+		 *    Disables frames support. Frames will not be fetched
592
+		 *    and the frameset page will be used instead.
593
+		 *    @access public
594
+		 */
595
+		function ignoreFrames() {
596
+			$this->_browser->ignoreFrames();
597
+		}
598
+
599
+		/**
600
+		 *    Switches off cookie sending and recieving.
601
+		 *    @access public
602
+		 */
603
+		function ignoreCookies() {
604
+			$this->_browser->ignoreCookies();
605
+		}
606
+
607
+		/**
608
+		 *    Skips errors for the next request only. You might
609
+		 *    want to confirm that a page is unreachable for
610
+		 *    example.
611
+		 *    @access public
612
+		 */
613
+		function ignoreErrors() {
614
+			$this->_ignore_errors = true;
615
+		}
616
+
617
+		/**
618
+		 *    Issues a fail if there is a transport error anywhere
619
+		 *    in the current frameset. Only one such error is
620
+		 *    reported.
621
+		 *    @param string/boolean $result   HTML or failure.
622
+		 *    @return string/boolean $result  Passes through result.
623
+		 *    @access private
624
+		 */
625
+		function _failOnError($result) {
626
+			if (! $this->_ignore_errors) {
627
+				if ($error = $this->_browser->getTransportError()) {
628
+					$this->fail($error);
629
+				}
630
+			}
631
+			$this->_ignore_errors = false;
632
+			return $result;
633
+		}
634
+
635
+		/**
636
+		 *    Adds a header to every fetch.
637
+		 *    @param string $header       Header line to add to every
638
+		 *                                request until cleared.
639
+		 *    @access public
640
+		 */
641
+		function addHeader($header) {
642
+			$this->_browser->addHeader($header);
643
+		}
644
+
645
+		/**
646
+		 *    Sets the maximum number of redirects before
647
+		 *    the web page is loaded regardless.
648
+		 *    @param integer $max        Maximum hops.
649
+		 *    @access public
650
+		 */
651
+		function setMaximumRedirects($max) {
652
+			if (! $this->_browser) {
653
+				trigger_error(
654
+						'Can only set maximum redirects in a test method, setUp() or tearDown()');
655
+			}
656
+			$this->_browser->setMaximumRedirects($max);
657
+		}
658
+
659
+		/**
660
+		 *    Sets the socket timeout for opening a connection and
661
+		 *    receiving at least one byte of information.
662
+		 *    @param integer $timeout      Maximum time in seconds.
663
+		 *    @access public
664
+		 */
665
+		function setConnectionTimeout($timeout) {
666
+			$this->_browser->setConnectionTimeout($timeout);
667
+		}
668
+
669
+		/**
670
+		 *    Sets proxy to use on all requests for when
671
+		 *    testing from behind a firewall. Set URL
672
+		 *    to false to disable.
673
+		 *    @param string $proxy        Proxy URL.
674
+		 *    @param string $username     Proxy username for authentication.
675
+		 *    @param string $password     Proxy password for authentication.
676
+		 *    @access public
677
+		 */
678
+		function useProxy($proxy, $username = false, $password = false) {
679
+			$this->_browser->useProxy($proxy, $username, $password);
680
+		}
681
+
682
+		/**
683
+		 *    Fetches a page into the page buffer. If
684
+		 *    there is no base for the URL then the
685
+		 *    current base URL is used. After the fetch
686
+		 *    the base URL reflects the new location.
687
+		 *    @param string $url          URL to fetch.
688
+		 *    @param hash $parameters     Optional additional GET data.
689
+		 *    @return boolean/string      Raw page on success.
690
+		 *    @access public
691
+		 */
692
+		function get($url, $parameters = false) {
693
+			return $this->_failOnError($this->_browser->get($url, $parameters));
694
+		}
695
+
696
+		/**
697
+		 *    Fetches a page by POST into the page buffer.
698
+		 *    If there is no base for the URL then the
699
+		 *    current base URL is used. After the fetch
700
+		 *    the base URL reflects the new location.
701
+		 *    @param string $url          URL to fetch.
702
+		 *    @param hash $parameters     Optional additional GET data.
703
+		 *    @return boolean/string      Raw page on success.
704
+		 *    @access public
705
+		 */
706
+		function post($url, $parameters = false) {
707
+			return $this->_failOnError($this->_browser->post($url, $parameters));
708
+		}
709
+
710
+		/**
711
+		 *    Does a HTTP HEAD fetch, fetching only the page
712
+		 *    headers. The current base URL is unchanged by this.
713
+		 *    @param string $url          URL to fetch.
714
+		 *    @param hash $parameters     Optional additional GET data.
715
+		 *    @return boolean             True on success.
716
+		 *    @access public
717
+		 */
718
+		function head($url, $parameters = false) {
719
+			return $this->_failOnError($this->_browser->head($url, $parameters));
720
+		}
721
+
722
+		/**
723
+		 *    Equivalent to hitting the retry button on the
724
+		 *    browser. Will attempt to repeat the page fetch.
725
+		 *    @return boolean     True if fetch succeeded.
726
+		 *    @access public
727
+		 */
728
+		function retry() {
729
+			return $this->_failOnError($this->_browser->retry());
730
+		}
731
+
732
+		/**
733
+		 *    Equivalent to hitting the back button on the
734
+		 *    browser.
735
+		 *    @return boolean     True if history entry and
736
+		 *                        fetch succeeded.
737
+		 *    @access public
738
+		 */
739
+		function back() {
740
+			return $this->_failOnError($this->_browser->back());
741
+		}
742
+
743
+		/**
744
+		 *    Equivalent to hitting the forward button on the
745
+		 *    browser.
746
+		 *    @return boolean     True if history entry and
747
+		 *                        fetch succeeded.
748
+		 *    @access public
749
+		 */
750
+		function forward() {
751
+			return $this->_failOnError($this->_browser->forward());
752
+		}
753
+
754
+		/**
755
+		 *    Retries a request after setting the authentication
756
+		 *    for the current realm.
757
+		 *    @param string $username    Username for realm.
758
+		 *    @param string $password    Password for realm.
759
+		 *    @return boolean/string     HTML on successful fetch. Note
760
+		 *                               that authentication may still have
761
+		 *                               failed.
762
+		 *    @access public
763
+		 */
764
+		function authenticate($username, $password) {
765
+			return $this->_failOnError(
766
+					$this->_browser->authenticate($username, $password));
767
+		}
768
+
769
+		/**
770
+		 *    Gets the cookie value for the current browser context.
771
+		 *    @param string $name          Name of cookie.
772
+		 *    @return string               Value of cookie or false if unset.
773
+		 *    @access public
774
+		 */
775
+		function getCookie($name) {
776
+			return $this->_browser->getCurrentCookieValue($name);
777
+		}
778
+
779
+		/**
780
+		 *    Sets a cookie in the current browser.
781
+		 *    @param string $name          Name of cookie.
782
+		 *    @param string $value         Cookie value.
783
+		 *    @param string $host          Host upon which the cookie is valid.
784
+		 *    @param string $path          Cookie path if not host wide.
785
+		 *    @param string $expiry        Expiry date.
786
+		 *    @access public
787
+		 */
788
+		function setCookie($name, $value, $host = false, $path = "/", $expiry = false) {
789
+			$this->_browser->setCookie($name, $value, $host, $path, $expiry);
790
+		}
791
+
792
+		/**
793
+		 *    Accessor for current frame focus. Will be
794
+		 *    false if no frame has focus.
795
+		 *    @return integer/string/boolean    Label if any, otherwise
796
+		 *                                      the position in the frameset
797
+		 *                                      or false if none.
798
+		 *    @access public
799
+		 */
800
+		function getFrameFocus() {
801
+			return $this->_browser->getFrameFocus();
802
+		}
803
+
804
+		/**
805
+		 *    Sets the focus by index. The integer index starts from 1.
806
+		 *    @param integer $choice    Chosen frame.
807
+		 *    @return boolean           True if frame exists.
808
+		 *    @access public
809
+		 */
810
+		function setFrameFocusByIndex($choice) {
811
+			return $this->_browser->setFrameFocusByIndex($choice);
812
+		}
813
+
814
+		/**
815
+		 *    Sets the focus by name.
816
+		 *    @param string $name    Chosen frame.
817
+		 *    @return boolean        True if frame exists.
818
+		 *    @access public
819
+		 */
820
+		function setFrameFocus($name) {
821
+			return $this->_browser->setFrameFocus($name);
822
+		}
823
+
824
+		/**
825
+		 *    Clears the frame focus. All frames will be searched
826
+		 *    for content.
827
+		 *    @access public
828
+		 */
829
+		function clearFrameFocus() {
830
+			return $this->_browser->clearFrameFocus();
831
+		}
832
+
833
+		/**
834
+		 *    Clicks a visible text item. Will first try buttons,
835
+		 *    then links and then images.
836
+		 *    @param string $label        Visible text or alt text.
837
+		 *    @return string/boolean      Raw page or false.
838
+		 *    @access public
839
+		 */
840
+		function click($label) {
841
+			return $this->_failOnError($this->_browser->click($label));
842
+		}
843
+
844
+		/**
845
+		 *    Clicks the submit button by label. The owning
846
+		 *    form will be submitted by this.
847
+		 *    @param string $label    Button label. An unlabeled
848
+		 *                            button can be triggered by 'Submit'.
849
+		 *    @param hash $additional Additional form values.
850
+		 *    @return boolean/string  Page on success, else false.
851
+		 *    @access public
852
+		 */
853
+		function clickSubmit($label = 'Submit', $additional = false) {
854
+			return $this->_failOnError(
855
+					$this->_browser->clickSubmit($label, $additional));
856
+		}
857
+
858
+		/**
859
+		 *    Clicks the submit button by name attribute. The owning
860
+		 *    form will be submitted by this.
861
+		 *    @param string $name     Name attribute of button.
862
+		 *    @param hash $additional Additional form values.
863
+		 *    @return boolean/string  Page on success.
864
+		 *    @access public
865
+		 */
866
+		function clickSubmitByName($name, $additional = false) {
867
+			return $this->_failOnError(
868
+					$this->_browser->clickSubmitByName($name, $additional));
869
+		}
870
+
871
+		/**
872
+		 *    Clicks the submit button by ID attribute. The owning
873
+		 *    form will be submitted by this.
874
+		 *    @param string $id       ID attribute of button.
875
+		 *    @param hash $additional Additional form values.
876
+		 *    @return boolean/string  Page on success.
877
+		 *    @access public
878
+		 */
879
+		function clickSubmitById($id, $additional = false) {
880
+			return $this->_failOnError(
881
+					$this->_browser->clickSubmitById($id, $additional));
882
+		}
883
+
884
+		/**
885
+		 *    Clicks the submit image by some kind of label. Usually
886
+		 *    the alt tag or the nearest equivalent. The owning
887
+		 *    form will be submitted by this. Clicking outside of
888
+		 *    the boundary of the coordinates will result in
889
+		 *    a failure.
890
+		 *    @param string $label    Alt attribute of button.
891
+		 *    @param integer $x       X-coordinate of imaginary click.
892
+		 *    @param integer $y       Y-coordinate of imaginary click.
893
+		 *    @param hash $additional Additional form values.
894
+		 *    @return boolean/string  Page on success.
895
+		 *    @access public
896
+		 */
897
+		function clickImage($label, $x = 1, $y = 1, $additional = false) {
898
+			return $this->_failOnError(
899
+					$this->_browser->clickImage($label, $x, $y, $additional));
900
+		}
901
+
902
+		/**
903
+		 *    Clicks the submit image by the name. Usually
904
+		 *    the alt tag or the nearest equivalent. The owning
905
+		 *    form will be submitted by this. Clicking outside of
906
+		 *    the boundary of the coordinates will result in
907
+		 *    a failure.
908
+		 *    @param string $name     Name attribute of button.
909
+		 *    @param integer $x       X-coordinate of imaginary click.
910
+		 *    @param integer $y       Y-coordinate of imaginary click.
911
+		 *    @param hash $additional Additional form values.
912
+		 *    @return boolean/string  Page on success.
913
+		 *    @access public
914
+		 */
915
+		function clickImageByName($name, $x = 1, $y = 1, $additional = false) {
916
+			return $this->_failOnError(
917
+					$this->_browser->clickImageByName($name, $x, $y, $additional));
918
+		}
919
+
920
+		/**
921
+		 *    Clicks the submit image by ID attribute. The owning
922
+		 *    form will be submitted by this. Clicking outside of
923
+		 *    the boundary of the coordinates will result in
924
+		 *    a failure.
925
+		 *    @param integer/string $id   ID attribute of button.
926
+		 *    @param integer $x           X-coordinate of imaginary click.
927
+		 *    @param integer $y           Y-coordinate of imaginary click.
928
+		 *    @param hash $additional     Additional form values.
929
+		 *    @return boolean/string      Page on success.
930
+		 *    @access public
931
+		 */
932
+		function clickImageById($id, $x = 1, $y = 1, $additional = false) {
933
+			return $this->_failOnError(
934
+					$this->_browser->clickImageById($id, $x, $y, $additional));
935
+		}
936
+
937
+		/**
938
+		 *    Submits a form by the ID.
939
+		 *    @param string $id       Form ID. No button information
940
+		 *                            is submitted this way.
941
+		 *    @return boolean/string  Page on success.
942
+		 *    @access public
943
+		 */
944
+		function submitFormById($id) {
945
+			return $this->_failOnError($this->_browser->submitFormById($id));
946
+		}
947
+
948
+		/**
949
+		 *    Follows a link by name. Will click the first link
950
+		 *    found with this link text by default, or a later
951
+		 *    one if an index is given. Match is case insensitive
952
+		 *    with normalised space.
953
+		 *    @param string $label     Text between the anchor tags.
954
+		 *    @param integer $index    Link position counting from zero.
955
+		 *    @return boolean/string   Page on success.
956
+		 *    @access public
957
+		 */
958
+		function clickLink($label, $index = 0) {
959
+			return $this->_failOnError($this->_browser->clickLink($label, $index));
960
+		}
961
+
962
+		/**
963
+		 *    Follows a link by id attribute.
964
+		 *    @param string $id        ID attribute value.
965
+		 *    @return boolean/string   Page on success.
966
+		 *    @access public
967
+		 */
968
+		function clickLinkById($id) {
969
+			return $this->_failOnError($this->_browser->clickLinkById($id));
970
+		}
971
+
972
+		/**
973
+		 *    Will trigger a pass if the two parameters have
974
+		 *    the same value only. Otherwise a fail. This
975
+		 *    is for testing hand extracted text, etc.
976
+		 *    @param mixed $first          Value to compare.
977
+		 *    @param mixed $second         Value to compare.
978
+		 *    @param string $message       Message to display.
979
+		 *    @return boolean              True on pass
980
+		 *    @access public
981
+		 */
982
+		function assertEqual($first, $second, $message = "%s") {
983
+			return $this->assert(
984
+					new EqualExpectation($first),
985
+					$second,
986
+					$message);
987
+		}
988
+
989
+		/**
990
+		 *    Will trigger a pass if the two parameters have
991
+		 *    a different value. Otherwise a fail. This
992
+		 *    is for testing hand extracted text, etc.
993
+		 *    @param mixed $first           Value to compare.
994
+		 *    @param mixed $second          Value to compare.
995
+		 *    @param string $message        Message to display.
996
+		 *    @return boolean               True on pass
997
+		 *    @access public
998
+		 */
999
+		function assertNotEqual($first, $second, $message = "%s") {
1000
+			return $this->assert(
1001
+					new NotEqualExpectation($first),
1002
+					$second,
1003
+					$message);
1004
+		}
1005
+
1006
+		/**
1007
+		 *    Tests for the presence of a link label. Match is
1008
+		 *    case insensitive with normalised space.
1009
+		 *    @param string $label     Text between the anchor tags.
1010
+		 *    @param string $message   Message to display. Default
1011
+		 *                             can be embedded with %s.
1012
+		 *    @return boolean          True if link present.
1013
+		 *    @access public
1014
+		 */
1015
+		function assertLink($label, $message = "%s") {
1016
+			return $this->assertTrue(
1017
+					$this->_browser->isLink($label),
1018
+					sprintf($message, "Link [$label] should exist"));
1019
+		}
1020
+
1021
+		/**
1022
+		 *    Tests for the non-presence of a link label. Match is
1023
+		 *    case insensitive with normalised space.
1024
+		 *    @param string/integer $label    Text between the anchor tags
1025
+		 *                                    or ID attribute.
1026
+		 *    @param string $message          Message to display. Default
1027
+		 *                                    can be embedded with %s.
1028
+		 *    @return boolean                 True if link missing.
1029
+		 *    @access public
1030
+		 */
1031
+		function assertNoLink($label, $message = "%s") {
1032
+			return $this->assertFalse(
1033
+					$this->_browser->isLink($label),
1034
+					sprintf($message, "Link [$label] should not exist"));
1035
+		}
1036
+
1037
+		/**
1038
+		 *    Tests for the presence of a link id attribute.
1039
+		 *    @param string $id        Id attribute value.
1040
+		 *    @param string $message   Message to display. Default
1041
+		 *                             can be embedded with %s.
1042
+		 *    @return boolean          True if link present.
1043
+		 *    @access public
1044
+		 */
1045
+		function assertLinkById($id, $message = "%s") {
1046
+			return $this->assertTrue(
1047
+					$this->_browser->isLinkById($id),
1048
+					sprintf($message, "Link ID [$id] should exist"));
1049
+		}
1050
+
1051
+		/**
1052
+		 *    Tests for the non-presence of a link label. Match is
1053
+		 *    case insensitive with normalised space.
1054
+		 *    @param string $id        Id attribute value.
1055
+		 *    @param string $message   Message to display. Default
1056
+		 *                             can be embedded with %s.
1057
+		 *    @return boolean          True if link missing.
1058
+		 *    @access public
1059
+		 */
1060
+		function assertNoLinkById($id, $message = "%s") {
1061
+			return $this->assertFalse(
1062
+					$this->_browser->isLinkById($id),
1063
+					sprintf($message, "Link ID [$id] should not exist"));
1064
+		}
1065
+
1066
+		/**
1067
+		 *    Sets all form fields with that label, or name if there
1068
+		 *    is no label attached.
1069
+		 *    @param string $name    Name of field in forms.
1070
+		 *    @param string $value   New value of field.
1071
+		 *    @return boolean        True if field exists, otherwise false.
1072
+		 *    @access public
1073
+		 */
1074
+		function setField($label, $value) {
1075
+			return $this->_browser->setField($label, $value);
1076
+		}
1077
+
1078
+		/**
1079
+		 *    Sets all form fields with that name.
1080
+		 *    @param string $name    Name of field in forms.
1081
+		 *    @param string $value   New value of field.
1082
+		 *    @return boolean        True if field exists, otherwise false.
1083
+		 *    @access public
1084
+		 */
1085
+		function setFieldByName($name, $value) {
1086
+			return $this->_browser->setFieldByName($name, $value);
1087
+		}
1088
+
1089
+		/**
1090
+		 *    Sets all form fields with that name.
1091
+		 *    @param string/integer $id   Id of field in forms.
1092
+		 *    @param string $value        New value of field.
1093
+		 *    @return boolean             True if field exists, otherwise false.
1094
+		 *    @access public
1095
+		 */
1096
+		function setFieldById($id, $value) {
1097
+			return $this->_browser->setFieldById($id, $value);
1098
+		}
1099
+
1100
+		/**
1101
+		 *    Confirms that the form element is currently set
1102
+		 *    to the expected value. A missing form will always
1103
+		 *    fail. If no value is given then only the existence
1104
+		 *    of the field is checked.
1105
+		 *    @param string $name       Name of field in forms.
1106
+		 *    @param mixed $expected    Expected string/array value or
1107
+		 *                              false for unset fields.
1108
+		 *    @param string $message    Message to display. Default
1109
+		 *                              can be embedded with %s.
1110
+		 *    @return boolean           True if pass.
1111
+		 *    @access public
1112
+		 */
1113
+		function assertField($label, $expected = true, $message = '%s') {
1114
+			$value = $this->_browser->getField($label);
1115
+			return $this->_assertFieldValue($label, $value, $expected, $message);
1116
+		}
1117
+
1118
+		/**
1119
+		 *    Confirms that the form element is currently set
1120
+		 *    to the expected value. A missing form element will always
1121
+		 *    fail. If no value is given then only the existence
1122
+		 *    of the field is checked.
1123
+		 *    @param string $name       Name of field in forms.
1124
+		 *    @param mixed $expected    Expected string/array value or
1125
+		 *                              false for unset fields.
1126
+		 *    @param string $message    Message to display. Default
1127
+		 *                              can be embedded with %s.
1128
+		 *    @return boolean           True if pass.
1129
+		 *    @access public
1130
+		 */
1131
+		function assertFieldByName($name, $expected = true, $message = '%s') {
1132
+			$value = $this->_browser->getFieldByName($name);
1133
+			return $this->_assertFieldValue($name, $value, $expected, $message);
1134
+		}
1135
+
1136
+		/**
1137
+		 *    Confirms that the form element is currently set
1138
+		 *    to the expected value. A missing form will always
1139
+		 *    fail. If no ID is given then only the existence
1140
+		 *    of the field is checked.
1141
+		 *    @param string/integer $id  Name of field in forms.
1142
+		 *    @param mixed $expected     Expected string/array value or
1143
+		 *                               false for unset fields.
1144
+		 *    @param string $message     Message to display. Default
1145
+		 *                               can be embedded with %s.
1146
+		 *    @return boolean            True if pass.
1147
+		 *    @access public
1148
+		 */
1149
+		function assertFieldById($id, $expected = true, $message = '%s') {
1150
+			$value = $this->_browser->getFieldById($id);
1151
+			return $this->_assertFieldValue($id, $value, $expected, $message);
1152
+		}
1153
+
1154
+		/**
1155
+		 *    Tests the field value against the expectation.
1156
+		 *    @param string $identifier      Name, ID or label.
1157
+		 *    @param mixed $value            Current field value.
1158
+		 *    @param mixed $expected         Expected value to match.
1159
+		 *    @param string $message         Failure message.
1160
+		 *    @return boolean                True if pass
1161
+		 *    @access protected
1162
+		 */
1163
+		function _assertFieldValue($identifier, $value, $expected, $message) {
1164
+			if ($expected === true) {
1165
+				return $this->assertTrue(
1166
+						isset($value),
1167
+						sprintf($message, "Field [$identifier] should exist"));
1168
+			}
1169
+			if (! SimpleExpectation::isExpectation($expected)) {
1170
+				$identifier = str_replace('%', '%%', $identifier);
1171
+				$expected = new FieldExpectation(
1172
+						$expected,
1173
+						"Field [$identifier] should match with [%s]");
1174
+			}
1175
+			return $this->assert($expected, $value, $message);
1176
+		}
1177
+
1178
+		/**
1179
+		 *    Checks the response code against a list
1180
+		 *    of possible values.
1181
+		 *    @param array $responses    Possible responses for a pass.
1182
+		 *    @param string $message     Message to display. Default
1183
+		 *                               can be embedded with %s.
1184
+		 *    @return boolean            True if pass.
1185
+		 *    @access public
1186
+		 */
1187
+		function assertResponse($responses, $message = '%s') {
1188
+			$responses = (is_array($responses) ? $responses : array($responses));
1189
+			$code = $this->_browser->getResponseCode();
1190
+			$message = sprintf($message, "Expecting response in [" .
1191
+					implode(", ", $responses) . "] got [$code]");
1192
+			return $this->assertTrue(in_array($code, $responses), $message);
1193
+		}
1194
+
1195
+		/**
1196
+		 *    Checks the mime type against a list
1197
+		 *    of possible values.
1198
+		 *    @param array $types      Possible mime types for a pass.
1199
+		 *    @param string $message   Message to display.
1200
+		 *    @return boolean          True if pass.
1201
+		 *    @access public
1202
+		 */
1203
+		function assertMime($types, $message = '%s') {
1204
+			$types = (is_array($types) ? $types : array($types));
1205
+			$type = $this->_browser->getMimeType();
1206
+			$message = sprintf($message, "Expecting mime type in [" .
1207
+					implode(", ", $types) . "] got [$type]");
1208
+			return $this->assertTrue(in_array($type, $types), $message);
1209
+		}
1210
+
1211
+		/**
1212
+		 *    Attempt to match the authentication type within
1213
+		 *    the security realm we are currently matching.
1214
+		 *    @param string $authentication   Usually basic.
1215
+		 *    @param string $message          Message to display.
1216
+		 *    @return boolean                 True if pass.
1217
+		 *    @access public
1218
+		 */
1219
+		function assertAuthentication($authentication = false, $message = '%s') {
1220
+			if (! $authentication) {
1221
+				$message = sprintf($message, "Expected any authentication type, got [" .
1222
+						$this->_browser->getAuthentication() . "]");
1223
+				return $this->assertTrue(
1224
+						$this->_browser->getAuthentication(),
1225
+						$message);
1226
+			} else {
1227
+				$message = sprintf($message, "Expected authentication [$authentication] got [" .
1228
+						$this->_browser->getAuthentication() . "]");
1229
+				return $this->assertTrue(
1230
+						strtolower($this->_browser->getAuthentication()) == strtolower($authentication),
1231
+						$message);
1232
+			}
1233
+		}
1234
+
1235
+		/**
1236
+		 *    Checks that no authentication is necessary to view
1237
+		 *    the desired page.
1238
+		 *    @param string $message     Message to display.
1239
+		 *    @return boolean            True if pass.
1240
+		 *    @access public
1241
+		 */
1242
+		function assertNoAuthentication($message = '%s') {
1243
+			$message = sprintf($message, "Expected no authentication type, got [" .
1244
+					$this->_browser->getAuthentication() . "]");
1245
+			return $this->assertFalse($this->_browser->getAuthentication(), $message);
1246
+		}
1247
+
1248
+		/**
1249
+		 *    Attempts to match the current security realm.
1250
+		 *    @param string $realm     Name of security realm.
1251
+		 *    @param string $message   Message to display.
1252
+		 *    @return boolean          True if pass.
1253
+		 *    @access public
1254
+		 */
1255
+		function assertRealm($realm, $message = '%s') {
1256
+			if (! SimpleExpectation::isExpectation($realm)) {
1257
+				$realm = new EqualExpectation($realm);
1258
+			}
1259
+			return $this->assert(
1260
+					$realm,
1261
+					$this->_browser->getRealm(),
1262
+					"Expected realm -> $message");
1263
+		}
1264
+
1265
+		/**
1266
+		 *    Checks each header line for the required value. If no
1267
+		 *    value is given then only an existence check is made.
1268
+		 *    @param string $header    Case insensitive header name.
1269
+		 *    @param mixed $value      Case sensitive trimmed string to
1270
+		 *                             match against. An expectation object
1271
+		 *                             can be used for pattern matching.
1272
+		 *    @return boolean          True if pass.
1273
+		 *    @access public
1274
+		 */
1275
+		function assertHeader($header, $value = false, $message = '%s') {
1276
+			return $this->assert(
1277
+					new HttpHeaderExpectation($header, $value),
1278
+					$this->_browser->getHeaders(),
1279
+					$message);
1280
+		}
1281
+
1282
+		/**
1283
+		 *    @deprecated
1284
+		 */
1285
+		function assertHeaderPattern($header, $pattern, $message = '%s') {
1286
+			return $this->assert(
1287
+					new HttpHeaderExpectation($header, new PatternExpectation($pattern)),
1288
+					$this->_browser->getHeaders(),
1289
+					$message);
1290
+		}
1291
+
1292
+		/**
1293
+		 *    Confirms that the header type has not been received.
1294
+		 *    Only the landing page is checked. If you want to check
1295
+		 *    redirect pages, then you should limit redirects so
1296
+		 *    as to capture the page you want.
1297
+		 *    @param string $header    Case insensitive header name.
1298
+		 *    @return boolean          True if pass.
1299
+		 *    @access public
1300
+		 */
1301
+		function assertNoHeader($header, $message = '%s') {
1302
+			return $this->assert(
1303
+					new NoHttpHeaderExpectation($header),
1304
+					$this->_browser->getHeaders(),
1305
+					$message);
1306
+		}
1307
+
1308
+		/**
1309
+		 *    @deprecated
1310
+		 */
1311
+		function assertNoUnwantedHeader($header, $message = '%s') {
1312
+			return $this->assertNoHeader($header, $message);
1313
+		}
1314
+
1315
+		/**
1316
+		 *    Tests the text between the title tags.
1317
+		 *    @param string $title      Expected title.
1318
+		 *    @param string $message    Message to display.
1319
+		 *    @return boolean           True if pass.
1320
+		 *    @access public
1321
+		 */
1322
+		function assertTitle($title = false, $message = '%s') {
1323
+			if (! SimpleExpectation::isExpectation($title)) {
1324
+				$title = new EqualExpectation($title);
1325
+			}
1326
+			return $this->assert($title, $this->_browser->getTitle(), $message);
1327
+		}
1328
+
1329
+		/**
1330
+		 *    Will trigger a pass if the text is found in the plain
1331
+		 *    text form of the page.
1332
+		 *    @param string $text       Text to look for.
1333
+		 *    @param string $message    Message to display.
1334
+		 *    @return boolean           True if pass.
1335
+		 *    @access public
1336
+		 */
1337
+		function assertText($text, $message = '%s') {
1338
+			return $this->assert(
1339
+					new TextExpectation($text),
1340
+					$this->_browser->getContentAsText(),
1341
+					$message);
1342
+		}
1343
+
1344
+		/**
1345
+		 *	  @deprecated
1346
+		 */
1347
+		function assertWantedText($text, $message = '%s') {
1348
+			return $this->assertText($text, $message);
1349
+		}
1350
+
1351
+		/**
1352
+		 *    Will trigger a pass if the text is not found in the plain
1353
+		 *    text form of the page.
1354
+		 *    @param string $text       Text to look for.
1355
+		 *    @param string $message    Message to display.
1356
+		 *    @return boolean           True if pass.
1357
+		 *    @access public
1358
+		 */
1359
+		function assertNoText($text, $message = '%s') {
1360
+			return $this->assert(
1361
+					new NoTextExpectation($text),
1362
+					$this->_browser->getContentAsText(),
1363
+					$message);
1364
+		}
1365
+
1366
+		/**
1367
+		 *	  @deprecated
1368
+		 */
1369
+		function assertNoUnwantedText($text, $message = '%s') {
1370
+			return $this->assertNoText($text, $message);
1371
+		}
1372
+
1373
+		/**
1374
+		 *    Will trigger a pass if the Perl regex pattern
1375
+		 *    is found in the raw content.
1376
+		 *    @param string $pattern    Perl regex to look for including
1377
+		 *                              the regex delimiters.
1378
+		 *    @param string $message    Message to display.
1379
+		 *    @return boolean           True if pass.
1380
+		 *    @access public
1381
+		 */
1382
+		function assertPattern($pattern, $message = '%s') {
1383
+			return $this->assert(
1384
+					new PatternExpectation($pattern),
1385
+					$this->_browser->getContent(),
1386
+					$message);
1387
+		}
1388
+
1389
+		/**
1390
+		 *	  @deprecated
1391
+		 */
1392
+		function assertWantedPattern($pattern, $message = '%s') {
1393
+			return $this->assertPattern($pattern, $message);
1394
+		}
1395
+
1396
+		/**
1397
+		 *    Will trigger a pass if the perl regex pattern
1398
+		 *    is not present in raw content.
1399
+		 *    @param string $pattern    Perl regex to look for including
1400
+		 *                              the regex delimiters.
1401
+		 *    @param string $message    Message to display.
1402
+		 *    @return boolean           True if pass.
1403
+		 *    @access public
1404
+		 */
1405
+		function assertNoPattern($pattern, $message = '%s') {
1406
+			return $this->assert(
1407
+					new NoPatternExpectation($pattern),
1408
+					$this->_browser->getContent(),
1409
+					$message);
1410
+		}
1411
+
1412
+		/**
1413
+		 *	  @deprecated
1414
+		 */
1415
+		function assertNoUnwantedPattern($pattern, $message = '%s') {
1416
+			return $this->assertNoPattern($pattern, $message);
1417
+		}
1418
+
1419
+		/**
1420
+		 *    Checks that a cookie is set for the current page
1421
+		 *    and optionally checks the value.
1422
+		 *    @param string $name        Name of cookie to test.
1423
+		 *    @param string $expected    Expected value as a string or
1424
+		 *                               false if any value will do.
1425
+		 *    @param string $message     Message to display.
1426
+		 *    @return boolean            True if pass.
1427
+		 *    @access public
1428
+		 */
1429
+		function assertCookie($name, $expected = false, $message = '%s') {
1430
+			$value = $this->getCookie($name);
1431
+			if (! $expected) {
1432
+				return $this->assertTrue(
1433
+						$value,
1434
+						sprintf($message, "Expecting cookie [$name]"));
1435
+			}
1436
+			if (! SimpleExpectation::isExpectation($expected)) {
1437
+				$expected = new EqualExpectation($expected);
1438
+			}
1439
+			return $this->assert($expected, $value, "Expecting cookie [$name] -> $message");
1440
+		}
1441
+
1442
+		/**
1443
+		 *    Checks that no cookie is present or that it has
1444
+		 *    been successfully cleared.
1445
+		 *    @param string $name        Name of cookie to test.
1446
+		 *    @param string $message     Message to display.
1447
+		 *    @return boolean            True if pass.
1448
+		 *    @access public
1449
+		 */
1450
+		function assertNoCookie($name, $message = '%s') {
1451
+			return $this->assertTrue(
1452
+					$this->getCookie($name) === false,
1453
+					sprintf($message, "Not expecting cookie [$name]"));
1454
+		}
1455
+	}
1456 1456
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
             if (is_array($compare) && count($compare) == 1) {
81 81
                 $compare = $compare[0];
82 82
             }
83
-            if (! $this->_isSingle($compare)) {
83
+            if (!$this->_isSingle($compare)) {
84 84
                 return false;
85 85
             }
86 86
             return ($this->_value == $compare);
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             if (is_string($compare)) {
97 97
                 $compare = array($compare);
98 98
             }
99
-            if (! is_array($compare)) {
99
+            if (!is_array($compare)) {
100 100
                 return false;
101 101
             }
102 102
             sort($compare);
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
          *    @access public
402 402
          */
403 403
         function test($compare) {
404
-            return ! parent::test($compare);
404
+            return !parent::test($compare);
405 405
         }
406 406
 
407 407
         /**
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
          *    @access private
623 623
          */
624 624
         function _failOnError($result) {
625
-            if (! $this->_ignore_errors) {
625
+            if (!$this->_ignore_errors) {
626 626
                 if ($error = $this->_browser->getTransportError()) {
627 627
                     $this->fail($error);
628 628
                 }
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
          *    @access public
649 649
          */
650 650
         function setMaximumRedirects($max) {
651
-            if (! $this->_browser) {
651
+            if (!$this->_browser) {
652 652
                 trigger_error(
653 653
                         'Can only set maximum redirects in a test method, setUp() or tearDown()');
654 654
             }
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
                         isset($value),
1166 1166
                         sprintf($message, "Field [$identifier] should exist"));
1167 1167
             }
1168
-            if (! SimpleExpectation::isExpectation($expected)) {
1168
+            if (!SimpleExpectation::isExpectation($expected)) {
1169 1169
                 $identifier = str_replace('%', '%%', $identifier);
1170 1170
                 $expected = new FieldExpectation(
1171 1171
                         $expected,
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
          *    @access public
1217 1217
          */
1218 1218
         function assertAuthentication($authentication = false, $message = '%s') {
1219
-            if (! $authentication) {
1219
+            if (!$authentication) {
1220 1220
                 $message = sprintf($message, "Expected any authentication type, got [" .
1221 1221
                         $this->_browser->getAuthentication() . "]");
1222 1222
                 return $this->assertTrue(
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
          *    @access public
1253 1253
          */
1254 1254
         function assertRealm($realm, $message = '%s') {
1255
-            if (! SimpleExpectation::isExpectation($realm)) {
1255
+            if (!SimpleExpectation::isExpectation($realm)) {
1256 1256
                 $realm = new EqualExpectation($realm);
1257 1257
             }
1258 1258
             return $this->assert(
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
          *    @access public
1320 1320
          */
1321 1321
         function assertTitle($title = false, $message = '%s') {
1322
-            if (! SimpleExpectation::isExpectation($title)) {
1322
+            if (!SimpleExpectation::isExpectation($title)) {
1323 1323
                 $title = new EqualExpectation($title);
1324 1324
             }
1325 1325
             return $this->assert($title, $this->_browser->getTitle(), $message);
@@ -1427,12 +1427,12 @@  discard block
 block discarded – undo
1427 1427
          */
1428 1428
         function assertCookie($name, $expected = false, $message = '%s') {
1429 1429
             $value = $this->getCookie($name);
1430
-            if (! $expected) {
1430
+            if (!$expected) {
1431 1431
                 return $this->assertTrue(
1432 1432
                         $value,
1433 1433
                         sprintf($message, "Expecting cookie [$name]"));
1434 1434
             }
1435
-            if (! SimpleExpectation::isExpectation($expected)) {
1435
+            if (!SimpleExpectation::isExpectation($expected)) {
1436 1436
                 $expected = new EqualExpectation($expected);
1437 1437
             }
1438 1438
             return $this->assert($expected, $value, "Expecting cookie [$name] -> $message");
Please login to merge, or discard this patch.
tests/test_tools/simpletest/xml.php 3 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -130,8 +130,6 @@
 block discarded – undo
130 130
         /**
131 131
          *    Paints the end of a test method.
132 132
          *    @param string $test_name   Name of test that is ending.
133
-         *    @param integer $progress   Number of test cases ending.
134
-         *    @access public
135 133
          */
136 134
         function paintMethodEnd($test_name) {
137 135
             print $this->_getIndent();
Please login to merge, or discard this patch.
Indentation   +597 added lines, -597 removed lines patch added patch discarded remove patch
@@ -1,613 +1,613 @@
 block discarded – undo
1 1
 <?php
2
-    /**
3
-     *	base include file for SimpleTest
4
-     *	@package	SimpleTest
5
-     *	@subpackage	UnitTester
6
-     *	@version	$Id: xml.php 1398 2006-09-08 19:31:03Z xue $
7
-     */
8
-
9
-    /**#@+
2
+	/**
3
+	 *	base include file for SimpleTest
4
+	 *	@package	SimpleTest
5
+	 *	@subpackage	UnitTester
6
+	 *	@version	$Id: xml.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__) . '/scorer.php');
13
-    /**#@-*/
12
+	require_once(dirname(__FILE__) . '/scorer.php');
13
+	/**#@-*/
14 14
 
15
-    /**
16
-     *    Creates the XML needed for remote communication
17
-     *    by SimpleTest.
15
+	/**
16
+	 *    Creates the XML needed for remote communication
17
+	 *    by SimpleTest.
18 18
 	 *	  @package SimpleTest
19 19
 	 *	  @subpackage UnitTester
20
-     */
21
-    class XmlReporter extends SimpleReporter {
22
-        protected $_indent;
23
-        protected $_namespace;
24
-
25
-        /**
26
-         *    Does nothing yet.
27
-         *    @access public
28
-         */
29
-        function XmlReporter($namespace = false, $indent = '  ') {
30
-            $this->SimpleReporter();
31
-            $this->_namespace = ($namespace ? $namespace . ':' : '');
32
-            $this->_indent = $indent;
33
-        }
34
-
35
-        /**
36
-         *    Calculates the pretty printing indent level
37
-         *    from the current level of nesting.
38
-         *    @param integer $offset  Extra indenting level.
39
-         *    @return string          Leading space.
40
-         *    @access protected
41
-         */
42
-        function _getIndent($offset = 0) {
43
-            return str_repeat(
44
-                    $this->_indent,
45
-                    count($this->getTestList()) + $offset);
46
-        }
47
-
48
-        /**
49
-         *    Converts character string to parsed XML
50
-         *    entities string.
51
-         *    @param string text        Unparsed character data.
52
-         *    @return string            Parsed character data.
53
-         *    @access public
54
-         */
55
-        function toParsedXml($text) {
56
-            return str_replace(
57
-                    array('&', '<', '>', '"', '\''),
58
-                    array('&amp;', '&lt;', '&gt;', '&quot;', '&apos;'),
59
-                    $text);
60
-        }
61
-
62
-        /**
63
-         *    Paints the start of a group test.
64
-         *    @param string $test_name   Name of test that is starting.
65
-         *    @param integer $size       Number of test cases starting.
66
-         *    @access public
67
-         */
68
-        function paintGroupStart($test_name, $size) {
69
-            parent::paintGroupStart($test_name, $size);
70
-            print $this->_getIndent();
71
-            print "<" . $this->_namespace . "group size=\"$size\">\n";
72
-            print $this->_getIndent(1);
73
-            print "<" . $this->_namespace . "name>" .
74
-                    $this->toParsedXml($test_name) .
75
-                    "</" . $this->_namespace . "name>\n";
76
-        }
77
-
78
-        /**
79
-         *    Paints the end of a group test.
80
-         *    @param string $test_name   Name of test that is ending.
81
-         *    @access public
82
-         */
83
-        function paintGroupEnd($test_name) {
84
-            print $this->_getIndent();
85
-            print "</" . $this->_namespace . "group>\n";
86
-            parent::paintGroupEnd($test_name);
87
-        }
88
-
89
-        /**
90
-         *    Paints the start of a test case.
91
-         *    @param string $test_name   Name of test that is starting.
92
-         *    @access public
93
-         */
94
-        function paintCaseStart($test_name) {
95
-            parent::paintCaseStart($test_name);
96
-            print $this->_getIndent();
97
-            print "<" . $this->_namespace . "case>\n";
98
-            print $this->_getIndent(1);
99
-            print "<" . $this->_namespace . "name>" .
100
-                    $this->toParsedXml($test_name) .
101
-                    "</" . $this->_namespace . "name>\n";
102
-        }
103
-
104
-        /**
105
-         *    Paints the end of a test case.
106
-         *    @param string $test_name   Name of test that is ending.
107
-         *    @access public
108
-         */
109
-        function paintCaseEnd($test_name) {
110
-            print $this->_getIndent();
111
-            print "</" . $this->_namespace . "case>\n";
112
-            parent::paintCaseEnd($test_name);
113
-        }
114
-
115
-        /**
116
-         *    Paints the start of a test method.
117
-         *    @param string $test_name   Name of test that is starting.
118
-         *    @access public
119
-         */
120
-        function paintMethodStart($test_name) {
121
-            parent::paintMethodStart($test_name);
122
-            print $this->_getIndent();
123
-            print "<" . $this->_namespace . "test>\n";
124
-            print $this->_getIndent(1);
125
-            print "<" . $this->_namespace . "name>" .
126
-                    $this->toParsedXml($test_name) .
127
-                    "</" . $this->_namespace . "name>\n";
128
-        }
129
-
130
-        /**
131
-         *    Paints the end of a test method.
132
-         *    @param string $test_name   Name of test that is ending.
133
-         *    @param integer $progress   Number of test cases ending.
134
-         *    @access public
135
-         */
136
-        function paintMethodEnd($test_name) {
137
-            print $this->_getIndent();
138
-            print "</" . $this->_namespace . "test>\n";
139
-            parent::paintMethodEnd($test_name);
140
-        }
141
-
142
-        /**
143
-         *    Increments the pass count.
144
-         *    @param string $message        Message is ignored.
145
-         *    @access public
146
-         */
147
-        function paintPass($message) {
148
-            parent::paintPass($message);
149
-            print $this->_getIndent(1);
150
-            print "<" . $this->_namespace . "pass>";
151
-            print $this->toParsedXml($message);
152
-            print "</" . $this->_namespace . "pass>\n";
153
-        }
154
-
155
-        /**
156
-         *    Increments the fail count.
157
-         *    @param string $message        Message is ignored.
158
-         *    @access public
159
-         */
160
-        function paintFail($message) {
161
-            parent::paintFail($message);
162
-            print $this->_getIndent(1);
163
-            print "<" . $this->_namespace . "fail>";
164
-            print $this->toParsedXml($message);
165
-            print "</" . $this->_namespace . "fail>\n";
166
-        }
167
-
168
-        /**
169
-         *    Paints a PHP error or exception.
170
-         *    @param string $message        Message is ignored.
171
-         *    @access public
172
-         *    @abstract
173
-         */
174
-        function paintError($message) {
175
-            parent::paintError($message);
176
-            print $this->_getIndent(1);
177
-            print "<" . $this->_namespace . "exception>";
178
-            print $this->toParsedXml($message);
179
-            print "</" . $this->_namespace . "exception>\n";
180
-        }
181
-
182
-        /**
183
-         *    Paints a simple supplementary message.
184
-         *    @param string $message        Text to display.
185
-         *    @access public
186
-         */
187
-        function paintMessage($message) {
188
-            parent::paintMessage($message);
189
-            print $this->_getIndent(1);
190
-            print "<" . $this->_namespace . "message>";
191
-            print $this->toParsedXml($message);
192
-            print "</" . $this->_namespace . "message>\n";
193
-        }
194
-
195
-        /**
196
-         *    Paints a formatted ASCII message such as a
197
-         *    variable dump.
198
-         *    @param string $message        Text to display.
199
-         *    @access public
200
-         */
201
-        function paintFormattedMessage($message) {
202
-            parent::paintFormattedMessage($message);
203
-            print $this->_getIndent(1);
204
-            print "<" . $this->_namespace . "formatted>";
205
-            print "<![CDATA[$message]]>";
206
-            print "</" . $this->_namespace . "formatted>\n";
207
-        }
208
-
209
-        /**
210
-         *    Serialises the event object.
211
-         *    @param string $type        Event type as text.
212
-         *    @param mixed $payload      Message or object.
213
-         *    @access public
214
-         */
215
-        function paintSignal($type, $payload) {
216
-            parent::paintSignal($type, $payload);
217
-            print $this->_getIndent(1);
218
-            print "<" . $this->_namespace . "signal type=\"$type\">";
219
-            print "<![CDATA[" . serialize($payload) . "]]>";
220
-            print "</" . $this->_namespace . "signal>\n";
221
-        }
222
-
223
-        /**
224
-         *    Paints the test document header.
225
-         *    @param string $test_name     First test top level
226
-         *                                 to start.
227
-         *    @access public
228
-         *    @abstract
229
-         */
230
-        function paintHeader($test_name) {
231
-            if (! SimpleReporter::inCli()) {
232
-                header('Content-type: text/xml');
233
-            }
234
-            print "<?xml version=\"1.0\"";
235
-            if ($this->_namespace) {
236
-                print " xmlns:" . $this->_namespace .
237
-                        "=\"www.lastcraft.com/SimpleTest/Beta3/Report\"";
238
-            }
239
-            print "?>\n";
240
-            print "<" . $this->_namespace . "run>\n";
241
-        }
242
-
243
-        /**
244
-         *    Paints the test document footer.
245
-         *    @param string $test_name        The top level test.
246
-         *    @access public
247
-         *    @abstract
248
-         */
249
-        function paintFooter($test_name) {
250
-            print "</" . $this->_namespace . "run>\n";
251
-        }
252
-    }
253
-
254
-    /**
255
-     *    Accumulator for incoming tag. Holds the
256
-     *    incoming test structure information for
257
-     *    later dispatch to the reporter.
20
+	 */
21
+	class XmlReporter extends SimpleReporter {
22
+		protected $_indent;
23
+		protected $_namespace;
24
+
25
+		/**
26
+		 *    Does nothing yet.
27
+		 *    @access public
28
+		 */
29
+		function XmlReporter($namespace = false, $indent = '  ') {
30
+			$this->SimpleReporter();
31
+			$this->_namespace = ($namespace ? $namespace . ':' : '');
32
+			$this->_indent = $indent;
33
+		}
34
+
35
+		/**
36
+		 *    Calculates the pretty printing indent level
37
+		 *    from the current level of nesting.
38
+		 *    @param integer $offset  Extra indenting level.
39
+		 *    @return string          Leading space.
40
+		 *    @access protected
41
+		 */
42
+		function _getIndent($offset = 0) {
43
+			return str_repeat(
44
+					$this->_indent,
45
+					count($this->getTestList()) + $offset);
46
+		}
47
+
48
+		/**
49
+		 *    Converts character string to parsed XML
50
+		 *    entities string.
51
+		 *    @param string text        Unparsed character data.
52
+		 *    @return string            Parsed character data.
53
+		 *    @access public
54
+		 */
55
+		function toParsedXml($text) {
56
+			return str_replace(
57
+					array('&', '<', '>', '"', '\''),
58
+					array('&amp;', '&lt;', '&gt;', '&quot;', '&apos;'),
59
+					$text);
60
+		}
61
+
62
+		/**
63
+		 *    Paints the start of a group test.
64
+		 *    @param string $test_name   Name of test that is starting.
65
+		 *    @param integer $size       Number of test cases starting.
66
+		 *    @access public
67
+		 */
68
+		function paintGroupStart($test_name, $size) {
69
+			parent::paintGroupStart($test_name, $size);
70
+			print $this->_getIndent();
71
+			print "<" . $this->_namespace . "group size=\"$size\">\n";
72
+			print $this->_getIndent(1);
73
+			print "<" . $this->_namespace . "name>" .
74
+					$this->toParsedXml($test_name) .
75
+					"</" . $this->_namespace . "name>\n";
76
+		}
77
+
78
+		/**
79
+		 *    Paints the end of a group test.
80
+		 *    @param string $test_name   Name of test that is ending.
81
+		 *    @access public
82
+		 */
83
+		function paintGroupEnd($test_name) {
84
+			print $this->_getIndent();
85
+			print "</" . $this->_namespace . "group>\n";
86
+			parent::paintGroupEnd($test_name);
87
+		}
88
+
89
+		/**
90
+		 *    Paints the start of a test case.
91
+		 *    @param string $test_name   Name of test that is starting.
92
+		 *    @access public
93
+		 */
94
+		function paintCaseStart($test_name) {
95
+			parent::paintCaseStart($test_name);
96
+			print $this->_getIndent();
97
+			print "<" . $this->_namespace . "case>\n";
98
+			print $this->_getIndent(1);
99
+			print "<" . $this->_namespace . "name>" .
100
+					$this->toParsedXml($test_name) .
101
+					"</" . $this->_namespace . "name>\n";
102
+		}
103
+
104
+		/**
105
+		 *    Paints the end of a test case.
106
+		 *    @param string $test_name   Name of test that is ending.
107
+		 *    @access public
108
+		 */
109
+		function paintCaseEnd($test_name) {
110
+			print $this->_getIndent();
111
+			print "</" . $this->_namespace . "case>\n";
112
+			parent::paintCaseEnd($test_name);
113
+		}
114
+
115
+		/**
116
+		 *    Paints the start of a test method.
117
+		 *    @param string $test_name   Name of test that is starting.
118
+		 *    @access public
119
+		 */
120
+		function paintMethodStart($test_name) {
121
+			parent::paintMethodStart($test_name);
122
+			print $this->_getIndent();
123
+			print "<" . $this->_namespace . "test>\n";
124
+			print $this->_getIndent(1);
125
+			print "<" . $this->_namespace . "name>" .
126
+					$this->toParsedXml($test_name) .
127
+					"</" . $this->_namespace . "name>\n";
128
+		}
129
+
130
+		/**
131
+		 *    Paints the end of a test method.
132
+		 *    @param string $test_name   Name of test that is ending.
133
+		 *    @param integer $progress   Number of test cases ending.
134
+		 *    @access public
135
+		 */
136
+		function paintMethodEnd($test_name) {
137
+			print $this->_getIndent();
138
+			print "</" . $this->_namespace . "test>\n";
139
+			parent::paintMethodEnd($test_name);
140
+		}
141
+
142
+		/**
143
+		 *    Increments the pass count.
144
+		 *    @param string $message        Message is ignored.
145
+		 *    @access public
146
+		 */
147
+		function paintPass($message) {
148
+			parent::paintPass($message);
149
+			print $this->_getIndent(1);
150
+			print "<" . $this->_namespace . "pass>";
151
+			print $this->toParsedXml($message);
152
+			print "</" . $this->_namespace . "pass>\n";
153
+		}
154
+
155
+		/**
156
+		 *    Increments the fail count.
157
+		 *    @param string $message        Message is ignored.
158
+		 *    @access public
159
+		 */
160
+		function paintFail($message) {
161
+			parent::paintFail($message);
162
+			print $this->_getIndent(1);
163
+			print "<" . $this->_namespace . "fail>";
164
+			print $this->toParsedXml($message);
165
+			print "</" . $this->_namespace . "fail>\n";
166
+		}
167
+
168
+		/**
169
+		 *    Paints a PHP error or exception.
170
+		 *    @param string $message        Message is ignored.
171
+		 *    @access public
172
+		 *    @abstract
173
+		 */
174
+		function paintError($message) {
175
+			parent::paintError($message);
176
+			print $this->_getIndent(1);
177
+			print "<" . $this->_namespace . "exception>";
178
+			print $this->toParsedXml($message);
179
+			print "</" . $this->_namespace . "exception>\n";
180
+		}
181
+
182
+		/**
183
+		 *    Paints a simple supplementary message.
184
+		 *    @param string $message        Text to display.
185
+		 *    @access public
186
+		 */
187
+		function paintMessage($message) {
188
+			parent::paintMessage($message);
189
+			print $this->_getIndent(1);
190
+			print "<" . $this->_namespace . "message>";
191
+			print $this->toParsedXml($message);
192
+			print "</" . $this->_namespace . "message>\n";
193
+		}
194
+
195
+		/**
196
+		 *    Paints a formatted ASCII message such as a
197
+		 *    variable dump.
198
+		 *    @param string $message        Text to display.
199
+		 *    @access public
200
+		 */
201
+		function paintFormattedMessage($message) {
202
+			parent::paintFormattedMessage($message);
203
+			print $this->_getIndent(1);
204
+			print "<" . $this->_namespace . "formatted>";
205
+			print "<![CDATA[$message]]>";
206
+			print "</" . $this->_namespace . "formatted>\n";
207
+		}
208
+
209
+		/**
210
+		 *    Serialises the event object.
211
+		 *    @param string $type        Event type as text.
212
+		 *    @param mixed $payload      Message or object.
213
+		 *    @access public
214
+		 */
215
+		function paintSignal($type, $payload) {
216
+			parent::paintSignal($type, $payload);
217
+			print $this->_getIndent(1);
218
+			print "<" . $this->_namespace . "signal type=\"$type\">";
219
+			print "<![CDATA[" . serialize($payload) . "]]>";
220
+			print "</" . $this->_namespace . "signal>\n";
221
+		}
222
+
223
+		/**
224
+		 *    Paints the test document header.
225
+		 *    @param string $test_name     First test top level
226
+		 *                                 to start.
227
+		 *    @access public
228
+		 *    @abstract
229
+		 */
230
+		function paintHeader($test_name) {
231
+			if (! SimpleReporter::inCli()) {
232
+				header('Content-type: text/xml');
233
+			}
234
+			print "<?xml version=\"1.0\"";
235
+			if ($this->_namespace) {
236
+				print " xmlns:" . $this->_namespace .
237
+						"=\"www.lastcraft.com/SimpleTest/Beta3/Report\"";
238
+			}
239
+			print "?>\n";
240
+			print "<" . $this->_namespace . "run>\n";
241
+		}
242
+
243
+		/**
244
+		 *    Paints the test document footer.
245
+		 *    @param string $test_name        The top level test.
246
+		 *    @access public
247
+		 *    @abstract
248
+		 */
249
+		function paintFooter($test_name) {
250
+			print "</" . $this->_namespace . "run>\n";
251
+		}
252
+	}
253
+
254
+	/**
255
+	 *    Accumulator for incoming tag. Holds the
256
+	 *    incoming test structure information for
257
+	 *    later dispatch to the reporter.
258 258
 	 *	  @package SimpleTest
259 259
 	 *	  @subpackage UnitTester
260
-     */
261
-    class NestingXmlTag {
262
-        protected $_name;
263
-        protected $_attributes;
264
-
265
-        /**
266
-         *    Sets the basic test information except
267
-         *    the name.
268
-         *    @param hash $attributes   Name value pairs.
269
-         *    @access public
270
-         */
271
-        function NestingXmlTag($attributes) {
272
-            $this->_name = false;
273
-            $this->_attributes = $attributes;
274
-        }
275
-
276
-        /**
277
-         *    Sets the test case/method name.
278
-         *    @param string $name        Name of test.
279
-         *    @access public
280
-         */
281
-        function setName($name) {
282
-            $this->_name = $name;
283
-        }
284
-
285
-        /**
286
-         *    Accessor for name.
287
-         *    @return string        Name of test.
288
-         *    @access public
289
-         */
290
-        function getName() {
291
-            return $this->_name;
292
-        }
293
-
294
-        /**
295
-         *    Accessor for attributes.
296
-         *    @return hash        All attributes.
297
-         *    @access protected
298
-         */
299
-        function _getAttributes() {
300
-            return $this->_attributes;
301
-        }
302
-    }
303
-
304
-    /**
305
-     *    Accumulator for incoming method tag. Holds the
306
-     *    incoming test structure information for
307
-     *    later dispatch to the reporter.
260
+	 */
261
+	class NestingXmlTag {
262
+		protected $_name;
263
+		protected $_attributes;
264
+
265
+		/**
266
+		 *    Sets the basic test information except
267
+		 *    the name.
268
+		 *    @param hash $attributes   Name value pairs.
269
+		 *    @access public
270
+		 */
271
+		function NestingXmlTag($attributes) {
272
+			$this->_name = false;
273
+			$this->_attributes = $attributes;
274
+		}
275
+
276
+		/**
277
+		 *    Sets the test case/method name.
278
+		 *    @param string $name        Name of test.
279
+		 *    @access public
280
+		 */
281
+		function setName($name) {
282
+			$this->_name = $name;
283
+		}
284
+
285
+		/**
286
+		 *    Accessor for name.
287
+		 *    @return string        Name of test.
288
+		 *    @access public
289
+		 */
290
+		function getName() {
291
+			return $this->_name;
292
+		}
293
+
294
+		/**
295
+		 *    Accessor for attributes.
296
+		 *    @return hash        All attributes.
297
+		 *    @access protected
298
+		 */
299
+		function _getAttributes() {
300
+			return $this->_attributes;
301
+		}
302
+	}
303
+
304
+	/**
305
+	 *    Accumulator for incoming method tag. Holds the
306
+	 *    incoming test structure information for
307
+	 *    later dispatch to the reporter.
308 308
 	 *	  @package SimpleTest
309 309
 	 *	  @subpackage UnitTester
310
-     */
311
-    class NestingMethodTag extends NestingXmlTag {
312
-
313
-        /**
314
-         *    Sets the basic test information except
315
-         *    the name.
316
-         *    @param hash $attributes   Name value pairs.
317
-         *    @access public
318
-         */
319
-        function NestingMethodTag($attributes) {
320
-            $this->NestingXmlTag($attributes);
321
-        }
322
-
323
-        /**
324
-         *    Signals the appropriate start event on the
325
-         *    listener.
326
-         *    @param SimpleReporter $listener    Target for events.
327
-         *    @access public
328
-         */
329
-        function paintStart($listener) {
330
-            $listener->paintMethodStart($this->getName());
331
-        }
332
-
333
-        /**
334
-         *    Signals the appropriate end event on the
335
-         *    listener.
336
-         *    @param SimpleReporter $listener    Target for events.
337
-         *    @access public
338
-         */
339
-        function paintEnd($listener) {
340
-            $listener->paintMethodEnd($this->getName());
341
-        }
342
-    }
343
-
344
-    /**
345
-     *    Accumulator for incoming case tag. Holds the
346
-     *    incoming test structure information for
347
-     *    later dispatch to the reporter.
310
+	 */
311
+	class NestingMethodTag extends NestingXmlTag {
312
+
313
+		/**
314
+		 *    Sets the basic test information except
315
+		 *    the name.
316
+		 *    @param hash $attributes   Name value pairs.
317
+		 *    @access public
318
+		 */
319
+		function NestingMethodTag($attributes) {
320
+			$this->NestingXmlTag($attributes);
321
+		}
322
+
323
+		/**
324
+		 *    Signals the appropriate start event on the
325
+		 *    listener.
326
+		 *    @param SimpleReporter $listener    Target for events.
327
+		 *    @access public
328
+		 */
329
+		function paintStart($listener) {
330
+			$listener->paintMethodStart($this->getName());
331
+		}
332
+
333
+		/**
334
+		 *    Signals the appropriate end event on the
335
+		 *    listener.
336
+		 *    @param SimpleReporter $listener    Target for events.
337
+		 *    @access public
338
+		 */
339
+		function paintEnd($listener) {
340
+			$listener->paintMethodEnd($this->getName());
341
+		}
342
+	}
343
+
344
+	/**
345
+	 *    Accumulator for incoming case tag. Holds the
346
+	 *    incoming test structure information for
347
+	 *    later dispatch to the reporter.
348 348
 	 *	  @package SimpleTest
349 349
 	 *	  @subpackage UnitTester
350
-     */
351
-    class NestingCaseTag extends NestingXmlTag {
352
-
353
-        /**
354
-         *    Sets the basic test information except
355
-         *    the name.
356
-         *    @param hash $attributes   Name value pairs.
357
-         *    @access public
358
-         */
359
-        function NestingCaseTag($attributes) {
360
-            $this->NestingXmlTag($attributes);
361
-        }
362
-
363
-        /**
364
-         *    Signals the appropriate start event on the
365
-         *    listener.
366
-         *    @param SimpleReporter $listener    Target for events.
367
-         *    @access public
368
-         */
369
-        function paintStart($listener) {
370
-            $listener->paintCaseStart($this->getName());
371
-        }
372
-
373
-        /**
374
-         *    Signals the appropriate end event on the
375
-         *    listener.
376
-         *    @param SimpleReporter $listener    Target for events.
377
-         *    @access public
378
-         */
379
-        function paintEnd($listener) {
380
-            $listener->paintCaseEnd($this->getName());
381
-        }
382
-    }
383
-
384
-    /**
385
-     *    Accumulator for incoming group tag. Holds the
386
-     *    incoming test structure information for
387
-     *    later dispatch to the reporter.
350
+	 */
351
+	class NestingCaseTag extends NestingXmlTag {
352
+
353
+		/**
354
+		 *    Sets the basic test information except
355
+		 *    the name.
356
+		 *    @param hash $attributes   Name value pairs.
357
+		 *    @access public
358
+		 */
359
+		function NestingCaseTag($attributes) {
360
+			$this->NestingXmlTag($attributes);
361
+		}
362
+
363
+		/**
364
+		 *    Signals the appropriate start event on the
365
+		 *    listener.
366
+		 *    @param SimpleReporter $listener    Target for events.
367
+		 *    @access public
368
+		 */
369
+		function paintStart($listener) {
370
+			$listener->paintCaseStart($this->getName());
371
+		}
372
+
373
+		/**
374
+		 *    Signals the appropriate end event on the
375
+		 *    listener.
376
+		 *    @param SimpleReporter $listener    Target for events.
377
+		 *    @access public
378
+		 */
379
+		function paintEnd($listener) {
380
+			$listener->paintCaseEnd($this->getName());
381
+		}
382
+	}
383
+
384
+	/**
385
+	 *    Accumulator for incoming group tag. Holds the
386
+	 *    incoming test structure information for
387
+	 *    later dispatch to the reporter.
388 388
 	 *	  @package SimpleTest
389 389
 	 *	  @subpackage UnitTester
390
-     */
391
-    class NestingGroupTag extends NestingXmlTag {
392
-
393
-        /**
394
-         *    Sets the basic test information except
395
-         *    the name.
396
-         *    @param hash $attributes   Name value pairs.
397
-         *    @access public
398
-         */
399
-        function NestingGroupTag($attributes) {
400
-            $this->NestingXmlTag($attributes);
401
-        }
402
-
403
-        /**
404
-         *    Signals the appropriate start event on the
405
-         *    listener.
406
-         *    @param SimpleReporter $listener    Target for events.
407
-         *    @access public
408
-         */
409
-        function paintStart($listener) {
410
-            $listener->paintGroupStart($this->getName(), $this->getSize());
411
-        }
412
-
413
-        /**
414
-         *    Signals the appropriate end event on the
415
-         *    listener.
416
-         *    @param SimpleReporter $listener    Target for events.
417
-         *    @access public
418
-         */
419
-        function paintEnd($listener) {
420
-            $listener->paintGroupEnd($this->getName());
421
-        }
422
-
423
-        /**
424
-         *    The size in the attributes.
425
-         *    @return integer     Value of size attribute or zero.
426
-         *    @access public
427
-         */
428
-        function getSize() {
429
-            $attributes = $this->_getAttributes();
430
-            if (isset($attributes['SIZE'])) {
431
-                return (integer)$attributes['SIZE'];
432
-            }
433
-            return 0;
434
-        }
435
-    }
436
-
437
-    /**
438
-     *    Parser for importing the output of the XmlReporter.
439
-     *    Dispatches that output to another reporter.
390
+	 */
391
+	class NestingGroupTag extends NestingXmlTag {
392
+
393
+		/**
394
+		 *    Sets the basic test information except
395
+		 *    the name.
396
+		 *    @param hash $attributes   Name value pairs.
397
+		 *    @access public
398
+		 */
399
+		function NestingGroupTag($attributes) {
400
+			$this->NestingXmlTag($attributes);
401
+		}
402
+
403
+		/**
404
+		 *    Signals the appropriate start event on the
405
+		 *    listener.
406
+		 *    @param SimpleReporter $listener    Target for events.
407
+		 *    @access public
408
+		 */
409
+		function paintStart($listener) {
410
+			$listener->paintGroupStart($this->getName(), $this->getSize());
411
+		}
412
+
413
+		/**
414
+		 *    Signals the appropriate end event on the
415
+		 *    listener.
416
+		 *    @param SimpleReporter $listener    Target for events.
417
+		 *    @access public
418
+		 */
419
+		function paintEnd($listener) {
420
+			$listener->paintGroupEnd($this->getName());
421
+		}
422
+
423
+		/**
424
+		 *    The size in the attributes.
425
+		 *    @return integer     Value of size attribute or zero.
426
+		 *    @access public
427
+		 */
428
+		function getSize() {
429
+			$attributes = $this->_getAttributes();
430
+			if (isset($attributes['SIZE'])) {
431
+				return (integer)$attributes['SIZE'];
432
+			}
433
+			return 0;
434
+		}
435
+	}
436
+
437
+	/**
438
+	 *    Parser for importing the output of the XmlReporter.
439
+	 *    Dispatches that output to another reporter.
440 440
 	 *	  @package SimpleTest
441 441
 	 *	  @subpackage UnitTester
442
-     */
443
-    class SimpleTestXmlParser {
444
-        protected $_listener;
445
-        protected $_expat;
446
-        protected $_tag_stack;
447
-        protected $_in_content_tag;
448
-        protected $_content;
449
-        protected $_attributes;
450
-
451
-        /**
452
-         *    Loads a listener with the SimpleReporter
453
-         *    interface.
454
-         *    @param SimpleReporter $listener   Listener of tag events.
455
-         *    @access public
456
-         */
457
-        function SimpleTestXmlParser($listener) {
458
-            $this->_listener = $listener;
459
-            $this->_expat = $this->_createParser();
460
-            $this->_tag_stack = array();
461
-            $this->_in_content_tag = false;
462
-            $this->_content = '';
463
-            $this->_attributes = array();
464
-        }
465
-
466
-        /**
467
-         *    Parses a block of XML sending the results to
468
-         *    the listener.
469
-         *    @param string $chunk        Block of text to read.
470
-         *    @return boolean             True if valid XML.
471
-         *    @access public
472
-         */
473
-        function parse($chunk) {
474
-            if (! xml_parse($this->_expat, $chunk)) {
475
-                trigger_error('XML parse error with ' .
476
-                        xml_error_string(xml_get_error_code($this->_expat)));
477
-                return false;
478
-            }
479
-            return true;
480
-        }
481
-
482
-        /**
483
-         *    Sets up expat as the XML parser.
484
-         *    @return resource        Expat handle.
485
-         *    @access protected
486
-         */
487
-        function &_createParser() {
488
-            $expat = xml_parser_create();
489
-            xml_set_object($expat, $this);
490
-            xml_set_element_handler($expat, '_startElement', '_endElement');
491
-            xml_set_character_data_handler($expat, '_addContent');
492
-            xml_set_default_handler($expat, '_default');
493
-            return $expat;
494
-        }
495
-
496
-        /**
497
-         *    Opens a new test nesting level.
498
-         *    @return NestedXmlTag     The group, case or method tag
499
-         *                             to start.
500
-         *    @access private
501
-         */
502
-        function _pushNestingTag($nested) {
503
-            array_unshift($this->_tag_stack, $nested);
504
-        }
505
-
506
-        /**
507
-         *    Accessor for current test structure tag.
508
-         *    @return NestedXmlTag     The group, case or method tag
509
-         *                             being parsed.
510
-         *    @access private
511
-         */
512
-        function &_getCurrentNestingTag() {
513
-            return $this->_tag_stack[0];
514
-        }
515
-
516
-        /**
517
-         *    Ends a nesting tag.
518
-         *    @return NestedXmlTag     The group, case or method tag
519
-         *                             just finished.
520
-         *    @access private
521
-         */
522
-        function _popNestingTag() {
523
-            return array_shift($this->_tag_stack);
524
-        }
525
-
526
-        /**
527
-         *    Test if tag is a leaf node with only text content.
528
-         *    @param string $tag        XML tag name.
529
-         *    @return @boolean          True if leaf, false if nesting.
530
-         *    @private
531
-         */
532
-        function _isLeaf($tag) {
533
-            return in_array($tag, array(
534
-                    'NAME', 'PASS', 'FAIL', 'EXCEPTION', 'MESSAGE', 'FORMATTED', 'SIGNAL'));
535
-        }
536
-
537
-        /**
538
-         *    Handler for start of event element.
539
-         *    @param resource $expat     Parser handle.
540
-         *    @param string $tag         Element name.
541
-         *    @param hash $attributes    Name value pairs.
542
-         *                               Attributes without content
543
-         *                               are marked as true.
544
-         *    @access protected
545
-         */
546
-        function _startElement($expat, $tag, $attributes) {
547
-            $this->_attributes = $attributes;
548
-            if ($tag == 'GROUP') {
549
-                $this->_pushNestingTag(new NestingGroupTag($attributes));
550
-            } elseif ($tag == 'CASE') {
551
-                $this->_pushNestingTag(new NestingCaseTag($attributes));
552
-            } elseif ($tag == 'TEST') {
553
-                $this->_pushNestingTag(new NestingMethodTag($attributes));
554
-            } elseif ($this->_isLeaf($tag)) {
555
-                $this->_in_content_tag = true;
556
-                $this->_content = '';
557
-            }
558
-        }
559
-
560
-        /**
561
-         *    End of element event.
562
-         *    @param resource $expat     Parser handle.
563
-         *    @param string $tag         Element name.
564
-         *    @access protected
565
-         */
566
-        function _endElement($expat, $tag) {
567
-            $this->_in_content_tag = false;
568
-            if (in_array($tag, array('GROUP', 'CASE', 'TEST'))) {
569
-                $nesting_tag = $this->_popNestingTag();
570
-                $nesting_tag->paintEnd($this->_listener);
571
-            } elseif ($tag == 'NAME') {
572
-                $nesting_tag = $this->_getCurrentNestingTag();
573
-                $nesting_tag->setName($this->_content);
574
-                $nesting_tag->paintStart($this->_listener);
575
-            } elseif ($tag == 'PASS') {
576
-                $this->_listener->paintPass($this->_content);
577
-            } elseif ($tag == 'FAIL') {
578
-                $this->_listener->paintFail($this->_content);
579
-            } elseif ($tag == 'EXCEPTION') {
580
-                $this->_listener->paintError($this->_content);
581
-            } elseif ($tag == 'SIGNAL') {
582
-                $this->_listener->paintSignal(
583
-                        $this->_attributes['TYPE'],
584
-                        unserialize($this->_content));
585
-            } elseif ($tag == 'MESSAGE') {
586
-                $this->_listener->paintMessage($this->_content);
587
-            } elseif ($tag == 'FORMATTED') {
588
-                $this->_listener->paintFormattedMessage($this->_content);
589
-            }
590
-        }
591
-
592
-        /**
593
-         *    Content between start and end elements.
594
-         *    @param resource $expat     Parser handle.
595
-         *    @param string $text        Usually output messages.
596
-         *    @access protected
597
-         */
598
-        function _addContent($expat, $text) {
599
-            if ($this->_in_content_tag) {
600
-                $this->_content .= $text;
601
-            }
602
-            return true;
603
-        }
604
-
605
-        /**
606
-         *    XML and Doctype handler. Discards all such content.
607
-         *    @param resource $expat     Parser handle.
608
-         *    @param string $default     Text of default content.
609
-         *    @access protected
610
-         */
611
-        function _default($expat, $default) {
612
-        }
613
-    }
442
+	 */
443
+	class SimpleTestXmlParser {
444
+		protected $_listener;
445
+		protected $_expat;
446
+		protected $_tag_stack;
447
+		protected $_in_content_tag;
448
+		protected $_content;
449
+		protected $_attributes;
450
+
451
+		/**
452
+		 *    Loads a listener with the SimpleReporter
453
+		 *    interface.
454
+		 *    @param SimpleReporter $listener   Listener of tag events.
455
+		 *    @access public
456
+		 */
457
+		function SimpleTestXmlParser($listener) {
458
+			$this->_listener = $listener;
459
+			$this->_expat = $this->_createParser();
460
+			$this->_tag_stack = array();
461
+			$this->_in_content_tag = false;
462
+			$this->_content = '';
463
+			$this->_attributes = array();
464
+		}
465
+
466
+		/**
467
+		 *    Parses a block of XML sending the results to
468
+		 *    the listener.
469
+		 *    @param string $chunk        Block of text to read.
470
+		 *    @return boolean             True if valid XML.
471
+		 *    @access public
472
+		 */
473
+		function parse($chunk) {
474
+			if (! xml_parse($this->_expat, $chunk)) {
475
+				trigger_error('XML parse error with ' .
476
+						xml_error_string(xml_get_error_code($this->_expat)));
477
+				return false;
478
+			}
479
+			return true;
480
+		}
481
+
482
+		/**
483
+		 *    Sets up expat as the XML parser.
484
+		 *    @return resource        Expat handle.
485
+		 *    @access protected
486
+		 */
487
+		function &_createParser() {
488
+			$expat = xml_parser_create();
489
+			xml_set_object($expat, $this);
490
+			xml_set_element_handler($expat, '_startElement', '_endElement');
491
+			xml_set_character_data_handler($expat, '_addContent');
492
+			xml_set_default_handler($expat, '_default');
493
+			return $expat;
494
+		}
495
+
496
+		/**
497
+		 *    Opens a new test nesting level.
498
+		 *    @return NestedXmlTag     The group, case or method tag
499
+		 *                             to start.
500
+		 *    @access private
501
+		 */
502
+		function _pushNestingTag($nested) {
503
+			array_unshift($this->_tag_stack, $nested);
504
+		}
505
+
506
+		/**
507
+		 *    Accessor for current test structure tag.
508
+		 *    @return NestedXmlTag     The group, case or method tag
509
+		 *                             being parsed.
510
+		 *    @access private
511
+		 */
512
+		function &_getCurrentNestingTag() {
513
+			return $this->_tag_stack[0];
514
+		}
515
+
516
+		/**
517
+		 *    Ends a nesting tag.
518
+		 *    @return NestedXmlTag     The group, case or method tag
519
+		 *                             just finished.
520
+		 *    @access private
521
+		 */
522
+		function _popNestingTag() {
523
+			return array_shift($this->_tag_stack);
524
+		}
525
+
526
+		/**
527
+		 *    Test if tag is a leaf node with only text content.
528
+		 *    @param string $tag        XML tag name.
529
+		 *    @return @boolean          True if leaf, false if nesting.
530
+		 *    @private
531
+		 */
532
+		function _isLeaf($tag) {
533
+			return in_array($tag, array(
534
+					'NAME', 'PASS', 'FAIL', 'EXCEPTION', 'MESSAGE', 'FORMATTED', 'SIGNAL'));
535
+		}
536
+
537
+		/**
538
+		 *    Handler for start of event element.
539
+		 *    @param resource $expat     Parser handle.
540
+		 *    @param string $tag         Element name.
541
+		 *    @param hash $attributes    Name value pairs.
542
+		 *                               Attributes without content
543
+		 *                               are marked as true.
544
+		 *    @access protected
545
+		 */
546
+		function _startElement($expat, $tag, $attributes) {
547
+			$this->_attributes = $attributes;
548
+			if ($tag == 'GROUP') {
549
+				$this->_pushNestingTag(new NestingGroupTag($attributes));
550
+			} elseif ($tag == 'CASE') {
551
+				$this->_pushNestingTag(new NestingCaseTag($attributes));
552
+			} elseif ($tag == 'TEST') {
553
+				$this->_pushNestingTag(new NestingMethodTag($attributes));
554
+			} elseif ($this->_isLeaf($tag)) {
555
+				$this->_in_content_tag = true;
556
+				$this->_content = '';
557
+			}
558
+		}
559
+
560
+		/**
561
+		 *    End of element event.
562
+		 *    @param resource $expat     Parser handle.
563
+		 *    @param string $tag         Element name.
564
+		 *    @access protected
565
+		 */
566
+		function _endElement($expat, $tag) {
567
+			$this->_in_content_tag = false;
568
+			if (in_array($tag, array('GROUP', 'CASE', 'TEST'))) {
569
+				$nesting_tag = $this->_popNestingTag();
570
+				$nesting_tag->paintEnd($this->_listener);
571
+			} elseif ($tag == 'NAME') {
572
+				$nesting_tag = $this->_getCurrentNestingTag();
573
+				$nesting_tag->setName($this->_content);
574
+				$nesting_tag->paintStart($this->_listener);
575
+			} elseif ($tag == 'PASS') {
576
+				$this->_listener->paintPass($this->_content);
577
+			} elseif ($tag == 'FAIL') {
578
+				$this->_listener->paintFail($this->_content);
579
+			} elseif ($tag == 'EXCEPTION') {
580
+				$this->_listener->paintError($this->_content);
581
+			} elseif ($tag == 'SIGNAL') {
582
+				$this->_listener->paintSignal(
583
+						$this->_attributes['TYPE'],
584
+						unserialize($this->_content));
585
+			} elseif ($tag == 'MESSAGE') {
586
+				$this->_listener->paintMessage($this->_content);
587
+			} elseif ($tag == 'FORMATTED') {
588
+				$this->_listener->paintFormattedMessage($this->_content);
589
+			}
590
+		}
591
+
592
+		/**
593
+		 *    Content between start and end elements.
594
+		 *    @param resource $expat     Parser handle.
595
+		 *    @param string $text        Usually output messages.
596
+		 *    @access protected
597
+		 */
598
+		function _addContent($expat, $text) {
599
+			if ($this->_in_content_tag) {
600
+				$this->_content .= $text;
601
+			}
602
+			return true;
603
+		}
604
+
605
+		/**
606
+		 *    XML and Doctype handler. Discards all such content.
607
+		 *    @param resource $expat     Parser handle.
608
+		 *    @param string $default     Text of default content.
609
+		 *    @access protected
610
+		 */
611
+		function _default($expat, $default) {
612
+		}
613
+	}
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
          *    @abstract
229 229
          */
230 230
         function paintHeader($test_name) {
231
-            if (! SimpleReporter::inCli()) {
231
+            if (!SimpleReporter::inCli()) {
232 232
                 header('Content-type: text/xml');
233 233
             }
234 234
             print "<?xml version=\"1.0\"";
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
         function getSize() {
429 429
             $attributes = $this->_getAttributes();
430 430
             if (isset($attributes['SIZE'])) {
431
-                return (integer)$attributes['SIZE'];
431
+                return (integer) $attributes['SIZE'];
432 432
             }
433 433
             return 0;
434 434
         }
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
          *    @access public
472 472
          */
473 473
         function parse($chunk) {
474
-            if (! xml_parse($this->_expat, $chunk)) {
474
+            if (!xml_parse($this->_expat, $chunk)) {
475 475
                 trigger_error('XML parse error with ' .
476 476
                         xml_error_string(xml_get_error_code($this->_expat)));
477 477
                 return false;
Please login to merge, or discard this patch.
tests/unit/Collections/TPriorityListTest.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -3,6 +3,10 @@
 block discarded – undo
3 3
 class PriorityListItem
4 4
 {
5 5
 	var $data = 'data';
6
+
7
+	/**
8
+	 * @param integer $d
9
+	 */
6 10
 	function __construct($d)
7 11
 	{
8 12
 		$this->data = $d;
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	public function testConstructTList()
76 76
 	{
77 77
 		$a    = array(
78
-			1,2,3
78
+			1, 2, 3
79 79
 		);
80 80
 		$list = new TPriorityList($a);
81 81
 		$this->assertEquals(3, $list->getCount());
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	public function testCanNotRemoveWhenReadOnlyTList()
242 242
 	{
243 243
 		$list = new TPriorityList(array(
244
-			1,2,3
244
+			1, 2, 3
245 245
 		), true);
246 246
 		try {
247 247
 			$list->remove(2);
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 		}
252 252
 		
253 253
 		$list = new TPriorityList(array(
254
-			1,2,3
254
+			1, 2, 3
255 255
 		), true);
256 256
 		try {
257 257
 			$list->remove(10);
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	public function testCanNotRemoveAtWhenReadOnlyTList()
280 280
 	{
281 281
 		$list = new TPriorityList(array(
282
-			1,2,3
282
+			1, 2, 3
283 283
 		), true);
284 284
 		try {
285 285
 			$list->removeAt(2);
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		}
290 290
 		
291 291
 		$list = new TPriorityList(array(
292
-			1,2,3
292
+			1, 2, 3
293 293
 		), true);
294 294
 		try {
295 295
 			$list->removeAt(10);
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	public function testCanNotClearWhenReadOnlyTList()
311 311
 	{
312 312
 		$list = new TPriorityList(array(
313
-			1,2,3
313
+			1, 2, 3
314 314
 		), true);
315 315
 		try {
316 316
 			$list->clear();
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 	public function testCopyFromTList()
339 339
 	{
340 340
 		$array = array(
341
-			$this->item3,$this->item1
341
+			$this->item3, $this->item1
342 342
 		);
343 343
 		$this->list->copyFrom($array);
344 344
 		$this->assertTrue(count($array) == 2 && $this->list[0] === $this->item3 && $this->list[1] === $this->item1);
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 	public function testMergeWithTList()
354 354
 	{
355 355
 		$array = array(
356
-			$this->item3,$this->item1
356
+			$this->item3, $this->item1
357 357
 		);
358 358
 		$this->list->mergeWith($array);
359 359
 		$this->assertTrue($this->list->getCount() == 4 && $this->list[0] === $this->item1 && $this->list[3] === $this->item1);
@@ -408,33 +408,33 @@  discard block
 block discarded – undo
408 408
 	public function testOffsetSetAddTList()
409 409
 	{
410 410
 		$list = new TPriorityList(array(
411
-			1,2,3
411
+			1, 2, 3
412 412
 		));
413 413
 		$list->offsetSet(null, 4);
414 414
 		self::assertEquals(array(
415
-			1,2,3,4
415
+			1, 2, 3, 4
416 416
 		), $list->toArray());
417 417
 	}
418 418
 	
419 419
 	public function testOffsetSetReplaceTList()
420 420
 	{
421 421
 		$list = new TPriorityList(array(
422
-			1,2,3
422
+			1, 2, 3
423 423
 		));
424 424
 		$list->offsetSet(1, 4);
425 425
 		self::assertEquals(array(
426
-			1,4,3
426
+			1, 4, 3
427 427
 		), $list->toArray());
428 428
 	}
429 429
 	
430 430
 	public function testOffsetUnsetTList()
431 431
 	{
432 432
 		$list = new TPriorityList(array(
433
-			1,2,3
433
+			1, 2, 3
434 434
 		));
435 435
 		$list->offsetUnset(1);
436 436
 		self::assertEquals(array(
437
-			1,3
437
+			1, 3
438 438
 		), $list->toArray());
439 439
 	}
440 440
 	
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 	public function testConstructTPriorityList()
450 450
 	{
451 451
 		$a = array(
452
-			'a' => 1,'0.5' => 2,9 => 8
452
+			'a' => 1, '0.5' => 2, 9 => 8
453 453
 		);
454 454
 		
455 455
 		$list = new TPriorityList($a);
@@ -646,38 +646,38 @@  discard block
 block discarded – undo
646 646
 		
647 647
 		$plist->insertAtIndexInPriority(4, false);
648 648
 		$this->assertEquals(array(
649
-			3,4
649
+			3, 4
650 650
 		), $plist->toArray());
651 651
 		$plist->insertAtIndexInPriority(5, 2);
652 652
 		$this->assertEquals(array(
653
-			3,4,5
653
+			3, 4, 5
654 654
 		), $plist->toArray());
655 655
 		
656 656
 		$plist->insertAtIndexInPriority(6, false, null);
657 657
 		$this->assertEquals(array(
658
-			3,4,5,6
658
+			3, 4, 5, 6
659 659
 		), $plist->toArray());
660 660
 		$plist->insertAtIndexInPriority(7, 5, null);
661 661
 		$this->assertEquals(array(
662
-			3,4,5,6,7
662
+			3, 4, 5, 6, 7
663 663
 		), $plist->toArray());
664 664
 		
665 665
 		$plist->insertAtIndexInPriority(8, false, 10);
666 666
 		$this->assertEquals(array(
667
-			3,4,5,6,7,8
667
+			3, 4, 5, 6, 7, 8
668 668
 		), $plist->toArray());
669 669
 		$plist->insertAtIndexInPriority(9, 7, 10);
670 670
 		$this->assertEquals(array(
671
-			3,4,5,6,7,8,9
671
+			3, 4, 5, 6, 7, 8, 9
672 672
 		), $plist->toArray());
673 673
 		
674 674
 		$plist->insertAtIndexInPriority(10, false, 100);
675 675
 		$this->assertEquals(array(
676
-			3,4,5,6,7,8,9,10
676
+			3, 4, 5, 6, 7, 8, 9, 10
677 677
 		), $plist->toArray());
678 678
 		$plist->insertAtIndexInPriority(11, 1, 100);
679 679
 		$this->assertEquals(array(
680
-			3,4,5,6,7,8,9,10,11
680
+			3, 4, 5, 6, 7, 8, 9, 10, 11
681 681
 		), $plist->toArray());
682 682
 		
683 683
 		$plist = new TPriorityList();
@@ -689,38 +689,38 @@  discard block
 block discarded – undo
689 689
 		
690 690
 		$plist->insertAtIndexInPriority(4, false, null, true);
691 691
 		$this->assertEquals(array(
692
-			3,4
692
+			3, 4
693 693
 		), $plist->toArray());
694 694
 		$plist->insertAtIndexInPriority(5, 2, null, true);
695 695
 		$this->assertEquals(array(
696
-			3,4,5
696
+			3, 4, 5
697 697
 		), $plist->toArray());
698 698
 		
699 699
 		$plist->insertAtIndexInPriority(6, false, null, true);
700 700
 		$this->assertEquals(array(
701
-			3,4,5,6
701
+			3, 4, 5, 6
702 702
 		), $plist->toArray());
703 703
 		$plist->insertAtIndexInPriority(7, 5, null, true);
704 704
 		$this->assertEquals(array(
705
-			3,4,5,6,7
705
+			3, 4, 5, 6, 7
706 706
 		), $plist->toArray());
707 707
 		
708 708
 		$plist->insertAtIndexInPriority(8, false, 10, true);
709 709
 		$this->assertEquals(array(
710
-			3,4,5,6,7,8
710
+			3, 4, 5, 6, 7, 8
711 711
 		), $plist->toArray());
712 712
 		$plist->insertAtIndexInPriority(9, 7, 10, true);
713 713
 		$this->assertEquals(array(
714
-			3,4,5,6,7,8,9
714
+			3, 4, 5, 6, 7, 8, 9
715 715
 		), $plist->toArray());
716 716
 		
717 717
 		$plist->insertAtIndexInPriority(10, false, 100, true);
718 718
 		$this->assertEquals(array(
719
-			3,4,5,6,7,8,9,10
719
+			3, 4, 5, 6, 7, 8, 9, 10
720 720
 		), $plist->toArray());
721 721
 		$plist->insertAtIndexInPriority(11, 1, 100, true);
722 722
 		$this->assertEquals(array(
723
-			3,4,5,6,7,8,9,10,11
723
+			3, 4, 5, 6, 7, 8, 9, 10, 11
724 724
 		), $plist->toArray());
725 725
 		
726 726
 		$plist = new TPriorityList();
@@ -732,38 +732,38 @@  discard block
 block discarded – undo
732 732
 		
733 733
 		$plist->insertAtIndexInPriority(4, false, null, false);
734 734
 		$this->assertEquals(array(
735
-			3,4
735
+			3, 4
736 736
 		), $plist->toArray());
737 737
 		$plist->insertAtIndexInPriority(5, 2, null, false);
738 738
 		$this->assertEquals(array(
739
-			3,4,5
739
+			3, 4, 5
740 740
 		), $plist->toArray());
741 741
 		
742 742
 		$plist->insertAtIndexInPriority(6, false, null, false);
743 743
 		$this->assertEquals(array(
744
-			3,4,5,6
744
+			3, 4, 5, 6
745 745
 		), $plist->toArray());
746 746
 		$plist->insertAtIndexInPriority(7, 5, null, false);
747 747
 		$this->assertEquals(array(
748
-			3,4,5,6,7
748
+			3, 4, 5, 6, 7
749 749
 		), $plist->toArray());
750 750
 		
751 751
 		$plist->insertAtIndexInPriority(8, false, 10, false);
752 752
 		$this->assertEquals(array(
753
-			3,4,5,6,7,8
753
+			3, 4, 5, 6, 7, 8
754 754
 		), $plist->toArray());
755 755
 		$plist->insertAtIndexInPriority(9, 7, 10, false);
756 756
 		$this->assertEquals(array(
757
-			3,4,5,6,7,8,9
757
+			3, 4, 5, 6, 7, 8, 9
758 758
 		), $plist->toArray());
759 759
 		
760 760
 		$plist->insertAtIndexInPriority(10, false, 100, false);
761 761
 		$this->assertEquals(array(
762
-			3,4,5,6,7,8,9,10
762
+			3, 4, 5, 6, 7, 8, 9, 10
763 763
 		), $plist->toArray());
764 764
 		$plist->insertAtIndexInPriority(11, 1, 100, false);
765 765
 		$this->assertEquals(array(
766
-			3,4,5,6,7,8,9,10,11
766
+			3, 4, 5, 6, 7, 8, 9, 10, 11
767 767
 		), $plist->toArray());
768 768
 	}
769 769
 	
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 	public function testMergeWithTPriorityList()
922 922
 	{
923 923
 		$plist = new TPriorityList(array(
924
-			$this->item3,$this->item1
924
+			$this->item3, $this->item1
925 925
 		));
926 926
 		$plist->mergeWith($this->plist);
927 927
 		$this->assertEquals(6, $plist->getCount());
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
 		$list->add(3, 15);
1088 1088
 		$list->offsetSet(null, 4); // Appending like this, items get the default priority; not linear behavior
1089 1089
 		self::assertEquals(array(
1090
-			1,2,4,3
1090
+			1, 2, 4, 3
1091 1091
 		), $list->toArray());
1092 1092
 	}
1093 1093
 	
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 		$list->add(3, 15);
1100 1100
 		$list->offsetSet(1, 4);
1101 1101
 		self::assertEquals(array(
1102
-			1,4,3
1102
+			1, 4, 3
1103 1103
 		), $list->toArray());
1104 1104
 	}
1105 1105
 	
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
 		$list->add(3, 15);
1112 1112
 		$list->offsetSet(3, 4);
1113 1113
 		self::assertEquals(array(
1114
-			1,2,3,4
1114
+			1, 2, 3, 4
1115 1115
 		), $list->toArray());
1116 1116
 	}
1117 1117
 	
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 		$list->add(3, 15);
1124 1124
 		$list->offsetUnset(1);
1125 1125
 		self::assertEquals(array(
1126
-			1,3
1126
+			1, 3
1127 1127
 		), $list->toArray());
1128 1128
 	}
1129 1129
 	
Please login to merge, or discard this patch.
Braces   +48 added lines, -72 removed lines patch added patch discarded remove patch
@@ -117,8 +117,7 @@  discard block
 block discarded – undo
117 117
 		try {
118 118
 			$list->add(1);
119 119
 			self::fail('An expected TInvalidOperationException was not raised');
120
-		}
121
-		catch (TInvalidOperationException $e) {
120
+		} catch (TInvalidOperationException $e) {
122 121
 		}
123 122
 	}
124 123
 	
@@ -132,8 +131,7 @@  discard block
 block discarded – undo
132 131
 		try {
133 132
 			$this->list->insertAt(4, $this->item3);
134 133
 			$this->fail('exception not raised when adding item at an out-of-range index');
135
-		}
136
-		catch (TInvalidDataValueException $e) {
134
+		} catch (TInvalidDataValueException $e) {
137 135
 		}
138 136
 	}
139 137
 	
@@ -143,14 +141,12 @@  discard block
 block discarded – undo
143 141
 		try {
144 142
 			$list->insertAt(1, 2);
145 143
 			self::fail('An expected TInvalidOperationException was not raised');
146
-		}
147
-		catch (TInvalidOperationException $e) {
144
+		} catch (TInvalidOperationException $e) {
148 145
 		}
149 146
 		try {
150 147
 			$list->insertAt(0, 2);
151 148
 			self::fail('An expected TInvalidOperationException was not raised');
152
-		}
153
-		catch (TInvalidOperationException $e) {
149
+		} catch (TInvalidOperationException $e) {
154 150
 		}
155 151
 	}
156 152
 	
@@ -159,8 +155,7 @@  discard block
 block discarded – undo
159 155
 		try {
160 156
 			$this->list->insertBefore($this->item4, $this->item3);
161 157
 			$this->fail('exception not raised when adding item before a non-existant base item');
162
-		}
163
-		catch (TInvalidDataValueException $e) {
158
+		} catch (TInvalidDataValueException $e) {
164 159
 		}
165 160
 		$this->assertEquals(2, $this->list->getCount());
166 161
 		$this->assertEquals(0, $this->list->insertBefore($this->item1, $this->item3));
@@ -178,14 +173,12 @@  discard block
 block discarded – undo
178 173
 		try {
179 174
 			$list->insertBefore(5, 6);
180 175
 			self::fail('An expected TInvalidOperationException was not raised');
181
-		}
182
-		catch (TInvalidOperationException $e) {
176
+		} catch (TInvalidOperationException $e) {
183 177
 		}
184 178
 		try {
185 179
 			$list->insertBefore(8, 6);
186 180
 			self::fail('An expected TInvalidOperationException was not raised');
187
-		}
188
-		catch (TInvalidOperationException $e) {
181
+		} catch (TInvalidOperationException $e) {
189 182
 		}
190 183
 	}
191 184
 	
@@ -194,8 +187,7 @@  discard block
 block discarded – undo
194 187
 		try {
195 188
 			$this->list->insertAfter($this->item4, $this->item3);
196 189
 			$this->fail('exception not raised when adding item after a non-existant base item');
197
-		}
198
-		catch (TInvalidDataValueException $e) {
190
+		} catch (TInvalidDataValueException $e) {
199 191
 		}
200 192
 		$this->assertEquals(2, $this->list->getCount());
201 193
 		$this->assertEquals(2, $this->list->insertAfter($this->item2, $this->item3));
@@ -213,14 +205,12 @@  discard block
 block discarded – undo
213 205
 		try {
214 206
 			$list->insertAfter(5, 6);
215 207
 			self::fail('An expected TInvalidOperationException was not raised');
216
-		}
217
-		catch (TInvalidOperationException $e) {
208
+		} catch (TInvalidOperationException $e) {
218 209
 		}
219 210
 		try {
220 211
 			$list->insertAfter(8, 6);
221 212
 			self::fail('An expected TInvalidOperationException was not raised');
222
-		}
223
-		catch (TInvalidOperationException $e) {
213
+		} catch (TInvalidOperationException $e) {
224 214
 		}
225 215
 	}
226 216
 	
@@ -233,8 +223,7 @@  discard block
 block discarded – undo
233 223
 		try {
234 224
 			$this->list->remove($this->item1);
235 225
 			$this->fail('exception not raised when removing nonexisting item');
236
-		}
237
-		catch (Exception $e) {
226
+		} catch (Exception $e) {
238 227
 		}
239 228
 	}
240 229
 	
@@ -246,8 +235,7 @@  discard block
 block discarded – undo
246 235
 		try {
247 236
 			$list->remove(2);
248 237
 			self::fail('An expected TInvalidOperationException was not raised');
249
-		}
250
-		catch (TInvalidOperationException $e) {
238
+		} catch (TInvalidOperationException $e) {
251 239
 		}
252 240
 		
253 241
 		$list = new TPriorityList(array(
@@ -256,8 +244,7 @@  discard block
 block discarded – undo
256 244
 		try {
257 245
 			$list->remove(10);
258 246
 			self::fail('An expected TInvalidOperationException was not raised');
259
-		}
260
-		catch (TInvalidOperationException $e) {
247
+		} catch (TInvalidOperationException $e) {
261 248
 		}
262 249
 	}
263 250
 	
@@ -271,8 +258,7 @@  discard block
 block discarded – undo
271 258
 		try {
272 259
 			$this->list->removeAt(2);
273 260
 			$this->fail('exception not raised when removing item with invalid index');
274
-		}
275
-		catch (TInvalidDataValueException $e) {
261
+		} catch (TInvalidDataValueException $e) {
276 262
 		}
277 263
 	}
278 264
 	
@@ -284,8 +270,7 @@  discard block
 block discarded – undo
284 270
 		try {
285 271
 			$list->removeAt(2);
286 272
 			self::fail('An expected TInvalidOperationException was not raised');
287
-		}
288
-		catch (TInvalidOperationException $e) {
273
+		} catch (TInvalidOperationException $e) {
289 274
 		}
290 275
 		
291 276
 		$list = new TPriorityList(array(
@@ -294,8 +279,7 @@  discard block
 block discarded – undo
294 279
 		try {
295 280
 			$list->removeAt(10);
296 281
 			self::fail('An expected TInvalidOperationException was not raised');
297
-		}
298
-		catch (TInvalidOperationException $e) {
282
+		} catch (TInvalidOperationException $e) {
299 283
 		}
300 284
 	}
301 285
 	
@@ -314,8 +298,7 @@  discard block
 block discarded – undo
314 298
 		), true);
315 299
 		try {
316 300
 			$list->clear();
317
-		}
318
-		catch (TInvalidOperationException $e) {
301
+		} catch (TInvalidOperationException $e) {
319 302
 			return;
320 303
 		}
321 304
 		self::fail('An expected TInvalidOperationException was not raised');
@@ -345,8 +328,7 @@  discard block
 block discarded – undo
345 328
 		try {
346 329
 			$this->list->copyFrom($this);
347 330
 			$this->fail('exception not raised when copying from non-traversable object');
348
-		}
349
-		catch (TInvalidDataTypeException $e) {
331
+		} catch (TInvalidDataTypeException $e) {
350 332
 		}
351 333
 	}
352 334
 	
@@ -360,8 +342,7 @@  discard block
 block discarded – undo
360 342
 		try {
361 343
 			$this->list->mergeWith($this);
362 344
 			$this->fail('exception not raised when copying from non-traversable object');
363
-		}
364
-		catch (TInvalidDataTypeException $e) {
345
+		} catch (TInvalidDataTypeException $e) {
365 346
 		}
366 347
 	}
367 348
 	
@@ -378,8 +359,7 @@  discard block
 block discarded – undo
378 359
 		try {
379 360
 			$a = $this->list[2];
380 361
 			$this->fail('exception not raised when accessing item with out-of-range index');
381
-		}
382
-		catch (TInvalidDataValueException $e) {
362
+		} catch (TInvalidDataValueException $e) {
383 363
 		}
384 364
 	}
385 365
 	
@@ -390,10 +370,12 @@  discard block
 block discarded – undo
390 370
 		foreach ($this->list as $index => $item) {
391 371
 			foreach ($this->list as $a => $b); // test of iterator
392 372
 			$n++;
393
-			if ($index === 0 && $item === $this->item1)
394
-				$found++;
395
-			if ($index === 1 && $item === $this->item2)
396
-				$found++;
373
+			if ($index === 0 && $item === $this->item1) {
374
+							$found++;
375
+			}
376
+			if ($index === 1 && $item === $this->item2) {
377
+							$found++;
378
+			}
397 379
 		}
398 380
 		$this->assertTrue($n == 2 && $found == 2);
399 381
 	}
@@ -552,8 +534,7 @@  discard block
 block discarded – undo
552 534
 		try {
553 535
 			$plist->insertAt(5, $this->pitem3);
554 536
 			$this->fail('exception not raised when adding item at an out-of-range index');
555
-		}
556
-		catch (TInvalidDataValueException $e) {
537
+		} catch (TInvalidDataValueException $e) {
557 538
 		}
558 539
 		$this->assertEquals(100, $plist->priorityAt(4));
559 540
 	}
@@ -588,22 +569,19 @@  discard block
 block discarded – undo
588 569
 		try {
589 570
 			$plist->remove($this->pitem5);
590 571
 			$this->fail('Exception not raised: TInvalidDataValueException: The item cannot be found in the list');
591
-		}
592
-		catch (TInvalidDataValueException $v) {
572
+		} catch (TInvalidDataValueException $v) {
593 573
 		}
594 574
 		
595 575
 		try {
596 576
 			$plist->remove($this->pitem3, null);
597 577
 			$this->fail('Exception not raised: TInvalidDataValueException: The item cannot be found in the list');
598
-		}
599
-		catch (TInvalidDataValueException $v) {
578
+		} catch (TInvalidDataValueException $v) {
600 579
 		}
601 580
 		
602 581
 		try {
603 582
 			$plist->remove($this->pitem1, 100);
604 583
 			$this->fail('Exception not raised: TInvalidDataValueException: The item cannot be found in the list');
605
-		}
606
-		catch (TInvalidDataValueException $v) {
584
+		} catch (TInvalidDataValueException $v) {
607 585
 		}
608 586
 		
609 587
 		$plist->insertBefore($this->pitem3, $this->pitem4);
@@ -621,8 +599,7 @@  discard block
 block discarded – undo
621 599
 		try {
622 600
 			$plist->removeAt(3);
623 601
 			$this->fail('exception not raised when removing item with invalid index');
624
-		}
625
-		catch (TInvalidDataValueException $e) {
602
+		} catch (TInvalidDataValueException $e) {
626 603
 		}
627 604
 	}
628 605
 	
@@ -773,8 +750,7 @@  discard block
 block discarded – undo
773 750
 		try {
774 751
 			$list->insertAtIndexInPriority(1);
775 752
 			self::fail('An expected TInvalidOperationException was not raised');
776
-		}
777
-		catch (TInvalidOperationException $e) {
753
+		} catch (TInvalidOperationException $e) {
778 754
 		}
779 755
 	}
780 756
 	
@@ -785,8 +761,7 @@  discard block
 block discarded – undo
785 761
 		try {
786 762
 			$plist->removeAtIndexInPriority(1, 100);
787 763
 			$this->fail('TInvalidDataValueException not raised when accessing item with out-of-range index');
788
-		}
789
-		catch (TInvalidDataValueException $e) {
764
+		} catch (TInvalidDataValueException $e) {
790 765
 		}
791 766
 		$this->assertEquals($this->pitem2, $plist->removeAtIndexInPriority(1));
792 767
 		$this->assertEquals($this->pitem3, $plist->removeAtIndexInPriority(0, 100));
@@ -794,8 +769,7 @@  discard block
 block discarded – undo
794 769
 		try {
795 770
 			$plist->removeAtIndexInPriority(0, 200);
796 771
 			$this->fail('TInvalidDataValueException not raised when accessing item with out-of-range index');
797
-		}
798
-		catch (TInvalidDataValueException $e) {
772
+		} catch (TInvalidDataValueException $e) {
799 773
 		}
800 774
 		$this->assertEquals($this->pfirst, $plist->removeAtIndexInPriority(0, -10000000));
801 775
 		$this->assertEquals(0, $plist->getCount());
@@ -808,8 +782,7 @@  discard block
 block discarded – undo
808 782
 		try {
809 783
 			$plist->removeAtIndexInPriority(0);
810 784
 			self::fail('An expected TInvalidOperationException was not raised');
811
-		}
812
-		catch (TInvalidOperationException $e) {
785
+		} catch (TInvalidOperationException $e) {
813 786
 		}
814 787
 	}
815 788
 	
@@ -1043,8 +1016,7 @@  discard block
 block discarded – undo
1043 1016
 		try {
1044 1017
 			$a = $this->plist[4];
1045 1018
 			$this->fail('exception not raised when accessing item with out-of-range index');
1046
-		}
1047
-		catch (TInvalidDataValueException $e) {
1019
+		} catch (TInvalidDataValueException $e) {
1048 1020
 		}
1049 1021
 	}
1050 1022
 	
@@ -1057,14 +1029,18 @@  discard block
 block discarded – undo
1057 1029
 		
1058 1030
 		foreach ($this->plist as $index => $item) {
1059 1031
 			$n++;
1060
-			if ($index === 0 && $item === $this->pfirst)
1061
-				$found++;
1062
-			if ($index === 1 && $item === $this->pitem1)
1063
-				$found++;
1064
-			if ($index === 2 && $item === $this->pitem2)
1065
-				$found++;
1066
-			if ($index === 3 && $item === $this->pitem3)
1067
-				$found++;
1032
+			if ($index === 0 && $item === $this->pfirst) {
1033
+							$found++;
1034
+			}
1035
+			if ($index === 1 && $item === $this->pitem1) {
1036
+							$found++;
1037
+			}
1038
+			if ($index === 2 && $item === $this->pitem2) {
1039
+							$found++;
1040
+			}
1041
+			if ($index === 3 && $item === $this->pitem3) {
1042
+							$found++;
1043
+			}
1068 1044
 		}
1069 1045
 		$this->assertTrue($n == 4 && $found == 4);
1070 1046
 	}
Please login to merge, or discard this patch.
tests/unit/TComponentTest.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -170,6 +170,10 @@
 block discarded – undo
170 170
 	public function isinstanceof($class, $instance=null) {
171 171
 		return $this->_instanceReturn;
172 172
 	}
173
+
174
+	/**
175
+	 * @param null|boolean $value
176
+	 */
173 177
 	public function setInstanceReturn($value) {
174 178
 		$this->_instanceReturn = $value;
175 179
 	}
Please login to merge, or discard this patch.
Indentation   +959 added lines, -959 removed lines patch added patch discarded remove patch
@@ -12,15 +12,15 @@  discard block
 block discarded – undo
12 12
   private $_colorattribute = null;
13 13
 
14 14
   public function getAutoGlobalListen() {
15
-    return true;
15
+	return true;
16 16
   }
17 17
 
18 18
   public function getText() {
19
-    return $this->_text;
19
+	return $this->_text;
20 20
   }
21 21
 
22 22
   public function setText($value) {
23
-    $this->_text=$value;
23
+	$this->_text=$value;
24 24
   }
25 25
 
26 26
   public function getReadOnlyProperty() {
@@ -32,37 +32,37 @@  discard block
 block discarded – undo
32 32
   }
33 33
 
34 34
   public function getObject() {
35
-    if(!$this->_object) {
36
-      $this->_object=new NewComponent;
37
-      $this->_object->_text='object text';
38
-    }
39
-    return $this->_object;
35
+	if(!$this->_object) {
36
+	  $this->_object=new NewComponent;
37
+	  $this->_object->_text='object text';
38
+	}
39
+	return $this->_object;
40 40
   }
41 41
 
42 42
   public function onMyEvent($param) {
43
-    $this->raiseEvent('OnMyEvent',$this,$param);
43
+	$this->raiseEvent('OnMyEvent',$this,$param);
44 44
   }
45 45
 
46 46
   public function myEventHandler($sender,$param) {
47
-    $this->_eventHandled=true;
47
+	$this->_eventHandled=true;
48 48
   }
49 49
 
50 50
   public function eventReturnValue($sender,$param) {
51
-    return $param->Return;
51
+	return $param->Return;
52 52
   }
53 53
 
54 54
   public function isEventHandled() {
55
-    return $this->_eventHandled;
55
+	return $this->_eventHandled;
56 56
   }
57 57
 
58 58
   public function resetEventHandled() {
59
-    $this->_eventHandled = false;
59
+	$this->_eventHandled = false;
60 60
   }
61 61
   public function getReturn() {
62 62
   	return $this->_return;
63 63
   }
64 64
   public function setReturn($return) {
65
-    $this->_return = $return;
65
+	$this->_return = $return;
66 66
   }
67 67
   public function getjsColorAttribute() {
68 68
 	return $this->_colorattribute;
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	}
203 203
 
204 204
 	public function onBehaviorEvent($sender, $param,$responsetype=null,$postfunction=null) {
205
-    	return $this->getOwner()->raiseEvent('onBehaviorEvent',$sender,$param,$responsetype,$postfunction);
205
+		return $this->getOwner()->raiseEvent('onBehaviorEvent',$sender,$param,$responsetype,$postfunction);
206 206
 	}
207 207
 	public function fxGlobalBehaviorEvent($sender, $param) {
208 208
 	}
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
   protected $component;
414 414
 
415 415
   public function setUp() {
416
-    $this->component = new NewComponent();
416
+	$this->component = new NewComponent();
417 417
   }
418 418
 
419 419
 
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
   	// PHP version 5.3.6 doesn't call the __destruct method when unsetting variables;
422 422
   	//	Thus any object that listens must be explicitly call unlisten in this version of PHP.
423 423
   	if($this->component)
424
-	    $this->component->unlisten();
425
-    $this->component = null;
424
+		$this->component->unlisten();
425
+	$this->component = null;
426 426
   }
427 427
 
428 428
 
429 429
   public function testGetListeningToGlobalEvents() {
430 430
   	$this->assertEquals(true, $this->component->getListeningToGlobalEvents());
431
-    $this->component->unlisten();
431
+	$this->component->unlisten();
432 432
   	$this->assertEquals(false, $this->component->getListeningToGlobalEvents());
433 433
   }
434 434
 
@@ -437,12 +437,12 @@  discard block
 block discarded – undo
437 437
   	// the default object auto installs class behavior hooks
438 438
   	$this->assertEquals(1, $this->component->getEventHandlers('fxAttachClassBehavior')->getCount());
439 439
   	$this->assertEquals(1, $this->component->getEventHandlers('fxDetachClassBehavior')->getCount());
440
-    $this->assertTrue($this->component->getListeningToGlobalEvents());
440
+	$this->assertTrue($this->component->getListeningToGlobalEvents());
441 441
 
442
-    // this object does not auto install class behavior hooks, thus not changing the global event structure.
443
-    //	Creating a new instance should _not_ influence the fxAttachClassBehavior and fxDetachClassBehavior
444
-    //	count.
445
-    $component_nolisten = new NewComponentNoListen();
442
+	// this object does not auto install class behavior hooks, thus not changing the global event structure.
443
+	//	Creating a new instance should _not_ influence the fxAttachClassBehavior and fxDetachClassBehavior
444
+	//	count.
445
+	$component_nolisten = new NewComponentNoListen();
446 446
   	$this->assertEquals(1, $this->component->getEventHandlers('fxAttachClassBehavior')->getCount());
447 447
   	$this->assertEquals(1, $this->component->getEventHandlers('fxDetachClassBehavior')->getCount());
448 448
   	$this->assertEquals(1, $component_nolisten->getEventHandlers('fxAttachClassBehavior')->getCount());
@@ -523,66 +523,66 @@  discard block
 block discarded – undo
523 523
   //Test Class behaviors
524 524
   public function testAttachClassBehavior() {
525 525
 
526
-    // ensure that the class is listening
526
+	// ensure that the class is listening
527 527
   	$this->assertEquals(1, $this->component->getEventHandlers('fxAttachClassBehavior')->getCount());
528 528
 
529 529
   	//Test that the component is not a FooClassBehavior
530
-    $this->assertNull($this->component->asa('FooClassBehavior'), "Component is already a FooClassBehavior and should not have this behavior");
530
+	$this->assertNull($this->component->asa('FooClassBehavior'), "Component is already a FooClassBehavior and should not have this behavior");
531 531
 
532
-    //Add the FooClassBehavior
533
-    $this->component->attachClassBehavior('FooClassBehavior', new FooClassBehavior);
532
+	//Add the FooClassBehavior
533
+	$this->component->attachClassBehavior('FooClassBehavior', new FooClassBehavior);
534 534
 
535
-    //Test that the existing listening component can be a FooClassBehavior
536
-    $this->assertNotNull($this->component->asa('FooClassBehavior'), "Component is does not have the FooClassBehavior and should have this behavior");
535
+	//Test that the existing listening component can be a FooClassBehavior
536
+	$this->assertNotNull($this->component->asa('FooClassBehavior'), "Component is does not have the FooClassBehavior and should have this behavior");
537 537
 
538
-    // test if the function modifies new instances of the object
539
-    $anothercomponent = new NewComponent();
538
+	// test if the function modifies new instances of the object
539
+	$anothercomponent = new NewComponent();
540 540
 
541
-    //The new component should be a FooClassBehavior
542
-    $this->assertNotNull($anothercomponent->asa('FooClassBehavior'), "anothercomponent does not have the FooClassBehavior");
541
+	//The new component should be a FooClassBehavior
542
+	$this->assertNotNull($anothercomponent->asa('FooClassBehavior'), "anothercomponent does not have the FooClassBehavior");
543 543
 
544
-    // test when overwriting an existing class behavior, it should throw an TInvalidOperationException
545
-    try {
546
-      $this->component->attachClassBehavior('FooClassBehavior', new BarClassBehavior);
547
-      $this->fail('TInvalidOperationException not raised when overwriting an existing behavior');
548
-    } catch(TInvalidOperationException $e) {
549
-    }
544
+	// test when overwriting an existing class behavior, it should throw an TInvalidOperationException
545
+	try {
546
+	  $this->component->attachClassBehavior('FooClassBehavior', new BarClassBehavior);
547
+	  $this->fail('TInvalidOperationException not raised when overwriting an existing behavior');
548
+	} catch(TInvalidOperationException $e) {
549
+	}
550 550
 
551 551
 
552
-    // test when overwriting an existing class behavior, it should throw an TInvalidOperationException
553
-    try {
552
+	// test when overwriting an existing class behavior, it should throw an TInvalidOperationException
553
+	try {
554 554
   	  $this->component->attachClassBehavior('FooBarBehavior', 'FooBarBehavior', 'TComponent');
555
-      $this->fail('TInvalidOperationException not raised when trying to place a behavior on the root object TComponent');
556
-    } catch(TInvalidOperationException $e) {
557
-    }
555
+	  $this->fail('TInvalidOperationException not raised when trying to place a behavior on the root object TComponent');
556
+	} catch(TInvalidOperationException $e) {
557
+	}
558 558
 
559 559
 
560
-    // test if the function does not modify any existing objects that are not listening
561
-    //	The FooClassBehavior is already a part of the class behaviors thus the new instance gets the behavior.
562
-    $nolistencomponent = new NewComponentNoListen();
560
+	// test if the function does not modify any existing objects that are not listening
561
+	//	The FooClassBehavior is already a part of the class behaviors thus the new instance gets the behavior.
562
+	$nolistencomponent = new NewComponentNoListen();
563 563
 
564
-    // test if the function modifies all existing objects that are listening
565
-    //	Adding a behavior to the first object, the second instance should automatically get the class behavior.
566
-    //		This is because the second object is listening to the global events of class behaviors
567
-    $this->component->attachClassBehavior('BarClassBehavior', new BarClassBehavior);
568
-    $this->assertNotNull($anothercomponent->asa('BarClassBehavior'), "anothercomponent is does not have the BarClassBehavior");
564
+	// test if the function modifies all existing objects that are listening
565
+	//	Adding a behavior to the first object, the second instance should automatically get the class behavior.
566
+	//		This is because the second object is listening to the global events of class behaviors
567
+	$this->component->attachClassBehavior('BarClassBehavior', new BarClassBehavior);
568
+	$this->assertNotNull($anothercomponent->asa('BarClassBehavior'), "anothercomponent is does not have the BarClassBehavior");
569 569
 
570
-    // The no listen object should not have the BarClassBehavior because it was added as a class behavior after the object was instanced
571
-    $this->assertNull($nolistencomponent->asa('BarClassBehavior'), "nolistencomponent has the BarClassBehavior and should not");
570
+	// The no listen object should not have the BarClassBehavior because it was added as a class behavior after the object was instanced
571
+	$this->assertNull($nolistencomponent->asa('BarClassBehavior'), "nolistencomponent has the BarClassBehavior and should not");
572 572
 
573
-    //	But the no listen object should have the FooClassBehavior because the class behavior was installed before the object was instanced
574
-    $this->assertNotNull($nolistencomponent->asa('FooClassBehavior'), "nolistencomponent is does not have the FooClassBehavior");
573
+	//	But the no listen object should have the FooClassBehavior because the class behavior was installed before the object was instanced
574
+	$this->assertNotNull($nolistencomponent->asa('FooClassBehavior'), "nolistencomponent is does not have the FooClassBehavior");
575 575
 
576
-    //Clear out what was done during this test
577
-    $anothercomponent->unlisten();
578
-    $this->component->detachClassBehavior('FooClassBehavior');
579
-    $this->component->detachClassBehavior('BarClassBehavior');
576
+	//Clear out what was done during this test
577
+	$anothercomponent->unlisten();
578
+	$this->component->detachClassBehavior('FooClassBehavior');
579
+	$this->component->detachClassBehavior('BarClassBehavior');
580 580
 
581
-    // Test attaching of single object behaviors as class-wide behaviors
582
-    $this->component->attachClassBehavior('BarBehaviorObject', 'BarBehavior');
583
-    $this->assertTrue($this->component->asa('BarBehaviorObject') instanceof BarBehavior);
584
-    $this->assertEquals($this->component->BarBehaviorObject->Owner, $this->component);
585
-    $this->component->detachClassBehavior('BarBehaviorObject');
581
+	// Test attaching of single object behaviors as class-wide behaviors
582
+	$this->component->attachClassBehavior('BarBehaviorObject', 'BarBehavior');
583
+	$this->assertTrue($this->component->asa('BarBehaviorObject') instanceof BarBehavior);
584
+	$this->assertEquals($this->component->BarBehaviorObject->Owner, $this->component);
585
+	$this->component->detachClassBehavior('BarBehaviorObject');
586 586
   }
587 587
 
588 588
 
@@ -590,48 +590,48 @@  discard block
 block discarded – undo
590 590
 
591 591
 
592 592
   public function testDetachClassBehavior() {
593
-    // ensure that the component is listening
593
+	// ensure that the component is listening
594 594
   	$this->assertEquals(1, $this->component->getEventHandlers('fxDetachClassBehavior')->getCount());
595 595
 
596
-    $prenolistencomponent = new NewComponentNoListen();
596
+	$prenolistencomponent = new NewComponentNoListen();
597 597
 
598 598
   	//Attach a class behavior
599
-    $this->component->attachClassBehavior('FooClassBehavior', new FooClassBehavior);
599
+	$this->component->attachClassBehavior('FooClassBehavior', new FooClassBehavior);
600 600
 
601
-    //Create new components that listen and don't listen to global events
602
-    $anothercomponent = new NewComponent();
603
-    $postnolistencomponent = new NewComponentNoListen();
601
+	//Create new components that listen and don't listen to global events
602
+	$anothercomponent = new NewComponent();
603
+	$postnolistencomponent = new NewComponentNoListen();
604 604
 
605
-    //ensures that all the Components are properly initialized
605
+	//ensures that all the Components are properly initialized
606 606
   	$this->assertEquals(2, $this->component->getEventHandlers('fxDetachClassBehavior')->getCount());
607
-    $this->assertNotNull($this->component->asa('FooClassBehavior'), "Component does not have the FooClassBehavior and should have this behavior");
608
-    $this->assertNull($prenolistencomponent->asa('FooClassBehavior'), "Component has the FooClassBehavior and should _not_ have this behavior");
609
-    $this->assertNotNull($anothercomponent->asa('FooClassBehavior'), "Component does not have the FooClassBehavior and should have this behavior");
610
-    $this->assertNotNull($postnolistencomponent->asa('FooClassBehavior'), "Component does not have the FooClassBehavior and should have this behavior");
607
+	$this->assertNotNull($this->component->asa('FooClassBehavior'), "Component does not have the FooClassBehavior and should have this behavior");
608
+	$this->assertNull($prenolistencomponent->asa('FooClassBehavior'), "Component has the FooClassBehavior and should _not_ have this behavior");
609
+	$this->assertNotNull($anothercomponent->asa('FooClassBehavior'), "Component does not have the FooClassBehavior and should have this behavior");
610
+	$this->assertNotNull($postnolistencomponent->asa('FooClassBehavior'), "Component does not have the FooClassBehavior and should have this behavior");
611 611
 
612 612
 
613
-    $this->component->detachClassBehavior('FooClassBehavior');
613
+	$this->component->detachClassBehavior('FooClassBehavior');
614 614
 
615
-    $this->assertNull($this->component->asa('FooClassBehavior'), "Component has the FooClassBehavior and should _not_ have this behavior");
616
-    $this->assertNull($prenolistencomponent->asa('FooClassBehavior'), "Component has the FooClassBehavior and should _not_ have this behavior");
617
-    $this->assertNull($anothercomponent->asa('FooClassBehavior'), "Component has the FooClassBehavior and should _not_ have this behavior");
618
-    $this->assertNotNull($postnolistencomponent->asa('FooClassBehavior'), "Component does not have the FooClassBehavior and should have this behavior");
615
+	$this->assertNull($this->component->asa('FooClassBehavior'), "Component has the FooClassBehavior and should _not_ have this behavior");
616
+	$this->assertNull($prenolistencomponent->asa('FooClassBehavior'), "Component has the FooClassBehavior and should _not_ have this behavior");
617
+	$this->assertNull($anothercomponent->asa('FooClassBehavior'), "Component has the FooClassBehavior and should _not_ have this behavior");
618
+	$this->assertNotNull($postnolistencomponent->asa('FooClassBehavior'), "Component does not have the FooClassBehavior and should have this behavior");
619 619
 
620 620
 
621
-    //tear down function variables
622
-    $anothercomponent->unlisten();
621
+	//tear down function variables
622
+	$anothercomponent->unlisten();
623 623
   }
624 624
 
625 625
   public function testGetClassHierarchy() {
626
-    $component = new DynamicCatchingComponent;
627
-    $this->assertEquals(array('TComponent', 'NewComponent', 'NewComponentNoListen', 'DynamicCatchingComponent'), $component->getClassHierarchy());
628
-    $this->assertEquals(array('TComponent', 'NewComponent', 'NewComponentNoListen', 'DynamicCatchingComponent'), $component->getClassHierarchy(false));
629
-    $this->assertEquals(array('tcomponent', 'newcomponent', 'newcomponentnolisten', 'dynamiccatchingcomponent'), $component->getClassHierarchy(true));
626
+	$component = new DynamicCatchingComponent;
627
+	$this->assertEquals(array('TComponent', 'NewComponent', 'NewComponentNoListen', 'DynamicCatchingComponent'), $component->getClassHierarchy());
628
+	$this->assertEquals(array('TComponent', 'NewComponent', 'NewComponentNoListen', 'DynamicCatchingComponent'), $component->getClassHierarchy(false));
629
+	$this->assertEquals(array('tcomponent', 'newcomponent', 'newcomponentnolisten', 'dynamiccatchingcomponent'), $component->getClassHierarchy(true));
630 630
   }
631 631
 
632 632
 
633 633
   public function testAsA() {
634
-    $anothercomponent = new NewComponent();
634
+	$anothercomponent = new NewComponent();
635 635
 
636 636
   	// ensure the component does not have the FooClassBehavior
637 637
   	$this->assertNull($this->component->asa('FooClassBehavior'));
@@ -645,24 +645,24 @@  discard block
 block discarded – undo
645 645
   	$this->assertNull($anothercomponent->asa('NonExistantClassBehavior'));
646 646
 
647 647
   	// add the class behavior
648
-    $this->component->attachClassBehavior('FooClassBehavior', new FooClassBehavior);
648
+	$this->component->attachClassBehavior('FooClassBehavior', new FooClassBehavior);
649 649
 
650
-    //Check that the component has only the class behavior assigned
650
+	//Check that the component has only the class behavior assigned
651 651
   	$this->assertNotNull($this->component->asa('FooClassBehavior'));
652 652
   	$this->assertNull($this->component->asa('FooFooClassBehavior'));
653 653
   	$this->assertNull($this->component->asa('BarClassBehavior'));
654 654
   	$this->assertNull($this->component->asa('NonExistantClassBehavior'));
655 655
 
656
-    //Check that the component has only the class behavior assigned
656
+	//Check that the component has only the class behavior assigned
657 657
   	$this->assertNotNull($anothercomponent->asa('FooClassBehavior'));
658 658
   	$this->assertNull($anothercomponent->asa('FooFooClassBehavior'));
659 659
   	$this->assertNull($anothercomponent->asa('BarClassBehavior'));
660 660
   	$this->assertNull($anothercomponent->asa('NonExistantClassBehavior'));
661 661
 
662 662
   	// remove the class behavior
663
-    $this->component->detachClassBehavior('FooClassBehavior');
663
+	$this->component->detachClassBehavior('FooClassBehavior');
664 664
 
665
-    // Check the function doesn't have the behavior any more
665
+	// Check the function doesn't have the behavior any more
666 666
   	$this->assertNull($this->component->asa('FooClassBehavior'));
667 667
   	$this->assertNull($this->component->asa('FooFooClassBehavior'));
668 668
   	$this->assertNull($this->component->asa('BarClassBehavior'));
@@ -678,13 +678,13 @@  discard block
 block discarded – undo
678 678
 
679 679
   	$this->component->attachBehavior('BarBehavior', new BarBehavior);
680 680
 
681
-    //Check that the component has only the object behavior assigned
681
+	//Check that the component has only the object behavior assigned
682 682
   	$this->assertNull($this->component->asa('FooBehavior'));
683 683
   	$this->assertNull($this->component->asa('FooFooBehavior'));
684 684
   	$this->assertNotNull($this->component->asa('BarBehavior'));
685 685
   	$this->assertNull($this->component->asa('NonExistantBehavior'));
686 686
 
687
-    //Check that the component has the behavior assigned
687
+	//Check that the component has the behavior assigned
688 688
   	$this->assertNull($anothercomponent->asa('FooBehavior'));
689 689
   	$this->assertNull($anothercomponent->asa('FooFooBehavior'));
690 690
   	$this->assertNull($anothercomponent->asa('BarBehavior'));
@@ -692,690 +692,690 @@  discard block
 block discarded – undo
692 692
 
693 693
   	$this->component->detachBehavior('BarBehavior');
694 694
 
695
-    //Check that the component has no object behaviors assigned
695
+	//Check that the component has no object behaviors assigned
696 696
   	$this->assertNull($this->component->asa('FooBehavior'));
697 697
   	$this->assertNull($this->component->asa('FooFooBehavior'));
698 698
   	$this->assertNull($this->component->asa('BarBehavior'));
699 699
   	$this->assertNull($this->component->asa('NonExistantBehavior'));
700 700
 
701
-    //Check that the component has no behavior assigned
701
+	//Check that the component has no behavior assigned
702 702
   	$this->assertNull($anothercomponent->asa('FooBehavior'));
703 703
   	$this->assertNull($anothercomponent->asa('FooFooBehavior'));
704 704
   	$this->assertNull($anothercomponent->asa('BarBehavior'));
705 705
   	$this->assertNull($anothercomponent->asa('NonExistantBehavior'));
706 706
 
707
-    $anothercomponent->unlisten();
707
+	$anothercomponent->unlisten();
708 708
   }
709 709
 
710 710
   public function testIsA() {
711 711
   	//This doesn't check the IInstanceCheck functionality, separate function
712 712
 
713
-    $this->assertTrue($this->component->isa('TComponent'));
714
-    $this->assertTrue($this->component->isa('NewComponent'));
715
-    $this->assertFalse($this->component->isa(new FooBehavior));
716
-    $this->assertFalse($this->component->isa('FooBehavior'));
713
+	$this->assertTrue($this->component->isa('TComponent'));
714
+	$this->assertTrue($this->component->isa('NewComponent'));
715
+	$this->assertFalse($this->component->isa(new FooBehavior));
716
+	$this->assertFalse($this->component->isa('FooBehavior'));
717 717
 
718
-    //Ensure there is no BarBehavior
718
+	//Ensure there is no BarBehavior
719 719
   	$this->assertNull($this->component->asa('FooFooBehavior'));
720 720
 
721
-    $this->assertFalse($this->component->isa('FooBehavior'));
722
-    $this->assertFalse($this->component->isa('FooFooBehavior'));
721
+	$this->assertFalse($this->component->isa('FooBehavior'));
722
+	$this->assertFalse($this->component->isa('FooFooBehavior'));
723 723
 
724 724
   	$this->component->attachBehavior('FooFooBehavior', new FooFooBehavior);
725 725
 
726 726
   	$this->assertNotNull($this->component->asa('FooFooBehavior'));
727 727
 
728
-    $this->assertTrue($this->component->isa('FooBehavior'));
729
-    $this->assertTrue($this->component->isa('FooFooBehavior'));
728
+	$this->assertTrue($this->component->isa('FooBehavior'));
729
+	$this->assertTrue($this->component->isa('FooFooBehavior'));
730 730
 
731 731
 	$this->component->disableBehaviors();
732 732
 	// It still has the behavior
733 733
   	$this->assertNotNull($this->component->asa('FooFooBehavior'));
734 734
 
735 735
   	// But it is not expressed
736
-    $this->assertFalse($this->component->isa('FooBehavior'));
737
-    $this->assertFalse($this->component->isa('FooFooBehavior'));
736
+	$this->assertFalse($this->component->isa('FooBehavior'));
737
+	$this->assertFalse($this->component->isa('FooFooBehavior'));
738 738
 
739 739
 	$this->component->enableBehaviors();
740 740
   	$this->assertNotNull($this->component->asa('FooFooBehavior'));
741 741
 
742
-    $this->assertTrue($this->component->isa('FooFooBehavior'));
742
+	$this->assertTrue($this->component->isa('FooFooBehavior'));
743 743
 
744 744
 
745 745
 
746 746
    	$this->component->attachBehavior('FooBarBehavior', new FooBarBehavior);
747 747
 
748
-    $this->assertTrue($this->component->isa('FooBehavior'));
749
-    $this->assertTrue($this->component->isa('FooBarBehavior'));
748
+	$this->assertTrue($this->component->isa('FooBehavior'));
749
+	$this->assertTrue($this->component->isa('FooBarBehavior'));
750 750
 
751
-    $this->component->disableBehavior('FooBarBehavior');
751
+	$this->component->disableBehavior('FooBarBehavior');
752 752
 
753
-    $this->assertTrue($this->component->isa('FooBehavior'));
754
-    $this->assertFalse($this->component->isa('FooBarBehavior'));
753
+	$this->assertTrue($this->component->isa('FooBehavior'));
754
+	$this->assertFalse($this->component->isa('FooBarBehavior'));
755 755
 
756
-    $this->component->enableBehavior('FooBarBehavior');
757
-    $this->component->disableBehavior('FooFooBehavior');
758
-    $this->assertFalse($this->component->isa('FooBehavior'));
759
-    $this->assertFalse($this->component->isa('FooFooBehavior'));
760
-    $this->assertTrue($this->component->isa('FooBarBehavior'));
756
+	$this->component->enableBehavior('FooBarBehavior');
757
+	$this->component->disableBehavior('FooFooBehavior');
758
+	$this->assertFalse($this->component->isa('FooBehavior'));
759
+	$this->assertFalse($this->component->isa('FooFooBehavior'));
760
+	$this->assertTrue($this->component->isa('FooBarBehavior'));
761 761
 
762
-    $this->component->disableBehavior('FooBarBehavior');
763
-    $this->component->disableBehavior('FooFooBehavior');
762
+	$this->component->disableBehavior('FooBarBehavior');
763
+	$this->component->disableBehavior('FooFooBehavior');
764 764
 
765
-    $this->assertFalse($this->component->isa('FooBehavior'));
766
-    $this->assertFalse($this->component->isa('FooFooBehavior'));
767
-    $this->assertFalse($this->component->isa('FooBarBehavior'));
765
+	$this->assertFalse($this->component->isa('FooBehavior'));
766
+	$this->assertFalse($this->component->isa('FooFooBehavior'));
767
+	$this->assertFalse($this->component->isa('FooBarBehavior'));
768 768
 
769
-    $this->component->enableBehavior('FooBarBehavior');
770
-    $this->component->enableBehavior('FooFooBehavior');
769
+	$this->component->enableBehavior('FooBarBehavior');
770
+	$this->component->enableBehavior('FooFooBehavior');
771 771
 
772
-    $this->assertTrue($this->component->isa('FooFooBehavior'));
773
-    $this->assertTrue($this->component->isa('FooBarBehavior'));
772
+	$this->assertTrue($this->component->isa('FooFooBehavior'));
773
+	$this->assertTrue($this->component->isa('FooBarBehavior'));
774 774
 
775 775
 
776 776
   	$this->component->detachBehavior('FooFooBehavior');
777 777
   	$this->component->detachBehavior('FooBarBehavior');
778 778
 
779
-    $this->assertFalse($this->component->isa(new FooBehavior));
780
-    $this->assertFalse($this->component->isa('FooBehavior'));
781
-    $this->assertFalse($this->component->isa(new FooFooBehavior));
782
-    $this->assertFalse($this->component->isa('FooFooBehavior'));
783
-    $this->assertFalse($this->component->isa(new FooBarBehavior));
784
-    $this->assertFalse($this->component->isa('FooBarBehavior'));
779
+	$this->assertFalse($this->component->isa(new FooBehavior));
780
+	$this->assertFalse($this->component->isa('FooBehavior'));
781
+	$this->assertFalse($this->component->isa(new FooFooBehavior));
782
+	$this->assertFalse($this->component->isa('FooFooBehavior'));
783
+	$this->assertFalse($this->component->isa(new FooBarBehavior));
784
+	$this->assertFalse($this->component->isa('FooBarBehavior'));
785 785
 
786 786
   }
787 787
 
788 788
   public function testIsA_with_IInstanceCheck() {
789 789
 
790
-    $this->assertTrue($this->component->isa('NewComponent'));
791
-    $this->assertFalse($this->component->isa('PreBarBehavior'));
790
+	$this->assertTrue($this->component->isa('NewComponent'));
791
+	$this->assertFalse($this->component->isa('PreBarBehavior'));
792 792
 
793
-    $this->component->attachBehavior('BarBehavior', $behavior = new BarBehavior);
793
+	$this->component->attachBehavior('BarBehavior', $behavior = new BarBehavior);
794 794
 
795
-    $behavior->setInstanceReturn(null);
795
+	$behavior->setInstanceReturn(null);
796 796
 
797
-    $this->assertTrue($this->component->isa('NewComponent'));
798
-    $this->assertTrue($this->component->isa('PreBarBehavior'));
799
-    $this->assertFalse($this->component->isa('FooBehavior'));
797
+	$this->assertTrue($this->component->isa('NewComponent'));
798
+	$this->assertTrue($this->component->isa('PreBarBehavior'));
799
+	$this->assertFalse($this->component->isa('FooBehavior'));
800 800
 
801
-    // This forces the iso on the BarBehavior to respond to any class with false
802
-    $behavior->setInstanceReturn(false);
803
-    $this->assertFalse($this->component->isa('PreBarBehavior'));
804
-    $this->assertFalse($this->component->isa('FooBehavior'));
801
+	// This forces the iso on the BarBehavior to respond to any class with false
802
+	$behavior->setInstanceReturn(false);
803
+	$this->assertFalse($this->component->isa('PreBarBehavior'));
804
+	$this->assertFalse($this->component->isa('FooBehavior'));
805 805
 
806
-    //This forces the isa on the BarBehavior to respond to any class with true
807
-    $behavior->setInstanceReturn(true);
808
-    $this->assertTrue($this->component->isa('FooBehavior'));
806
+	//This forces the isa on the BarBehavior to respond to any class with true
807
+	$behavior->setInstanceReturn(true);
808
+	$this->assertTrue($this->component->isa('FooBehavior'));
809 809
 
810 810
 
811 811
   }
812 812
 
813 813
   public function testAttachDetachBehavior() {
814 814
 
815
-    try {
815
+	try {
816 816
 	  $this->component->faaEverMore(true, true);
817
-      $this->fail('TApplicationException not raised trying to execute a undefined class method');
818
-    } catch(TApplicationException $e) {}
819
-
820
-    $this->assertNull($this->component->asa('FooBehavior'));
821
-    $this->assertFalse($this->component->isa('FooBehavior'));
822
-    $this->assertNull($this->component->asa('BarBehavior'));
823
-    $this->assertFalse($this->component->isa('BarBehavior'));
824
-
825
-    try {
826
-      $this->component->attachBehavior('FooBehavior', new TComponent);
827
-      $this->fail('TApplicationException not raised trying to execute a undefined class method');
828
-    } catch(TInvalidDataTypeException $e) {}
829
-
830
-    $this->component->attachBehavior('FooBehavior', new FooBehavior);
831
-
832
-    $this->assertNotNull($this->component->asa('FooBehavior'));
833
-    $this->assertTrue($this->component->isa('FooBehavior'));
834
-    $this->assertNull($this->component->asa('BarBehavior'));
835
-    $this->assertFalse($this->component->isa('BarBehavior'));
836
-
837
-    try {
838
-	    $this->assertTrue($this->component->faaEverMore(true, true));
839
-    } catch(TApplicationException $e) {
840
-      $this->fail('TApplicationException raised while trying to execute a behavior class method');
841
-    }
817
+	  $this->fail('TApplicationException not raised trying to execute a undefined class method');
818
+	} catch(TApplicationException $e) {}
819
+
820
+	$this->assertNull($this->component->asa('FooBehavior'));
821
+	$this->assertFalse($this->component->isa('FooBehavior'));
822
+	$this->assertNull($this->component->asa('BarBehavior'));
823
+	$this->assertFalse($this->component->isa('BarBehavior'));
824
+
825
+	try {
826
+	  $this->component->attachBehavior('FooBehavior', new TComponent);
827
+	  $this->fail('TApplicationException not raised trying to execute a undefined class method');
828
+	} catch(TInvalidDataTypeException $e) {}
829
+
830
+	$this->component->attachBehavior('FooBehavior', new FooBehavior);
831
+
832
+	$this->assertNotNull($this->component->asa('FooBehavior'));
833
+	$this->assertTrue($this->component->isa('FooBehavior'));
834
+	$this->assertNull($this->component->asa('BarBehavior'));
835
+	$this->assertFalse($this->component->isa('BarBehavior'));
836
+
837
+	try {
838
+		$this->assertTrue($this->component->faaEverMore(true, true));
839
+	} catch(TApplicationException $e) {
840
+	  $this->fail('TApplicationException raised while trying to execute a behavior class method');
841
+	}
842 842
 
843
-    try {
843
+	try {
844 844
 	  $this->component->noMethodHere(true);
845
-      $this->fail('TApplicationException not raised trying to execute a undefined class method');
846
-    } catch(TApplicationException $e) {}
845
+	  $this->fail('TApplicationException not raised trying to execute a undefined class method');
846
+	} catch(TApplicationException $e) {}
847 847
 
848
-    $this->assertTrue($this->component->disableBehavior('FooBehavior'));
848
+	$this->assertTrue($this->component->disableBehavior('FooBehavior'));
849 849
 
850
-    //BarBehavior is not a behavior at this time
851
-    $this->assertNull($this->component->disableBehavior('BarBehavior'));
850
+	//BarBehavior is not a behavior at this time
851
+	$this->assertNull($this->component->disableBehavior('BarBehavior'));
852 852
 
853
-    try {
853
+	try {
854 854
 	  $this->component->faaEverMore(true, true);
855
-      $this->fail('TApplicationException not raised trying to execute a undefined class method');
856
-    } catch(TApplicationException $e) {}
855
+	  $this->fail('TApplicationException not raised trying to execute a undefined class method');
856
+	} catch(TApplicationException $e) {}
857 857
 
858
-    $this->assertTrue($this->component->enableBehavior('FooBehavior'));
858
+	$this->assertTrue($this->component->enableBehavior('FooBehavior'));
859 859
 
860
-    //BarBehavior is not a behavior at this time
861
-    $this->assertNull($this->component->enableBehavior('BarBehavior'));
860
+	//BarBehavior is not a behavior at this time
861
+	$this->assertNull($this->component->enableBehavior('BarBehavior'));
862 862
 
863
-    try {
864
-	    $this->assertTrue($this->component->faaEverMore(true, true));
865
-    } catch(TApplicationException $e) {
866
-      $this->fail('TApplicationException raised while trying to execute a behavior class method');
867
-    }
863
+	try {
864
+		$this->assertTrue($this->component->faaEverMore(true, true));
865
+	} catch(TApplicationException $e) {
866
+	  $this->fail('TApplicationException raised while trying to execute a behavior class method');
867
+	}
868 868
 
869
-    $this->component->detachBehavior('FooBehavior');
869
+	$this->component->detachBehavior('FooBehavior');
870 870
 
871
-    $this->assertNull($this->component->asa('FooBehavior'));
872
-    $this->assertFalse($this->component->isa('FooBehavior'));
873
-    $this->assertNull($this->component->asa('BarBehavior'));
874
-    $this->assertFalse($this->component->isa('BarBehavior'));
871
+	$this->assertNull($this->component->asa('FooBehavior'));
872
+	$this->assertFalse($this->component->isa('FooBehavior'));
873
+	$this->assertNull($this->component->asa('BarBehavior'));
874
+	$this->assertFalse($this->component->isa('BarBehavior'));
875 875
 
876 876
   }
877 877
 
878 878
   public function testAttachDetachBehaviors() {
879
-    $this->assertNull($this->component->asa('FooBehavior'));
880
-    $this->assertNull($this->component->asa('BarBehavior'));
881
-    $this->assertNull($this->component->asa('FooBarBehavior'));
882
-    $this->assertNull($this->component->asa('PreBarBehavior'));
879
+	$this->assertNull($this->component->asa('FooBehavior'));
880
+	$this->assertNull($this->component->asa('BarBehavior'));
881
+	$this->assertNull($this->component->asa('FooBarBehavior'));
882
+	$this->assertNull($this->component->asa('PreBarBehavior'));
883 883
 
884
-    $this->component->attachBehaviors(array('FooFooBehavior' => new FooFooBehavior, 'BarBehavior' => new BarBehavior, 'PreBarBehavior' => new PreBarBehavior));
884
+	$this->component->attachBehaviors(array('FooFooBehavior' => new FooFooBehavior, 'BarBehavior' => new BarBehavior, 'PreBarBehavior' => new PreBarBehavior));
885 885
 
886
-    $this->assertNull($this->component->asa('FooBehavior'));
887
-    $this->assertNotNull($this->component->asa('FooFooBehavior'));
888
-    $this->assertNotNull($this->component->asa('BarBehavior'));
889
-    $this->assertNull($this->component->asa('FooBarBehavior'));
890
-    $this->assertNotNull($this->component->asa('PreBarBehavior'));
886
+	$this->assertNull($this->component->asa('FooBehavior'));
887
+	$this->assertNotNull($this->component->asa('FooFooBehavior'));
888
+	$this->assertNotNull($this->component->asa('BarBehavior'));
889
+	$this->assertNull($this->component->asa('FooBarBehavior'));
890
+	$this->assertNotNull($this->component->asa('PreBarBehavior'));
891 891
 
892
-    $this->assertTrue($this->component->isa('FooFooBehavior'));
893
-    $this->assertTrue($this->component->isa('FooBehavior'));
894
-    $this->assertTrue($this->component->isa('BarBehavior'));
895
-    $this->assertTrue($this->component->isa('PreBarBehavior'));
896
-    $this->assertFalse($this->component->isa('FooBarBehavior'));
892
+	$this->assertTrue($this->component->isa('FooFooBehavior'));
893
+	$this->assertTrue($this->component->isa('FooBehavior'));
894
+	$this->assertTrue($this->component->isa('BarBehavior'));
895
+	$this->assertTrue($this->component->isa('PreBarBehavior'));
896
+	$this->assertFalse($this->component->isa('FooBarBehavior'));
897 897
 
898
-    $this->component->detachBehaviors(array('FooFooBehavior' => new FooFooBehavior, 'BarBehavior' => new BarBehavior));
898
+	$this->component->detachBehaviors(array('FooFooBehavior' => new FooFooBehavior, 'BarBehavior' => new BarBehavior));
899 899
 
900
-    $this->assertNull($this->component->asa('FooBehavior'));
901
-    $this->assertNull($this->component->asa('FooFooBehavior'));
902
-    $this->assertNull($this->component->asa('BarBehavior'));
903
-    $this->assertNull($this->component->asa('FooBarBehavior'));
904
-    $this->assertNotNull($this->component->asa('PreBarBehavior'));
900
+	$this->assertNull($this->component->asa('FooBehavior'));
901
+	$this->assertNull($this->component->asa('FooFooBehavior'));
902
+	$this->assertNull($this->component->asa('BarBehavior'));
903
+	$this->assertNull($this->component->asa('FooBarBehavior'));
904
+	$this->assertNotNull($this->component->asa('PreBarBehavior'));
905 905
 
906
-    $this->assertFalse($this->component->isa('FooFooBehavior'));
907
-    $this->assertFalse($this->component->isa('FooBehavior'));
908
-    $this->assertFalse($this->component->isa('BarBehavior'));
909
-    $this->assertFalse($this->component->isa('FooBarBehavior'));
910
-    $this->assertTrue($this->component->isa('PreBarBehavior'));
906
+	$this->assertFalse($this->component->isa('FooFooBehavior'));
907
+	$this->assertFalse($this->component->isa('FooBehavior'));
908
+	$this->assertFalse($this->component->isa('BarBehavior'));
909
+	$this->assertFalse($this->component->isa('FooBarBehavior'));
910
+	$this->assertTrue($this->component->isa('PreBarBehavior'));
911 911
 
912 912
 
913 913
 
914
-    //	testing if we can detachBehaviors just by the name of the behavior instead of an array of the behavior
915
-    $this->component->attachBehaviors(array('FooFooBehavior' => new FooFooBehavior, 'BarBehavior' => new BarBehavior));
914
+	//	testing if we can detachBehaviors just by the name of the behavior instead of an array of the behavior
915
+	$this->component->attachBehaviors(array('FooFooBehavior' => new FooFooBehavior, 'BarBehavior' => new BarBehavior));
916 916
 
917
-    $this->assertTrue($this->component->isa('FooBehavior'));
918
-    $this->assertTrue($this->component->isa('BarBehavior'));
917
+	$this->assertTrue($this->component->isa('FooBehavior'));
918
+	$this->assertTrue($this->component->isa('BarBehavior'));
919 919
 
920
-    $this->component->detachBehaviors(array('FooFooBehavior', 'BarBehavior'));
920
+	$this->component->detachBehaviors(array('FooFooBehavior', 'BarBehavior'));
921 921
 
922
-    $this->assertNull($this->component->asa('FooBehavior'));
923
-    $this->assertNull($this->component->asa('FooFooBehavior'));
924
-    $this->assertNull($this->component->asa('BarBehavior'));
925
-    $this->assertNull($this->component->asa('FooBarBehavior'));
922
+	$this->assertNull($this->component->asa('FooBehavior'));
923
+	$this->assertNull($this->component->asa('FooFooBehavior'));
924
+	$this->assertNull($this->component->asa('BarBehavior'));
925
+	$this->assertNull($this->component->asa('FooBarBehavior'));
926 926
 
927
-    $this->assertFalse($this->component->isa('FooFooBehavior'));
928
-    $this->assertFalse($this->component->isa('FooBehavior'));
929
-    $this->assertFalse($this->component->isa('BarBehavior'));
930
-    $this->assertFalse($this->component->isa('FooBarBehavior'));
927
+	$this->assertFalse($this->component->isa('FooFooBehavior'));
928
+	$this->assertFalse($this->component->isa('FooBehavior'));
929
+	$this->assertFalse($this->component->isa('BarBehavior'));
930
+	$this->assertFalse($this->component->isa('FooBarBehavior'));
931 931
   }
932 932
 
933 933
 
934 934
   public function testClearBehaviors() {
935 935
 
936
-    $this->assertNull($this->component->asa('FooBehavior'));
937
-    $this->assertNull($this->component->asa('BarBehavior'));
938
-    $this->assertNull($this->component->asa('FooBarBehavior'));
939
-    $this->assertNull($this->component->asa('PreBarBehavior'));
936
+	$this->assertNull($this->component->asa('FooBehavior'));
937
+	$this->assertNull($this->component->asa('BarBehavior'));
938
+	$this->assertNull($this->component->asa('FooBarBehavior'));
939
+	$this->assertNull($this->component->asa('PreBarBehavior'));
940 940
 
941
-    $this->component->attachBehaviors(array('FooFooBehavior' => new FooFooBehavior, 'BarBehavior' => new BarBehavior, 'PreBarBehavior' => new PreBarBehavior));
941
+	$this->component->attachBehaviors(array('FooFooBehavior' => new FooFooBehavior, 'BarBehavior' => new BarBehavior, 'PreBarBehavior' => new PreBarBehavior));
942 942
 
943
-    $this->assertNull($this->component->asa('FooBehavior'));
944
-    $this->assertNotNull($this->component->asa('FooFooBehavior'));
945
-    $this->assertNotNull($this->component->asa('BarBehavior'));
946
-    $this->assertNull($this->component->asa('FooBarBehavior'));
947
-    $this->assertNotNull($this->component->asa('PreBarBehavior'));
943
+	$this->assertNull($this->component->asa('FooBehavior'));
944
+	$this->assertNotNull($this->component->asa('FooFooBehavior'));
945
+	$this->assertNotNull($this->component->asa('BarBehavior'));
946
+	$this->assertNull($this->component->asa('FooBarBehavior'));
947
+	$this->assertNotNull($this->component->asa('PreBarBehavior'));
948 948
 
949
-    $this->component->clearBehaviors();
949
+	$this->component->clearBehaviors();
950 950
 
951
-    $this->assertNull($this->component->asa('FooBehavior'));
952
-    $this->assertNull($this->component->asa('BarBehavior'));
953
-    $this->assertNull($this->component->asa('FooBarBehavior'));
954
-    $this->assertNull($this->component->asa('PreBarBehavior'));
951
+	$this->assertNull($this->component->asa('FooBehavior'));
952
+	$this->assertNull($this->component->asa('BarBehavior'));
953
+	$this->assertNull($this->component->asa('FooBarBehavior'));
954
+	$this->assertNull($this->component->asa('PreBarBehavior'));
955 955
   }
956 956
 
957 957
   public function testEnableDisableBehavior() {
958 958
 
959
-    $this->assertNull($this->component->enableBehavior('FooBehavior'));
960
-    $this->assertNull($this->component->disableBehavior('FooBehavior'));
959
+	$this->assertNull($this->component->enableBehavior('FooBehavior'));
960
+	$this->assertNull($this->component->disableBehavior('FooBehavior'));
961 961
 
962
-    try {
962
+	try {
963 963
 	  $this->component->faaEverMore(true, true);
964
-      $this->fail('TApplicationException not raised trying to execute a undefined class method');
965
-    } catch(TApplicationException $e) {}
964
+	  $this->fail('TApplicationException not raised trying to execute a undefined class method');
965
+	} catch(TApplicationException $e) {}
966 966
 
967
-    $this->component->attachBehavior('FooBehavior', new FooBehavior);
967
+	$this->component->attachBehavior('FooBehavior', new FooBehavior);
968 968
 
969
-    $this->assertTrue($this->component->isa('FooBehavior'));
970
-    try {
971
-	    $this->assertTrue($this->component->faaEverMore(true, true));
972
-    } catch(TApplicationException $e) {
973
-      $this->fail('TApplicationException raised while trying to execute a behavior class method');
974
-    }
969
+	$this->assertTrue($this->component->isa('FooBehavior'));
970
+	try {
971
+		$this->assertTrue($this->component->faaEverMore(true, true));
972
+	} catch(TApplicationException $e) {
973
+	  $this->fail('TApplicationException raised while trying to execute a behavior class method');
974
+	}
975 975
 
976
-    $this->assertTrue($this->component->disableBehavior('FooBehavior'));
976
+	$this->assertTrue($this->component->disableBehavior('FooBehavior'));
977 977
 
978
-    $this->assertFalse($this->component->isa('FooBehavior'));
978
+	$this->assertFalse($this->component->isa('FooBehavior'));
979 979
 
980
-    try {
980
+	try {
981 981
 	  $this->component->faaEverMore(true, true);
982
-      $this->fail('TApplicationException not raised trying to execute a undefined class method');
983
-    } catch(TApplicationException $e) {}
982
+	  $this->fail('TApplicationException not raised trying to execute a undefined class method');
983
+	} catch(TApplicationException $e) {}
984 984
 
985
-    $this->assertTrue($this->component->enableBehavior('FooBehavior'));
985
+	$this->assertTrue($this->component->enableBehavior('FooBehavior'));
986 986
 
987
-    $this->assertTrue($this->component->isa('FooBehavior'));
988
-    try {
989
-	    $this->assertTrue($this->component->faaEverMore(true, true));
990
-    } catch(TApplicationException $e) {
991
-      $this->fail('TApplicationException raised while trying to execute a behavior class method');
992
-    }
987
+	$this->assertTrue($this->component->isa('FooBehavior'));
988
+	try {
989
+		$this->assertTrue($this->component->faaEverMore(true, true));
990
+	} catch(TApplicationException $e) {
991
+	  $this->fail('TApplicationException raised while trying to execute a behavior class method');
992
+	}
993 993
 
994 994
 
995 995
 
996
-    $this->assertNull($this->component->enableBehavior('BarClassBehavior'));
997
-    $this->assertNull($this->component->disableBehavior('BarClassBehavior'));
996
+	$this->assertNull($this->component->enableBehavior('BarClassBehavior'));
997
+	$this->assertNull($this->component->disableBehavior('BarClassBehavior'));
998 998
 
999
-    try {
999
+	try {
1000 1000
 	  $this->component->moreFunction(true, true);
1001
-      $this->fail('TApplicationException not raised trying to execute an undefined class method');
1002
-    } catch(TApplicationException $e) {}
1001
+	  $this->fail('TApplicationException not raised trying to execute an undefined class method');
1002
+	} catch(TApplicationException $e) {}
1003 1003
 
1004
-    $this->component->attachClassBehavior('BarClassBehavior', new BarClassBehavior);
1004
+	$this->component->attachClassBehavior('BarClassBehavior', new BarClassBehavior);
1005 1005
 
1006
-    $this->assertFalse($this->component->enableBehavior('BarClassBehavior'));
1007
-    $this->assertFalse($this->component->disableBehavior('BarClassBehavior'));
1006
+	$this->assertFalse($this->component->enableBehavior('BarClassBehavior'));
1007
+	$this->assertFalse($this->component->disableBehavior('BarClassBehavior'));
1008 1008
 
1009
-    try {
1010
-	    $this->assertTrue($this->component->moreFunction(true, true));
1011
-    } catch(TApplicationException $e) {
1012
-      $this->fail('TApplicationException raised while trying to execute a behavior class method');
1013
-    }
1009
+	try {
1010
+		$this->assertTrue($this->component->moreFunction(true, true));
1011
+	} catch(TApplicationException $e) {
1012
+	  $this->fail('TApplicationException raised while trying to execute a behavior class method');
1013
+	}
1014 1014
 
1015
-    $this->component->detachClassBehavior('BarClassBehavior');
1015
+	$this->component->detachClassBehavior('BarClassBehavior');
1016 1016
   }
1017 1017
 
1018 1018
 
1019 1019
   public function testBehaviorFunctionCalls() {
1020 1020
 
1021
-    $this->component->attachBehavior('FooBarBehavior', $behavior = new FooBarBehavior);
1022
-    $this->component->attachClassBehavior('FooClassBehavior', $classbehavior = new FooClassBehavior);
1021
+	$this->component->attachBehavior('FooBarBehavior', $behavior = new FooBarBehavior);
1022
+	$this->component->attachClassBehavior('FooClassBehavior', $classbehavior = new FooClassBehavior);
1023 1023
 
1024
-    // Test the Class Methods
1025
-    $this->assertEquals(12, $this->component->faaEverMore(3, 4));
1024
+	// Test the Class Methods
1025
+	$this->assertEquals(12, $this->component->faaEverMore(3, 4));
1026 1026
 
1027
-    // Check that the called object is shifted in front of the array of a class behavior call
1028
-    $this->assertEquals($this->component, $this->component->getLastClassObject());
1027
+	// Check that the called object is shifted in front of the array of a class behavior call
1028
+	$this->assertEquals($this->component, $this->component->getLastClassObject());
1029 1029
 
1030 1030
 
1031
-    //Test the FooBarBehavior
1032
-    $this->assertEquals(27, $this->component->moreFunction(3, 3));
1031
+	//Test the FooBarBehavior
1032
+	$this->assertEquals(27, $this->component->moreFunction(3, 3));
1033 1033
 
1034
-    $this->assertTrue($this->component->disableBehavior('FooBarBehavior'));
1035
-    try {
1036
-	    $this->assertNull($this->component->moreFunction(3, 4));
1037
-      	$this->fail('TApplicationException not raised trying to execute a disabled behavior');
1038
-    } catch(TApplicationException $e) {}
1039
-    $this->assertTrue($this->component->enableBehavior('FooBarBehavior'));
1034
+	$this->assertTrue($this->component->disableBehavior('FooBarBehavior'));
1035
+	try {
1036
+		$this->assertNull($this->component->moreFunction(3, 4));
1037
+	  	$this->fail('TApplicationException not raised trying to execute a disabled behavior');
1038
+	} catch(TApplicationException $e) {}
1039
+	$this->assertTrue($this->component->enableBehavior('FooBarBehavior'));
1040 1040
 
1041 1041
 	// Test the global event space, this should work and return false because no function implements these methods
1042
-    $this->assertNull($this->component->fxSomeUndefinedGlobalEvent());
1043
-    $this->assertNull($this->component->dySomeUndefinedIntraObjectEvent());
1042
+	$this->assertNull($this->component->fxSomeUndefinedGlobalEvent());
1043
+	$this->assertNull($this->component->dySomeUndefinedIntraObjectEvent());
1044 1044
 
1045
-    $this->component->detachClassBehavior('FooClassBehavior');
1045
+	$this->component->detachClassBehavior('FooClassBehavior');
1046 1046
 
1047 1047
 
1048 1048
 
1049
-    // test object instance behaviors implemented through class-wide behaviors
1050
-    $this->component->attachClassBehavior('FooFooBehaviorAsClass', 'FooFooBehavior');
1049
+	// test object instance behaviors implemented through class-wide behaviors
1050
+	$this->component->attachClassBehavior('FooFooBehaviorAsClass', 'FooFooBehavior');
1051 1051
 
1052
-    $component = new NewComponent;
1052
+	$component = new NewComponent;
1053 1053
 
1054
-    $this->assertEquals(5, $this->component->faafaaEverMore(3, 4));
1055
-    $this->assertEquals(10, $component->faafaaEverMore(6, 8));
1054
+	$this->assertEquals(5, $this->component->faafaaEverMore(3, 4));
1055
+	$this->assertEquals(10, $component->faafaaEverMore(6, 8));
1056 1056
 
1057
-    $this->component->detachClassBehavior('FooFooBehaviorAsClass');
1058
-    $component->unlisten();
1059
-    $component = null;
1057
+	$this->component->detachClassBehavior('FooFooBehaviorAsClass');
1058
+	$component->unlisten();
1059
+	$component = null;
1060 1060
 
1061
-    try {
1062
-    	$this->component->faafaaEverMore(3, 4);
1063
-      	$this->fail('TApplicationException not raised trying to execute a disabled behavior');
1064
-    } catch(TApplicationException $e) {}
1061
+	try {
1062
+		$this->component->faafaaEverMore(3, 4);
1063
+	  	$this->fail('TApplicationException not raised trying to execute a disabled behavior');
1064
+	} catch(TApplicationException $e) {}
1065 1065
 
1066 1066
 
1067 1067
 
1068
-    // make a call to an unpatched fx and dy call so that it's passed through to the __dycall function
1069
-    $dynamicComponent = new DynamicCallComponent;
1068
+	// make a call to an unpatched fx and dy call so that it's passed through to the __dycall function
1069
+	$dynamicComponent = new DynamicCallComponent;
1070 1070
 
1071
-    $this->assertNull($dynamicComponent->fxUndefinedEvent());
1072
-    $this->assertNull($dynamicComponent->dyUndefinedEvent());
1071
+	$this->assertNull($dynamicComponent->fxUndefinedEvent());
1072
+	$this->assertNull($dynamicComponent->dyUndefinedEvent());
1073 1073
 
1074
-    //This tests the dynamic __dycall function
1075
-    $this->assertEquals(1024, $dynamicComponent->dyPowerFunction(2, 10));
1076
-    $this->assertEquals(5, $dynamicComponent->dyDivisionFunction(10, 2));
1074
+	//This tests the dynamic __dycall function
1075
+	$this->assertEquals(1024, $dynamicComponent->dyPowerFunction(2, 10));
1076
+	$this->assertEquals(5, $dynamicComponent->dyDivisionFunction(10, 2));
1077 1077
 
1078
-    $this->assertEquals(2048, $dynamicComponent->fxPowerFunction(2, 10));
1079
-    $this->assertEquals(10, $dynamicComponent->fxDivisionFunction(10, 2));
1078
+	$this->assertEquals(2048, $dynamicComponent->fxPowerFunction(2, 10));
1079
+	$this->assertEquals(10, $dynamicComponent->fxDivisionFunction(10, 2));
1080 1080
 
1081
-    $dynamicComponent->unlisten();
1081
+	$dynamicComponent->unlisten();
1082 1082
 
1083 1083
   }
1084 1084
 
1085 1085
 
1086 1086
   public function testHasProperty() {
1087
-    $this->assertTrue($this->component->hasProperty('Text'), "Component hasn't property Text");
1088
-    $this->assertTrue($this->component->hasProperty('text'), "Component hasn't property text");
1089
-    $this->assertFalse($this->component->hasProperty('Caption'), "Component has property Caption");
1090
-
1091
-    $this->assertTrue($this->component->hasProperty('ColorAttribute'), "Component hasn't property JsColorAttribute");
1092
-    $this->assertTrue($this->component->hasProperty('colorattribute'), "Component hasn't property JsColorAttribute");
1093
-    $this->assertFalse($this->component->canGetProperty('PastelAttribute'), "Component has property JsPastelAttribute");
1094
-
1095
-    $this->assertTrue($this->component->hasProperty('JSColorAttribute'), "Component hasn't property JsColorAttribute");
1096
-    $this->assertTrue($this->component->hasProperty('jscolorattribute'), "Component hasn't property JsColorAttribute");
1097
-    $this->assertFalse($this->component->hasProperty('jsPastelAttribute'), "Component has property JsPastelAttribute");
1098
-
1099
-    $this->assertFalse($this->component->hasProperty('Excitement'), "Component has property Excitement");
1100
-    $this->component->attachBehavior('ExcitementPropBehavior', new BehaviorTestBehavior);
1101
-    $this->assertTrue($this->component->hasProperty('Excitement'), "Component hasn't property Excitement");
1102
-    $this->component->disableBehaviors();
1103
-    $this->assertFalse($this->component->hasProperty('Excitement'), "Component has property Excitement");
1104
-    $this->component->enableBehaviors();
1105
-    $this->assertTrue($this->component->hasProperty('Excitement'), "Component hasn't property Excitement");
1106
-    $this->component->disableBehavior('ExcitementPropBehavior');
1107
-    $this->assertFalse($this->component->hasProperty('Excitement'), "Component has property Excitement");
1108
-    $this->component->enableBehavior('ExcitementPropBehavior');
1109
-    $this->assertTrue($this->component->hasProperty('Excitement'), "Component hasn't property Excitement");
1110
-
1111
-    $this->component->detachBehavior('ExcitementPropBehavior');
1112
-
1113
-    $this->assertFalse($this->component->hasProperty('Excitement'), "Component has property Excitement");
1087
+	$this->assertTrue($this->component->hasProperty('Text'), "Component hasn't property Text");
1088
+	$this->assertTrue($this->component->hasProperty('text'), "Component hasn't property text");
1089
+	$this->assertFalse($this->component->hasProperty('Caption'), "Component has property Caption");
1090
+
1091
+	$this->assertTrue($this->component->hasProperty('ColorAttribute'), "Component hasn't property JsColorAttribute");
1092
+	$this->assertTrue($this->component->hasProperty('colorattribute'), "Component hasn't property JsColorAttribute");
1093
+	$this->assertFalse($this->component->canGetProperty('PastelAttribute'), "Component has property JsPastelAttribute");
1094
+
1095
+	$this->assertTrue($this->component->hasProperty('JSColorAttribute'), "Component hasn't property JsColorAttribute");
1096
+	$this->assertTrue($this->component->hasProperty('jscolorattribute'), "Component hasn't property JsColorAttribute");
1097
+	$this->assertFalse($this->component->hasProperty('jsPastelAttribute'), "Component has property JsPastelAttribute");
1098
+
1099
+	$this->assertFalse($this->component->hasProperty('Excitement'), "Component has property Excitement");
1100
+	$this->component->attachBehavior('ExcitementPropBehavior', new BehaviorTestBehavior);
1101
+	$this->assertTrue($this->component->hasProperty('Excitement'), "Component hasn't property Excitement");
1102
+	$this->component->disableBehaviors();
1103
+	$this->assertFalse($this->component->hasProperty('Excitement'), "Component has property Excitement");
1104
+	$this->component->enableBehaviors();
1105
+	$this->assertTrue($this->component->hasProperty('Excitement'), "Component hasn't property Excitement");
1106
+	$this->component->disableBehavior('ExcitementPropBehavior');
1107
+	$this->assertFalse($this->component->hasProperty('Excitement'), "Component has property Excitement");
1108
+	$this->component->enableBehavior('ExcitementPropBehavior');
1109
+	$this->assertTrue($this->component->hasProperty('Excitement'), "Component hasn't property Excitement");
1110
+
1111
+	$this->component->detachBehavior('ExcitementPropBehavior');
1112
+
1113
+	$this->assertFalse($this->component->hasProperty('Excitement'), "Component has property Excitement");
1114 1114
 
1115 1115
   }
1116 1116
 
1117 1117
   public function testCanGetProperty() {
1118
-    $this->assertTrue($this->component->canGetProperty('Text'));
1119
-    $this->assertTrue($this->component->canGetProperty('text'));
1120
-    $this->assertFalse($this->component->canGetProperty('Caption'));
1121
-
1122
-    $this->assertTrue($this->component->canGetProperty('ColorAttribute'));
1123
-    $this->assertTrue($this->component->canGetProperty('colorattribute'));
1124
-    $this->assertFalse($this->component->canGetProperty('PastelAttribute'));
1125
-
1126
-    $this->assertTrue($this->component->canGetProperty('JSColorAttribute'));
1127
-    $this->assertTrue($this->component->canGetProperty('jscolorattribute'));
1128
-    $this->assertFalse($this->component->canGetProperty('jsPastelAttribute'));
1129
-
1130
-
1131
-    $this->assertFalse($this->component->canGetProperty('Excitement'), "Component has property Excitement");
1132
-    $this->component->attachBehavior('ExcitementPropBehavior', new BehaviorTestBehavior);
1133
-    $this->assertTrue($this->component->canGetProperty('Excitement'), "Component hasn't property Excitement");
1134
-    $this->component->disableBehaviors();
1135
-    $this->assertFalse($this->component->canGetProperty('Excitement'), "Component has property Excitement");
1136
-    $this->component->enableBehaviors();
1137
-    $this->assertTrue($this->component->canGetProperty('Excitement'), "Component hasn't property Excitement");
1138
-    $this->component->disableBehavior('ExcitementPropBehavior');
1139
-    $this->assertFalse($this->component->canGetProperty('Excitement'), "Component has property Excitement");
1140
-    $this->component->enableBehavior('ExcitementPropBehavior');
1141
-    $this->assertTrue($this->component->canGetProperty('Excitement'), "Component hasn't property Excitement");
1142
-
1143
-    $this->component->detachBehavior('ExcitementPropBehavior');
1144
-
1145
-    $this->assertFalse($this->component->canGetProperty('Excitement'), "Component has property Excitement");
1118
+	$this->assertTrue($this->component->canGetProperty('Text'));
1119
+	$this->assertTrue($this->component->canGetProperty('text'));
1120
+	$this->assertFalse($this->component->canGetProperty('Caption'));
1121
+
1122
+	$this->assertTrue($this->component->canGetProperty('ColorAttribute'));
1123
+	$this->assertTrue($this->component->canGetProperty('colorattribute'));
1124
+	$this->assertFalse($this->component->canGetProperty('PastelAttribute'));
1125
+
1126
+	$this->assertTrue($this->component->canGetProperty('JSColorAttribute'));
1127
+	$this->assertTrue($this->component->canGetProperty('jscolorattribute'));
1128
+	$this->assertFalse($this->component->canGetProperty('jsPastelAttribute'));
1129
+
1130
+
1131
+	$this->assertFalse($this->component->canGetProperty('Excitement'), "Component has property Excitement");
1132
+	$this->component->attachBehavior('ExcitementPropBehavior', new BehaviorTestBehavior);
1133
+	$this->assertTrue($this->component->canGetProperty('Excitement'), "Component hasn't property Excitement");
1134
+	$this->component->disableBehaviors();
1135
+	$this->assertFalse($this->component->canGetProperty('Excitement'), "Component has property Excitement");
1136
+	$this->component->enableBehaviors();
1137
+	$this->assertTrue($this->component->canGetProperty('Excitement'), "Component hasn't property Excitement");
1138
+	$this->component->disableBehavior('ExcitementPropBehavior');
1139
+	$this->assertFalse($this->component->canGetProperty('Excitement'), "Component has property Excitement");
1140
+	$this->component->enableBehavior('ExcitementPropBehavior');
1141
+	$this->assertTrue($this->component->canGetProperty('Excitement'), "Component hasn't property Excitement");
1142
+
1143
+	$this->component->detachBehavior('ExcitementPropBehavior');
1144
+
1145
+	$this->assertFalse($this->component->canGetProperty('Excitement'), "Component has property Excitement");
1146 1146
   }
1147 1147
 
1148 1148
   public function testCanSetProperty() {
1149
-    $this->assertTrue($this->component->canSetProperty('Text'));
1150
-    $this->assertTrue($this->component->canSetProperty('text'));
1151
-    $this->assertFalse($this->component->canSetProperty('Caption'));
1152
-
1153
-    $this->assertTrue($this->component->canSetProperty('ColorAttribute'));
1154
-    $this->assertTrue($this->component->canSetProperty('colorattribute'));
1155
-    $this->assertFalse($this->component->canSetProperty('PastelAttribute'));
1156
-
1157
-    $this->assertTrue($this->component->canSetProperty('JSColorAttribute'));
1158
-    $this->assertTrue($this->component->canSetProperty('jscolorattribute'));
1159
-    $this->assertFalse($this->component->canSetProperty('jsPastelAttribute'));
1160
-
1161
-    $this->assertFalse($this->component->canSetProperty('Excitement'), "Component has property Excitement");
1162
-    $this->component->attachBehavior('ExcitementPropBehavior', new BehaviorTestBehavior);
1163
-    $this->assertTrue($this->component->canSetProperty('Excitement'), "Component hasn't property Excitement");
1164
-    $this->component->disableBehaviors();
1165
-    $this->assertFalse($this->component->canSetProperty('Excitement'), "Component has property Excitement");
1166
-    $this->component->enableBehaviors();
1167
-    $this->assertTrue($this->component->canSetProperty('Excitement'), "Component hasn't property Excitement");
1168
-    $this->component->disableBehavior('ExcitementPropBehavior');
1169
-    $this->assertFalse($this->component->canSetProperty('Excitement'), "Component has property Excitement");
1170
-    $this->component->enableBehavior('ExcitementPropBehavior');
1171
-    $this->assertTrue($this->component->canSetProperty('Excitement'), "Component hasn't property Excitement");
1172
-
1173
-    $this->component->detachBehavior('ExcitementPropBehavior');
1149
+	$this->assertTrue($this->component->canSetProperty('Text'));
1150
+	$this->assertTrue($this->component->canSetProperty('text'));
1151
+	$this->assertFalse($this->component->canSetProperty('Caption'));
1152
+
1153
+	$this->assertTrue($this->component->canSetProperty('ColorAttribute'));
1154
+	$this->assertTrue($this->component->canSetProperty('colorattribute'));
1155
+	$this->assertFalse($this->component->canSetProperty('PastelAttribute'));
1156
+
1157
+	$this->assertTrue($this->component->canSetProperty('JSColorAttribute'));
1158
+	$this->assertTrue($this->component->canSetProperty('jscolorattribute'));
1159
+	$this->assertFalse($this->component->canSetProperty('jsPastelAttribute'));
1160
+
1161
+	$this->assertFalse($this->component->canSetProperty('Excitement'), "Component has property Excitement");
1162
+	$this->component->attachBehavior('ExcitementPropBehavior', new BehaviorTestBehavior);
1163
+	$this->assertTrue($this->component->canSetProperty('Excitement'), "Component hasn't property Excitement");
1164
+	$this->component->disableBehaviors();
1165
+	$this->assertFalse($this->component->canSetProperty('Excitement'), "Component has property Excitement");
1166
+	$this->component->enableBehaviors();
1167
+	$this->assertTrue($this->component->canSetProperty('Excitement'), "Component hasn't property Excitement");
1168
+	$this->component->disableBehavior('ExcitementPropBehavior');
1169
+	$this->assertFalse($this->component->canSetProperty('Excitement'), "Component has property Excitement");
1170
+	$this->component->enableBehavior('ExcitementPropBehavior');
1171
+	$this->assertTrue($this->component->canSetProperty('Excitement'), "Component hasn't property Excitement");
1172
+
1173
+	$this->component->detachBehavior('ExcitementPropBehavior');
1174 1174
   }
1175 1175
 
1176 1176
   public function testGetProperty() {
1177
-    $this->assertTrue('default'===$this->component->Text);
1178
-    try {
1179
-      $value2=$this->component->Caption;
1180
-      $this->fail('exception not raised when getting undefined property');
1181
-    } catch(TInvalidOperationException $e) {
1182
-    }
1177
+	$this->assertTrue('default'===$this->component->Text);
1178
+	try {
1179
+	  $value2=$this->component->Caption;
1180
+	  $this->fail('exception not raised when getting undefined property');
1181
+	} catch(TInvalidOperationException $e) {
1182
+	}
1183 1183
 
1184
-    $this->assertTrue($this->component->OnMyEvent instanceof TPriorityList);
1185
-    try {
1186
-      $value2=$this->component->onUndefinedEvent;
1187
-      $this->fail('exception not raised when getting undefined property');
1188
-    } catch(TInvalidOperationException $e) {
1189
-    }
1184
+	$this->assertTrue($this->component->OnMyEvent instanceof TPriorityList);
1185
+	try {
1186
+	  $value2=$this->component->onUndefinedEvent;
1187
+	  $this->fail('exception not raised when getting undefined property');
1188
+	} catch(TInvalidOperationException $e) {
1189
+	}
1190 1190
 
1191
-    //Without the function parenthesis, the function is _not_ called but the __get
1192
-    //	method is called and the global events (list) are accessed
1193
-    $this->assertTrue($this->component->fxAttachClassBehavior instanceof TPriorityList);
1194
-    $this->assertTrue($this->component->fxDetachClassBehavior instanceof TPriorityList);
1191
+	//Without the function parenthesis, the function is _not_ called but the __get
1192
+	//	method is called and the global events (list) are accessed
1193
+	$this->assertTrue($this->component->fxAttachClassBehavior instanceof TPriorityList);
1194
+	$this->assertTrue($this->component->fxDetachClassBehavior instanceof TPriorityList);
1195 1195
 
1196
-    // even undefined global events have a list as every object is able to access every event
1197
-    $this->assertTrue($this->component->fxUndefinedEvent instanceof TPriorityList);
1196
+	// even undefined global events have a list as every object is able to access every event
1197
+	$this->assertTrue($this->component->fxUndefinedEvent instanceof TPriorityList);
1198 1198
 
1199 1199
 
1200
-    // Test the behaviors within the __get function
1201
-    $this->component->enableBehaviors();
1200
+	// Test the behaviors within the __get function
1201
+	$this->component->enableBehaviors();
1202 1202
 
1203
-    try {
1204
-      $value2=$this->component->Excitement;
1205
-      $this->fail('exception not raised when getting undefined property');
1206
-    } catch(TInvalidOperationException $e) {
1207
-    }
1203
+	try {
1204
+	  $value2=$this->component->Excitement;
1205
+	  $this->fail('exception not raised when getting undefined property');
1206
+	} catch(TInvalidOperationException $e) {
1207
+	}
1208 1208
 
1209
-    $this->component->attachBehavior('BehaviorTestBehavior', $behavior = new BehaviorTestBehavior);
1210
-    $this->assertEquals('faa', $this->component->Excitement);
1209
+	$this->component->attachBehavior('BehaviorTestBehavior', $behavior = new BehaviorTestBehavior);
1210
+	$this->assertEquals('faa', $this->component->Excitement);
1211 1211
 
1212
-    $this->component->disableBehaviors();
1212
+	$this->component->disableBehaviors();
1213 1213
 
1214
-    try {
1215
-      $this->assertEquals('faa', $this->component->Excitement);
1216
-      $this->fail('exception not raised when getting undefined property');
1217
-    } catch(TInvalidOperationException $e) {
1218
-    }
1214
+	try {
1215
+	  $this->assertEquals('faa', $this->component->Excitement);
1216
+	  $this->fail('exception not raised when getting undefined property');
1217
+	} catch(TInvalidOperationException $e) {
1218
+	}
1219 1219
 
1220
-    $this->component->enableBehaviors();
1221
-    $this->assertEquals('faa', $this->component->getExcitement());
1220
+	$this->component->enableBehaviors();
1221
+	$this->assertEquals('faa', $this->component->getExcitement());
1222 1222
 
1223
-    $this->component->disableBehavior('BehaviorTestBehavior');
1223
+	$this->component->disableBehavior('BehaviorTestBehavior');
1224 1224
 
1225
-    $this->assertEquals($behavior, $this->component->BehaviorTestBehavior);
1226
-    try {
1227
-	      $behavior = $this->component->BehaviorTestBehavior2;
1228
-	      $this->fail('exception not raised when getting undefined property');
1229
-	    } catch(TInvalidOperationException $e) {
1230
-    }
1225
+	$this->assertEquals($behavior, $this->component->BehaviorTestBehavior);
1226
+	try {
1227
+		  $behavior = $this->component->BehaviorTestBehavior2;
1228
+		  $this->fail('exception not raised when getting undefined property');
1229
+		} catch(TInvalidOperationException $e) {
1230
+	}
1231 1231
 
1232
-    try {
1233
-      $this->assertEquals('faa', $this->component->Excitement);
1234
-      $this->fail('exception not raised when getting undefined property');
1235
-    } catch(TInvalidOperationException $e) {
1236
-    }
1237
-    $this->component->enableBehavior('BehaviorTestBehavior');
1238
-    $this->assertEquals('faa', $this->component->getExcitement());
1232
+	try {
1233
+	  $this->assertEquals('faa', $this->component->Excitement);
1234
+	  $this->fail('exception not raised when getting undefined property');
1235
+	} catch(TInvalidOperationException $e) {
1236
+	}
1237
+	$this->component->enableBehavior('BehaviorTestBehavior');
1238
+	$this->assertEquals('faa', $this->component->getExcitement());
1239 1239
 
1240 1240
 
1241
-    // behaviors allow on and fx events to be passed through.
1242
-    $this->assertTrue($this->component->onBehaviorEvent instanceof TPriorityList);
1241
+	// behaviors allow on and fx events to be passed through.
1242
+	$this->assertTrue($this->component->onBehaviorEvent instanceof TPriorityList);
1243 1243
 
1244 1244
   }
1245 1245
 
1246 1246
   public function testSetProperty() {
1247
-    $value='new value';
1248
-    $this->component->Text=$value;
1249
-    $text=$this->component->Text;
1250
-    $this->assertTrue($value===$this->component->Text);
1251
-    try {
1252
-      $this->component->NewMember=$value;
1253
-      $this->fail('exception not raised when setting undefined property');
1254
-    } catch(TInvalidOperationException $e) {
1255
-    }
1256
-
1257
-    // Test get only properties is a set function
1258
-    try {
1259
-      $this->component->ReadOnlyProperty = 'setting read only';
1260
-      $this->fail('a property without a set function was set to a new value without error');
1261
-    } catch(TInvalidOperationException $e) {
1262
-    }
1263
-
1264
-    try {
1265
-      $this->component->ReadOnlyJsProperty = 'jssetting read only';
1266
-      $this->fail('a js property without a set function was set to a new value without error');
1267
-    } catch(TInvalidOperationException $e) {
1268
-    }
1269
-
1270
-    try {
1271
-      $this->component->JsReadOnlyJsProperty = 'jssetting read only';
1272
-      $this->fail('a js property without a set function was set to a new value without error');
1273
-    } catch(TInvalidOperationException $e) {
1274
-    }
1275
-
1276
-    $this->assertEquals(0, $this->component->getEventHandlers('onMyEvent')->getCount());
1277
-    $this->component->onMyEvent = array($this->component,'myEventHandler');
1278
-    $this->assertEquals(1, $this->component->getEventHandlers('onMyEvent')->getCount());
1279
-    $this->component->onMyEvent[] = array($this->component,'Object.myEventHandler');
1280
-    $this->assertEquals(2, $this->component->getEventHandlers('onMyEvent')->getCount());
1281
-
1282
-    $this->component->getEventHandlers('onMyEvent')->clear();
1283
-
1284
-    // Test the behaviors within the __get function
1285
-    $this->component->enableBehaviors();
1286
-
1287
-    try {
1288
-      $this->component->Excitement = 'laa';
1289
-      $this->fail('exception not raised when getting undefined property');
1290
-    } catch(TInvalidOperationException $e) {
1291
-    }
1292
-
1293
-    $this->component->attachBehavior('BehaviorTestBehavior', $behavior1 = new BehaviorTestBehavior);
1294
-    $this->component->Excitement = 'laa';
1295
-    $this->assertEquals('laa', $this->component->Excitement);
1296
-    $this->assertEquals('sol', $this->component->Excitement = 'sol');
1297
-
1298
-
1299
-    $this->component->disableBehaviors();
1300
-
1301
-    try {
1302
-      $this->component->Excitement = false;
1303
-      $this->assertEquals(false, $this->component->Excitement);
1304
-      $this->fail('exception not raised when getting undefined property');
1305
-    } catch(TInvalidOperationException $e) {
1306
-    }
1307
-
1308
-    $this->component->enableBehaviors();
1309
-    $this->component->Excitement = 'faa';
1310
-    $this->assertEquals('faa', $this->component->getExcitement());
1311
-
1312
-    $this->component->disableBehavior('BehaviorTestBehavior');
1313
-
1314
-    try {
1315
-      $this->component->Excitement = false;
1316
-      $this->assertEquals(false, $this->component->Excitement);
1317
-      $this->fail('exception not raised when getting undefined property');
1318
-    } catch(TInvalidOperationException $e) {
1319
-    }
1320
-    $this->component->enableBehavior('BehaviorTestBehavior');
1321
-    $this->component->Excitement = 'sol';
1322
-    $this->assertEquals('sol', $this->component->Excitement);
1323
-
1324
-
1325
-    $this->component->attachBehavior('BehaviorTestBehavior2', $behavior2 = new BehaviorTestBehavior);
1326
-
1327
-    $this->assertEquals('sol', $this->component->Excitement);
1328
-    $this->assertEquals('faa', $behavior2->Excitement);
1329
-
1330
-    // this sets Excitement for both because they are not uniquely named
1331
-    $this->component->Excitement = 'befaad';
1332
-
1333
-    $this->assertEquals('befaad', $this->component->Excitement);
1334
-    $this->assertEquals('befaad', $behavior1->Excitement);
1335
-    $this->assertEquals('befaad', $behavior2->Excitement);
1336
-
1337
-
1338
-    $this->component->detachBehavior('BehaviorTestBehavior2');
1339
-
1340
-    // behaviors allow on and fx events to be passed through.
1341
-    $this->assertTrue($this->component->BehaviorTestBehavior->onBehaviorEvent instanceof TPriorityList);
1342
-
1343
-    $this->assertEquals(0, $this->component->BehaviorTestBehavior->getEventHandlers('onBehaviorEvent')->getCount());
1344
-    $this->component->onBehaviorEvent = array($this->component,'myEventHandler');
1345
-    $this->assertEquals(1, $this->component->BehaviorTestBehavior->getEventHandlers('onBehaviorEvent')->getCount());
1346
-    $this->component->onBehaviorEvent[] = array($this->component,'Object.myEventHandler');
1347
-    $this->assertEquals(2, $this->component->BehaviorTestBehavior->getEventHandlers('onBehaviorEvent')->getCount());
1348
-
1349
-    $this->component->BehaviorTestBehavior->getEventHandlers('onBehaviorEvent')->clear();
1247
+	$value='new value';
1248
+	$this->component->Text=$value;
1249
+	$text=$this->component->Text;
1250
+	$this->assertTrue($value===$this->component->Text);
1251
+	try {
1252
+	  $this->component->NewMember=$value;
1253
+	  $this->fail('exception not raised when setting undefined property');
1254
+	} catch(TInvalidOperationException $e) {
1255
+	}
1256
+
1257
+	// Test get only properties is a set function
1258
+	try {
1259
+	  $this->component->ReadOnlyProperty = 'setting read only';
1260
+	  $this->fail('a property without a set function was set to a new value without error');
1261
+	} catch(TInvalidOperationException $e) {
1262
+	}
1263
+
1264
+	try {
1265
+	  $this->component->ReadOnlyJsProperty = 'jssetting read only';
1266
+	  $this->fail('a js property without a set function was set to a new value without error');
1267
+	} catch(TInvalidOperationException $e) {
1268
+	}
1269
+
1270
+	try {
1271
+	  $this->component->JsReadOnlyJsProperty = 'jssetting read only';
1272
+	  $this->fail('a js property without a set function was set to a new value without error');
1273
+	} catch(TInvalidOperationException $e) {
1274
+	}
1275
+
1276
+	$this->assertEquals(0, $this->component->getEventHandlers('onMyEvent')->getCount());
1277
+	$this->component->onMyEvent = array($this->component,'myEventHandler');
1278
+	$this->assertEquals(1, $this->component->getEventHandlers('onMyEvent')->getCount());
1279
+	$this->component->onMyEvent[] = array($this->component,'Object.myEventHandler');
1280
+	$this->assertEquals(2, $this->component->getEventHandlers('onMyEvent')->getCount());
1281
+
1282
+	$this->component->getEventHandlers('onMyEvent')->clear();
1283
+
1284
+	// Test the behaviors within the __get function
1285
+	$this->component->enableBehaviors();
1286
+
1287
+	try {
1288
+	  $this->component->Excitement = 'laa';
1289
+	  $this->fail('exception not raised when getting undefined property');
1290
+	} catch(TInvalidOperationException $e) {
1291
+	}
1292
+
1293
+	$this->component->attachBehavior('BehaviorTestBehavior', $behavior1 = new BehaviorTestBehavior);
1294
+	$this->component->Excitement = 'laa';
1295
+	$this->assertEquals('laa', $this->component->Excitement);
1296
+	$this->assertEquals('sol', $this->component->Excitement = 'sol');
1297
+
1298
+
1299
+	$this->component->disableBehaviors();
1300
+
1301
+	try {
1302
+	  $this->component->Excitement = false;
1303
+	  $this->assertEquals(false, $this->component->Excitement);
1304
+	  $this->fail('exception not raised when getting undefined property');
1305
+	} catch(TInvalidOperationException $e) {
1306
+	}
1307
+
1308
+	$this->component->enableBehaviors();
1309
+	$this->component->Excitement = 'faa';
1310
+	$this->assertEquals('faa', $this->component->getExcitement());
1311
+
1312
+	$this->component->disableBehavior('BehaviorTestBehavior');
1313
+
1314
+	try {
1315
+	  $this->component->Excitement = false;
1316
+	  $this->assertEquals(false, $this->component->Excitement);
1317
+	  $this->fail('exception not raised when getting undefined property');
1318
+	} catch(TInvalidOperationException $e) {
1319
+	}
1320
+	$this->component->enableBehavior('BehaviorTestBehavior');
1321
+	$this->component->Excitement = 'sol';
1322
+	$this->assertEquals('sol', $this->component->Excitement);
1323
+
1324
+
1325
+	$this->component->attachBehavior('BehaviorTestBehavior2', $behavior2 = new BehaviorTestBehavior);
1326
+
1327
+	$this->assertEquals('sol', $this->component->Excitement);
1328
+	$this->assertEquals('faa', $behavior2->Excitement);
1329
+
1330
+	// this sets Excitement for both because they are not uniquely named
1331
+	$this->component->Excitement = 'befaad';
1332
+
1333
+	$this->assertEquals('befaad', $this->component->Excitement);
1334
+	$this->assertEquals('befaad', $behavior1->Excitement);
1335
+	$this->assertEquals('befaad', $behavior2->Excitement);
1336
+
1337
+
1338
+	$this->component->detachBehavior('BehaviorTestBehavior2');
1339
+
1340
+	// behaviors allow on and fx events to be passed through.
1341
+	$this->assertTrue($this->component->BehaviorTestBehavior->onBehaviorEvent instanceof TPriorityList);
1342
+
1343
+	$this->assertEquals(0, $this->component->BehaviorTestBehavior->getEventHandlers('onBehaviorEvent')->getCount());
1344
+	$this->component->onBehaviorEvent = array($this->component,'myEventHandler');
1345
+	$this->assertEquals(1, $this->component->BehaviorTestBehavior->getEventHandlers('onBehaviorEvent')->getCount());
1346
+	$this->component->onBehaviorEvent[] = array($this->component,'Object.myEventHandler');
1347
+	$this->assertEquals(2, $this->component->BehaviorTestBehavior->getEventHandlers('onBehaviorEvent')->getCount());
1348
+
1349
+	$this->component->BehaviorTestBehavior->getEventHandlers('onBehaviorEvent')->clear();
1350 1350
   }
1351 1351
 
1352 1352
 
1353 1353
   public function testIsSetFunction() {
1354
-    $this->assertTrue(isset($this->component->fxAttachClassBehavior));
1355
-    $this->component->unlisten();
1354
+	$this->assertTrue(isset($this->component->fxAttachClassBehavior));
1355
+	$this->component->unlisten();
1356 1356
 
1357
-    $this->assertFalse(isset($this->component->onMyEvent));
1358
-    $this->assertFalse(isset($this->component->undefinedEvent));
1359
-    $this->assertFalse(isset($this->component->fxAttachClassBehavior));
1357
+	$this->assertFalse(isset($this->component->onMyEvent));
1358
+	$this->assertFalse(isset($this->component->undefinedEvent));
1359
+	$this->assertFalse(isset($this->component->fxAttachClassBehavior));
1360 1360
 
1361
-    $this->assertFalse(isset($this->component->BehaviorTestBehavior));
1362
-    $this->assertFalse(isset($this->component->onBehaviorEvent));
1361
+	$this->assertFalse(isset($this->component->BehaviorTestBehavior));
1362
+	$this->assertFalse(isset($this->component->onBehaviorEvent));
1363 1363
 
1364
-    $this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1364
+	$this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1365 1365
 
1366
-    $this->assertTrue(isset($this->component->BehaviorTestBehavior));
1367
-    $this->assertFalse(isset($this->component->onBehaviorEvent));
1366
+	$this->assertTrue(isset($this->component->BehaviorTestBehavior));
1367
+	$this->assertFalse(isset($this->component->onBehaviorEvent));
1368 1368
 
1369
-    $this->component->attachEventHandler('onBehaviorEvent','foo');
1370
-    $this->assertTrue(isset($this->component->onBehaviorEvent));
1369
+	$this->component->attachEventHandler('onBehaviorEvent','foo');
1370
+	$this->assertTrue(isset($this->component->onBehaviorEvent));
1371 1371
 
1372
-    $this->component->attachEventHandler('onMyEvent','foo');
1373
-    $this->assertTrue(isset($this->component->onMyEvent));
1372
+	$this->component->attachEventHandler('onMyEvent','foo');
1373
+	$this->assertTrue(isset($this->component->onMyEvent));
1374 1374
 
1375
-    $this->assertTrue(isset($this->component->Excitement));
1376
-    $this->component->Excitement = null;
1377
-    $this->assertFalse(isset($this->component->Excitement));
1378
-    $this->assertFalse(isset($this->component->UndefinedBehaviorProperty));
1375
+	$this->assertTrue(isset($this->component->Excitement));
1376
+	$this->component->Excitement = null;
1377
+	$this->assertFalse(isset($this->component->Excitement));
1378
+	$this->assertFalse(isset($this->component->UndefinedBehaviorProperty));
1379 1379
 
1380 1380
 
1381 1381
   }
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
 
1392 1392
  	// object events
1393 1393
  	$this->assertEquals(0, $this->component->onMyEvent->Count);
1394
-    $this->component->attachEventHandler('onMyEvent','foo');
1394
+	$this->component->attachEventHandler('onMyEvent','foo');
1395 1395
  	$this->assertEquals(1, $this->component->onMyEvent->Count);
1396 1396
  	unset($this->component->onMyEvent);
1397 1397
  	$this->assertEquals(0, $this->component->onMyEvent->Count);
@@ -1407,10 +1407,10 @@  discard block
 block discarded – undo
1407 1407
 
1408 1408
   	try {
1409 1409
 	  	unset($this->component->Object);
1410
-    	$this->fail('TInvalidOperationException not raised when unsetting get only property');
1410
+		$this->fail('TInvalidOperationException not raised when unsetting get only property');
1411 1411
   	} catch(TInvalidOperationException $e) {}
1412 1412
 
1413
-    $this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1413
+	$this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1414 1414
  	$this->assertTrue($this->component->asa('BehaviorTestBehavior') instanceof BehaviorTestBehavior);
1415 1415
  	$this->assertFalse($this->component->asa('BehaviorTestBehavior2') instanceof BehaviorTestBehavior);
1416 1416
 
@@ -1436,7 +1436,7 @@  discard block
 block discarded – undo
1436 1436
 
1437 1437
   	try {
1438 1438
 	  	unset($this->component->ReadOnly);
1439
-    	$this->fail('TInvalidOperationException not raised when unsetting get only property');
1439
+		$this->fail('TInvalidOperationException not raised when unsetting get only property');
1440 1440
   	} catch(TInvalidOperationException $e) {}
1441 1441
 
1442 1442
   	$this->component->onBehaviorEvent = 'foo';
@@ -1453,338 +1453,338 @@  discard block
 block discarded – undo
1453 1453
   }
1454 1454
 
1455 1455
   public function testGetSubProperty() {
1456
-    $this->assertTrue('object text'===$this->component->getSubProperty('Object.Text'));
1456
+	$this->assertTrue('object text'===$this->component->getSubProperty('Object.Text'));
1457 1457
   }
1458 1458
 
1459 1459
   public function testSetSubProperty() {
1460
-    $this->component->setSubProperty('Object.Text','new object text');
1461
-    $this->assertEquals('new object text',$this->component->getSubProperty('Object.Text'));
1460
+	$this->component->setSubProperty('Object.Text','new object text');
1461
+	$this->assertEquals('new object text',$this->component->getSubProperty('Object.Text'));
1462 1462
   }
1463 1463
 
1464 1464
   public function testHasEvent() {
1465
-    $this->assertTrue($this->component->hasEvent('OnMyEvent'));
1466
-    $this->assertTrue($this->component->hasEvent('onmyevent'));
1467
-    $this->assertFalse($this->component->hasEvent('onYourEvent'));
1465
+	$this->assertTrue($this->component->hasEvent('OnMyEvent'));
1466
+	$this->assertTrue($this->component->hasEvent('onmyevent'));
1467
+	$this->assertFalse($this->component->hasEvent('onYourEvent'));
1468 1468
 
1469
-    // fx won't throw an error if any of these fx function are called on an object.
1470
-    //	It is a special prefix event designation that every object responds to all events.
1471
-    $this->assertTrue($this->component->hasEvent('fxAttachClassBehavior'));
1472
-    $this->assertTrue($this->component->hasEvent('fxattachclassbehavior'));
1469
+	// fx won't throw an error if any of these fx function are called on an object.
1470
+	//	It is a special prefix event designation that every object responds to all events.
1471
+	$this->assertTrue($this->component->hasEvent('fxAttachClassBehavior'));
1472
+	$this->assertTrue($this->component->hasEvent('fxattachclassbehavior'));
1473 1473
 
1474
-    $this->assertTrue($this->component->hasEvent('fxNonExistantGlobalEvent'));
1475
-    $this->assertTrue($this->component->hasEvent('fxnonexistantglobalevent'));
1474
+	$this->assertTrue($this->component->hasEvent('fxNonExistantGlobalEvent'));
1475
+	$this->assertTrue($this->component->hasEvent('fxnonexistantglobalevent'));
1476 1476
 
1477
-    $this->assertTrue($this->component->hasEvent('dyNonExistantLocalEvent'));
1478
-    $this->assertTrue($this->component->hasEvent('fxnonexistantlocalevent'));
1477
+	$this->assertTrue($this->component->hasEvent('dyNonExistantLocalEvent'));
1478
+	$this->assertTrue($this->component->hasEvent('fxnonexistantlocalevent'));
1479 1479
 
1480 1480
 
1481
-    //Test behavior events
1482
-    $this->assertFalse($this->component->hasEvent('onBehaviorEvent'));
1483
-    $this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1484
-    $this->assertTrue($this->component->hasEvent('onBehaviorEvent'));
1485
-    $this->assertTrue($this->component->BehaviorTestBehavior->hasEvent('onBehaviorEvent'));
1481
+	//Test behavior events
1482
+	$this->assertFalse($this->component->hasEvent('onBehaviorEvent'));
1483
+	$this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1484
+	$this->assertTrue($this->component->hasEvent('onBehaviorEvent'));
1485
+	$this->assertTrue($this->component->BehaviorTestBehavior->hasEvent('onBehaviorEvent'));
1486 1486
 
1487
-    $this->component->disableBehavior('BehaviorTestBehavior');
1488
-    $this->assertFalse($this->component->hasEvent('onBehaviorEvent'));
1489
-    $this->component->enableBehavior('BehaviorTestBehavior');
1490
-    $this->assertTrue($this->component->hasEvent('onBehaviorEvent'));
1487
+	$this->component->disableBehavior('BehaviorTestBehavior');
1488
+	$this->assertFalse($this->component->hasEvent('onBehaviorEvent'));
1489
+	$this->component->enableBehavior('BehaviorTestBehavior');
1490
+	$this->assertTrue($this->component->hasEvent('onBehaviorEvent'));
1491 1491
   }
1492 1492
 
1493 1493
   public function testHasEventHandler() {
1494
-    $this->assertFalse($this->component->hasEventHandler('OnMyEvent'));
1495
-    $this->component->attachEventHandler('OnMyEvent','foo');
1496
-    $this->assertTrue($this->component->hasEventHandler('OnMyEvent'));
1497
-
1498
-    $this->assertFalse($this->component->hasEventHandler('fxNonExistantGlobalEvent'));
1499
-    $this->component->attachEventHandler('fxNonExistantGlobalEvent','foo');
1500
-    $this->assertTrue($this->component->hasEventHandler('fxNonExistantGlobalEvent'));
1501
-
1502
-    //Test behavior events
1503
-    $this->assertFalse($this->component->hasEventHandler('onBehaviorEvent'));
1504
-    $this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1505
-    $this->assertFalse($this->component->hasEventHandler('onBehaviorEvent'));
1506
-    $this->assertFalse($this->component->BehaviorTestBehavior->hasEventHandler('onBehaviorEvent'));
1507
-
1508
-    $this->component->attachEventHandler('onBehaviorEvent','foo');
1509
-    $this->assertTrue($this->component->hasEventHandler('onBehaviorEvent'));
1510
-
1511
-    $this->component->disableBehavior('BehaviorTestBehavior');
1512
-    $this->assertFalse($this->component->hasEvent('onBehaviorEvent'));
1513
-    $this->assertFalse($this->component->hasEventHandler('onBehaviorEvent'));
1514
-    $this->component->enableBehavior('BehaviorTestBehavior');
1515
-    $this->assertTrue($this->component->hasEvent('onBehaviorEvent'));
1516
-    $this->assertTrue($this->component->hasEventHandler('onBehaviorEvent'));
1494
+	$this->assertFalse($this->component->hasEventHandler('OnMyEvent'));
1495
+	$this->component->attachEventHandler('OnMyEvent','foo');
1496
+	$this->assertTrue($this->component->hasEventHandler('OnMyEvent'));
1497
+
1498
+	$this->assertFalse($this->component->hasEventHandler('fxNonExistantGlobalEvent'));
1499
+	$this->component->attachEventHandler('fxNonExistantGlobalEvent','foo');
1500
+	$this->assertTrue($this->component->hasEventHandler('fxNonExistantGlobalEvent'));
1501
+
1502
+	//Test behavior events
1503
+	$this->assertFalse($this->component->hasEventHandler('onBehaviorEvent'));
1504
+	$this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1505
+	$this->assertFalse($this->component->hasEventHandler('onBehaviorEvent'));
1506
+	$this->assertFalse($this->component->BehaviorTestBehavior->hasEventHandler('onBehaviorEvent'));
1507
+
1508
+	$this->component->attachEventHandler('onBehaviorEvent','foo');
1509
+	$this->assertTrue($this->component->hasEventHandler('onBehaviorEvent'));
1510
+
1511
+	$this->component->disableBehavior('BehaviorTestBehavior');
1512
+	$this->assertFalse($this->component->hasEvent('onBehaviorEvent'));
1513
+	$this->assertFalse($this->component->hasEventHandler('onBehaviorEvent'));
1514
+	$this->component->enableBehavior('BehaviorTestBehavior');
1515
+	$this->assertTrue($this->component->hasEvent('onBehaviorEvent'));
1516
+	$this->assertTrue($this->component->hasEventHandler('onBehaviorEvent'));
1517 1517
   }
1518 1518
 
1519 1519
   public function testGetEventHandlers() {
1520
-    $list=$this->component->getEventHandlers('OnMyEvent');
1521
-    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===0));
1522
-    $this->component->attachEventHandler('OnMyEvent','foo');
1523
-    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===1));
1524
-    try {
1525
-      $list=$this->component->getEventHandlers('YourEvent');
1526
-      $this->fail('exception not raised when getting event handlers for undefined event');
1527
-    } catch(TInvalidOperationException $e) {
1528
-    }
1529
-
1530
-    $list=$this->component->getEventHandlers('fxRandomEvent');
1531
-    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===0));
1532
-    $this->component->attachEventHandler('fxRandomEvent','foo');
1533
-    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===1));
1534
-    try {
1535
-      $list=$this->component->getEventHandlers('fxSomeUndefinedGlobalEvent');
1536
-    } catch(TInvalidOperationException $e) {
1537
-      $this->fail('exception raised when getting event handlers for universal global event');
1538
-    }
1539
-
1540
-
1541
-
1542
-    //Test behavior events
1543
-    try {
1544
-      $list=$this->component->getEventHandlers('onBehaviorEvent');
1545
-      $this->fail('exception not raised when getting event handlers for undefined event');
1546
-    } catch(TInvalidOperationException $e) {
1547
-    }
1548
-    $this->assertFalse($this->component->hasEventHandler('onBehaviorEvent'));
1549
-
1550
-    $this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1551
-    $list=$this->component->getEventHandlers('onBehaviorEvent');
1552
-    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===0));
1553
-    $this->component->attachEventHandler('onBehaviorEvent','foo');
1554
-    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===1));
1555
-
1556
-    $this->component->disableBehavior('BehaviorTestBehavior');
1557
-    try {
1558
-      $list=$this->component->getEventHandlers('onBehaviorEvent');
1559
-      $this->fail('exception not raised when getting event handlers for undefined event');
1560
-    } catch(TInvalidOperationException $e) {
1561
-    }
1562
-    $this->component->enableBehavior('BehaviorTestBehavior');
1563
-    $this->assertTrue(($this->component->getEventHandlers('onBehaviorEvent') instanceof TPriorityList) && ($list->getCount()===1));
1520
+	$list=$this->component->getEventHandlers('OnMyEvent');
1521
+	$this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===0));
1522
+	$this->component->attachEventHandler('OnMyEvent','foo');
1523
+	$this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===1));
1524
+	try {
1525
+	  $list=$this->component->getEventHandlers('YourEvent');
1526
+	  $this->fail('exception not raised when getting event handlers for undefined event');
1527
+	} catch(TInvalidOperationException $e) {
1528
+	}
1529
+
1530
+	$list=$this->component->getEventHandlers('fxRandomEvent');
1531
+	$this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===0));
1532
+	$this->component->attachEventHandler('fxRandomEvent','foo');
1533
+	$this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===1));
1534
+	try {
1535
+	  $list=$this->component->getEventHandlers('fxSomeUndefinedGlobalEvent');
1536
+	} catch(TInvalidOperationException $e) {
1537
+	  $this->fail('exception raised when getting event handlers for universal global event');
1538
+	}
1539
+
1540
+
1541
+
1542
+	//Test behavior events
1543
+	try {
1544
+	  $list=$this->component->getEventHandlers('onBehaviorEvent');
1545
+	  $this->fail('exception not raised when getting event handlers for undefined event');
1546
+	} catch(TInvalidOperationException $e) {
1547
+	}
1548
+	$this->assertFalse($this->component->hasEventHandler('onBehaviorEvent'));
1549
+
1550
+	$this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1551
+	$list=$this->component->getEventHandlers('onBehaviorEvent');
1552
+	$this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===0));
1553
+	$this->component->attachEventHandler('onBehaviorEvent','foo');
1554
+	$this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===1));
1555
+
1556
+	$this->component->disableBehavior('BehaviorTestBehavior');
1557
+	try {
1558
+	  $list=$this->component->getEventHandlers('onBehaviorEvent');
1559
+	  $this->fail('exception not raised when getting event handlers for undefined event');
1560
+	} catch(TInvalidOperationException $e) {
1561
+	}
1562
+	$this->component->enableBehavior('BehaviorTestBehavior');
1563
+	$this->assertTrue(($this->component->getEventHandlers('onBehaviorEvent') instanceof TPriorityList) && ($list->getCount()===1));
1564 1564
 
1565 1565
   }
1566 1566
 
1567 1567
   public function testAttachEventHandler() {
1568 1568
 
1569
-    $this->component->attachEventHandler('OnMyEvent','foo');
1570
-    $this->assertEquals(1, $this->component->getEventHandlers('OnMyEvent')->getCount());
1571
-    try {
1572
-      $this->component->attachEventHandler('YourEvent','foo');
1573
-      $this->fail('exception not raised when attaching event handlers for undefined event');
1574
-    } catch(TInvalidOperationException $e) {
1575
-    }
1576
-
1577
-    //Testing the priorities of attaching events
1578
-    $this->component->attachEventHandler('OnMyEvent','foopre', 5);
1579
-    $this->component->attachEventHandler('OnMyEvent','foopost', 15);
1580
-    $this->component->attachEventHandler('OnMyEvent','foobar', 10);
1581
-    $this->assertEquals(4, $this->component->getEventHandlers('OnMyEvent')->getCount());
1582
-    $list = $this->component->getEventHandlers('OnMyEvent');
1583
-    $this->assertEquals('foopre', $list[0]);
1584
-    $this->assertEquals('foo', $list[1]);
1585
-    $this->assertEquals('foobar', $list[2]);
1586
-    $this->assertEquals('foopost', $list[3]);
1587
-
1588
-
1589
-    //Test attaching behavior events
1590
-    try {
1591
-      $this->component->attachEventHandler('onBehaviorEvent','foo');
1592
-      $this->fail('exception not raised when getting event handlers for undefined event');
1593
-    } catch(TInvalidOperationException $e) {
1594
-    }
1595
-    $this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1596
-
1597
-    $this->component->attachEventHandler('onBehaviorEvent','foo');
1598
-
1599
-    //Testing the priorities of attaching behavior events
1600
-    $this->component->attachEventHandler('onBehaviorEvent','foopre', 5);
1601
-    $this->component->attachEventHandler('onBehaviorEvent','foopost', 15);
1602
-    $this->component->attachEventHandler('onBehaviorEvent','foobar', 10);
1603
-    $this->component->attachEventHandler('onBehaviorEvent','foobarfoobar', 10);
1604
-    $this->assertEquals(5, $this->component->getEventHandlers('onBehaviorEvent')->getCount());
1605
-    $list = $this->component->getEventHandlers('onBehaviorEvent');
1606
-    $this->assertEquals('foopre', $list[0]);
1607
-    $this->assertEquals('foo', $list[1]);
1608
-    $this->assertEquals('foobar', $list[2]);
1609
-    $this->assertEquals('foobarfoobar', $list[3]);
1610
-    $this->assertEquals('foopost', $list[4]);
1611
-
1612
-    $this->component->disableBehavior('BehaviorTestBehavior');
1613
-    try {
1614
-      $this->component->attachEventHandler('onBehaviorEvent','bar');
1615
-      $this->fail('exception not raised when getting event handlers for undefined event');
1616
-    } catch(TInvalidOperationException $e) {
1617
-    }
1618
-    $this->component->enableBehavior('BehaviorTestBehavior');
1569
+	$this->component->attachEventHandler('OnMyEvent','foo');
1570
+	$this->assertEquals(1, $this->component->getEventHandlers('OnMyEvent')->getCount());
1571
+	try {
1572
+	  $this->component->attachEventHandler('YourEvent','foo');
1573
+	  $this->fail('exception not raised when attaching event handlers for undefined event');
1574
+	} catch(TInvalidOperationException $e) {
1575
+	}
1576
+
1577
+	//Testing the priorities of attaching events
1578
+	$this->component->attachEventHandler('OnMyEvent','foopre', 5);
1579
+	$this->component->attachEventHandler('OnMyEvent','foopost', 15);
1580
+	$this->component->attachEventHandler('OnMyEvent','foobar', 10);
1581
+	$this->assertEquals(4, $this->component->getEventHandlers('OnMyEvent')->getCount());
1582
+	$list = $this->component->getEventHandlers('OnMyEvent');
1583
+	$this->assertEquals('foopre', $list[0]);
1584
+	$this->assertEquals('foo', $list[1]);
1585
+	$this->assertEquals('foobar', $list[2]);
1586
+	$this->assertEquals('foopost', $list[3]);
1587
+
1588
+
1589
+	//Test attaching behavior events
1590
+	try {
1591
+	  $this->component->attachEventHandler('onBehaviorEvent','foo');
1592
+	  $this->fail('exception not raised when getting event handlers for undefined event');
1593
+	} catch(TInvalidOperationException $e) {
1594
+	}
1595
+	$this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1596
+
1597
+	$this->component->attachEventHandler('onBehaviorEvent','foo');
1598
+
1599
+	//Testing the priorities of attaching behavior events
1600
+	$this->component->attachEventHandler('onBehaviorEvent','foopre', 5);
1601
+	$this->component->attachEventHandler('onBehaviorEvent','foopost', 15);
1602
+	$this->component->attachEventHandler('onBehaviorEvent','foobar', 10);
1603
+	$this->component->attachEventHandler('onBehaviorEvent','foobarfoobar', 10);
1604
+	$this->assertEquals(5, $this->component->getEventHandlers('onBehaviorEvent')->getCount());
1605
+	$list = $this->component->getEventHandlers('onBehaviorEvent');
1606
+	$this->assertEquals('foopre', $list[0]);
1607
+	$this->assertEquals('foo', $list[1]);
1608
+	$this->assertEquals('foobar', $list[2]);
1609
+	$this->assertEquals('foobarfoobar', $list[3]);
1610
+	$this->assertEquals('foopost', $list[4]);
1611
+
1612
+	$this->component->disableBehavior('BehaviorTestBehavior');
1613
+	try {
1614
+	  $this->component->attachEventHandler('onBehaviorEvent','bar');
1615
+	  $this->fail('exception not raised when getting event handlers for undefined event');
1616
+	} catch(TInvalidOperationException $e) {
1617
+	}
1618
+	$this->component->enableBehavior('BehaviorTestBehavior');
1619 1619
 
1620 1620
   }
1621 1621
 
1622 1622
   public function testDetachEventHandler() {
1623 1623
 
1624
-    $this->component->attachEventHandler('OnMyEvent','foo');
1625
-    $this->assertEquals(1, $this->component->getEventHandlers('OnMyEvent')->getCount());
1624
+	$this->component->attachEventHandler('OnMyEvent','foo');
1625
+	$this->assertEquals(1, $this->component->getEventHandlers('OnMyEvent')->getCount());
1626 1626
 
1627
-    $this->component->attachEventHandler('OnMyEvent','foopre', 5);
1628
-    $this->component->attachEventHandler('OnMyEvent','foopost', 15);
1629
-    $this->component->attachEventHandler('OnMyEvent','foobar', 10);
1630
-    $this->component->attachEventHandler('OnMyEvent','foobarfoobar', 10);
1627
+	$this->component->attachEventHandler('OnMyEvent','foopre', 5);
1628
+	$this->component->attachEventHandler('OnMyEvent','foopost', 15);
1629
+	$this->component->attachEventHandler('OnMyEvent','foobar', 10);
1630
+	$this->component->attachEventHandler('OnMyEvent','foobarfoobar', 10);
1631 1631
 
1632 1632
 
1633 1633
 
1634
-    $this->component->detachEventHandler('OnMyEvent','foo');
1635
-    $list = $this->component->getEventHandlers('OnMyEvent');
1636
-    $this->assertEquals(4, $list->getCount());
1634
+	$this->component->detachEventHandler('OnMyEvent','foo');
1635
+	$list = $this->component->getEventHandlers('OnMyEvent');
1636
+	$this->assertEquals(4, $list->getCount());
1637 1637
 
1638
-    $this->assertEquals('foopre', $list[0]);
1639
-    $this->assertEquals('foobar', $list[1]);
1640
-    $this->assertEquals('foobarfoobar', $list[2]);
1641
-    $this->assertEquals('foopost', $list[3]);
1638
+	$this->assertEquals('foopre', $list[0]);
1639
+	$this->assertEquals('foobar', $list[1]);
1640
+	$this->assertEquals('foobarfoobar', $list[2]);
1641
+	$this->assertEquals('foopost', $list[3]);
1642 1642
 
1643
-    $this->component->detachEventHandler('OnMyEvent','foopre', null);
1644
-    $this->assertEquals(4, $list->getCount());
1643
+	$this->component->detachEventHandler('OnMyEvent','foopre', null);
1644
+	$this->assertEquals(4, $list->getCount());
1645 1645
 
1646
-    $this->component->detachEventHandler('OnMyEvent','foopre', 5);
1647
-    $this->assertEquals(3, $list->getCount());
1646
+	$this->component->detachEventHandler('OnMyEvent','foopre', 5);
1647
+	$this->assertEquals(3, $list->getCount());
1648 1648
 
1649 1649
 
1650
-    // Now do detaching of behavior on events
1651
-    try {
1652
-      $this->component->attachEventHandler('onBehaviorEvent','foo');
1653
-      $this->fail('exception not raised when getting event handlers for undefined event');
1654
-    } catch(TInvalidOperationException $e) {
1655
-    }
1656
-    $this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1650
+	// Now do detaching of behavior on events
1651
+	try {
1652
+	  $this->component->attachEventHandler('onBehaviorEvent','foo');
1653
+	  $this->fail('exception not raised when getting event handlers for undefined event');
1654
+	} catch(TInvalidOperationException $e) {
1655
+	}
1656
+	$this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1657 1657
 
1658
-    $this->component->attachEventHandler('onBehaviorEvent','foo');
1659
-    $this->assertEquals(1, $this->component->getEventHandlers('onBehaviorEvent')->getCount());
1658
+	$this->component->attachEventHandler('onBehaviorEvent','foo');
1659
+	$this->assertEquals(1, $this->component->getEventHandlers('onBehaviorEvent')->getCount());
1660 1660
 
1661
-    $this->component->attachEventHandler('onBehaviorEvent','foopre', 5);
1662
-    $this->component->attachEventHandler('onBehaviorEvent','foopost', 15);
1663
-    $this->component->attachEventHandler('onBehaviorEvent','foobar', 10);
1664
-    $this->component->attachEventHandler('onBehaviorEvent','foobarfoobar', 10);
1661
+	$this->component->attachEventHandler('onBehaviorEvent','foopre', 5);
1662
+	$this->component->attachEventHandler('onBehaviorEvent','foopost', 15);
1663
+	$this->component->attachEventHandler('onBehaviorEvent','foobar', 10);
1664
+	$this->component->attachEventHandler('onBehaviorEvent','foobarfoobar', 10);
1665 1665
 
1666 1666
 
1667 1667
 
1668
-    $this->component->detachEventHandler('onBehaviorEvent','foo');
1669
-    $list = $this->component->getEventHandlers('onBehaviorEvent');
1670
-    $this->assertEquals(4, $list->getCount());
1668
+	$this->component->detachEventHandler('onBehaviorEvent','foo');
1669
+	$list = $this->component->getEventHandlers('onBehaviorEvent');
1670
+	$this->assertEquals(4, $list->getCount());
1671 1671
 
1672
-    $this->assertEquals('foopre', $list[0]);
1673
-    $this->assertEquals('foobar', $list[1]);
1674
-    $this->assertEquals('foobarfoobar', $list[2]);
1675
-    $this->assertEquals('foopost', $list[3]);
1672
+	$this->assertEquals('foopre', $list[0]);
1673
+	$this->assertEquals('foobar', $list[1]);
1674
+	$this->assertEquals('foobarfoobar', $list[2]);
1675
+	$this->assertEquals('foopost', $list[3]);
1676 1676
 
1677
-    $this->component->detachEventHandler('onBehaviorEvent','foopre', null);
1678
-    $this->assertEquals(4, $list->getCount());
1677
+	$this->component->detachEventHandler('onBehaviorEvent','foopre', null);
1678
+	$this->assertEquals(4, $list->getCount());
1679 1679
 
1680
-    $this->component->detachEventHandler('onBehaviorEvent','foopre', 5);
1681
-    $this->assertEquals(3, $list->getCount());
1680
+	$this->component->detachEventHandler('onBehaviorEvent','foopre', 5);
1681
+	$this->assertEquals(3, $list->getCount());
1682 1682
   }
1683 1683
 
1684 1684
 
1685 1685
 
1686 1686
 
1687 1687
   public function testRaiseEvent() {
1688
-    $this->component->attachEventHandler('OnMyEvent',array($this->component,'myEventHandler'));
1689
-    $this->assertFalse($this->component->isEventHandled());
1690
-    $this->component->raiseEvent('OnMyEvent',$this,null);
1691
-    $this->assertTrue($this->component->isEventHandled());
1692
-    $this->component->attachEventHandler('OnMyEvent',array($this->component,'Object.myEventHandler'));
1693
-    $this->assertFalse($this->component->Object->isEventHandled());
1694
-    $this->component->raiseEvent('OnMyEvent',$this,null);
1695
-    $this->assertTrue($this->component->Object->isEventHandled());
1688
+	$this->component->attachEventHandler('OnMyEvent',array($this->component,'myEventHandler'));
1689
+	$this->assertFalse($this->component->isEventHandled());
1690
+	$this->component->raiseEvent('OnMyEvent',$this,null);
1691
+	$this->assertTrue($this->component->isEventHandled());
1692
+	$this->component->attachEventHandler('OnMyEvent',array($this->component,'Object.myEventHandler'));
1693
+	$this->assertFalse($this->component->Object->isEventHandled());
1694
+	$this->component->raiseEvent('OnMyEvent',$this,null);
1695
+	$this->assertTrue($this->component->Object->isEventHandled());
1696 1696
 
1697
-    $this->component->resetEventHandled();
1698
-    $this->component->Object->resetEventHandled();
1697
+	$this->component->resetEventHandled();
1698
+	$this->component->Object->resetEventHandled();
1699 1699
 
1700 1700
 
1701
-    // Test a behavior on event
1702
-    $this->component->attachBehavior('test', new BehaviorTestBehavior);
1701
+	// Test a behavior on event
1702
+	$this->component->attachBehavior('test', new BehaviorTestBehavior);
1703 1703
 
1704
-    $this->component->attachEventHandler('onBehaviorEvent',array($this->component,'myEventHandler'));
1705
-    $this->assertFalse($this->component->isEventHandled());
1706
-    $this->component->raiseEvent('onBehaviorEvent',$this,null);
1707
-    $this->assertTrue($this->component->isEventHandled());
1708
-    $this->component->attachEventHandler('onBehaviorEvent',array($this->component,'Object.myEventHandler'));
1709
-    $this->assertFalse($this->component->Object->isEventHandled());
1710
-    $this->component->raiseEvent('onBehaviorEvent',$this,null);
1711
-    $this->assertTrue($this->component->Object->isEventHandled());
1704
+	$this->component->attachEventHandler('onBehaviorEvent',array($this->component,'myEventHandler'));
1705
+	$this->assertFalse($this->component->isEventHandled());
1706
+	$this->component->raiseEvent('onBehaviorEvent',$this,null);
1707
+	$this->assertTrue($this->component->isEventHandled());
1708
+	$this->component->attachEventHandler('onBehaviorEvent',array($this->component,'Object.myEventHandler'));
1709
+	$this->assertFalse($this->component->Object->isEventHandled());
1710
+	$this->component->raiseEvent('onBehaviorEvent',$this,null);
1711
+	$this->assertTrue($this->component->Object->isEventHandled());
1712 1712
 
1713
-    //test behavior enabled/disabled events
1714
-    $this->component->disableBehavior('test');
1713
+	//test behavior enabled/disabled events
1714
+	$this->component->disableBehavior('test');
1715 1715
 
1716
-    $this->component->resetEventHandled();
1717
-    $this->component->Object->resetEventHandled();
1716
+	$this->component->resetEventHandled();
1717
+	$this->component->Object->resetEventHandled();
1718 1718
 
1719
-    try {
1720
-    	$this->component->attachEventHandler('onBehaviorEvent',array($this->component,'myEventHandler'));
1721
-      $this->fail('exception not raised when getting event handlers for undefined event');
1722
-    } catch(TInvalidOperationException $e) {}
1723
-    $this->assertFalse($this->component->isEventHandled());
1724
-    try {
1725
-      $this->component->raiseEvent('onBehaviorEvent',$this,null);
1726
-      $this->fail('exception not raised when getting event handlers for undefined event');
1727
-    } catch(TInvalidOperationException $e) {}
1728
-    $this->assertFalse($this->component->isEventHandled());
1719
+	try {
1720
+		$this->component->attachEventHandler('onBehaviorEvent',array($this->component,'myEventHandler'));
1721
+	  $this->fail('exception not raised when getting event handlers for undefined event');
1722
+	} catch(TInvalidOperationException $e) {}
1723
+	$this->assertFalse($this->component->isEventHandled());
1724
+	try {
1725
+	  $this->component->raiseEvent('onBehaviorEvent',$this,null);
1726
+	  $this->fail('exception not raised when getting event handlers for undefined event');
1727
+	} catch(TInvalidOperationException $e) {}
1728
+	$this->assertFalse($this->component->isEventHandled());
1729 1729
 
1730
-    $this->component->enableBehavior('test');
1730
+	$this->component->enableBehavior('test');
1731 1731
 
1732 1732
 
1733 1733
 
1734
-    //Test the return types of this function
1734
+	//Test the return types of this function
1735 1735
 
1736
-    $this->assertFalse($this->component->isEventHandled());
1737
-    $this->assertFalse($this->component->Object->isEventHandled());
1738
-    $this->assertEquals(array(), $this->component->onBehaviorEvent($this,$this->component));
1739
-    $this->assertTrue($this->component->isEventHandled());
1740
-    $this->assertTrue($this->component->Object->isEventHandled());
1736
+	$this->assertFalse($this->component->isEventHandled());
1737
+	$this->assertFalse($this->component->Object->isEventHandled());
1738
+	$this->assertEquals(array(), $this->component->onBehaviorEvent($this,$this->component));
1739
+	$this->assertTrue($this->component->isEventHandled());
1740
+	$this->assertTrue($this->component->Object->isEventHandled());
1741 1741
 
1742
-    // This accumulates all the responses from each of the events
1743
-    $arr=$this->component->onBehaviorEvent($this, $this->component, TEventResults::EVENT_RESULT_ALL);
1744
-    $this->assertEquals($this, $arr[0]['sender']);
1745
-    $this->assertEquals($this->component, $arr[0]['param']);
1746
-    $this->assertTrue(null === $arr[0]['response']);
1742
+	// This accumulates all the responses from each of the events
1743
+	$arr=$this->component->onBehaviorEvent($this, $this->component, TEventResults::EVENT_RESULT_ALL);
1744
+	$this->assertEquals($this, $arr[0]['sender']);
1745
+	$this->assertEquals($this->component, $arr[0]['param']);
1746
+	$this->assertTrue(null === $arr[0]['response']);
1747 1747
 
1748
-    $this->assertEquals($this, $arr[1]['sender']);
1749
-    $this->assertEquals($this->component, $arr[1]['param']);
1750
-    $this->assertTrue(null === $arr[1]['response']);
1748
+	$this->assertEquals($this, $arr[1]['sender']);
1749
+	$this->assertEquals($this->component, $arr[1]['param']);
1750
+	$this->assertTrue(null === $arr[1]['response']);
1751 1751
 
1752
-    $this->assertEquals(2, count($arr));
1752
+	$this->assertEquals(2, count($arr));
1753 1753
 
1754
-    // This tests without the default filtering-out of null
1755
-    $arr=$this->component->onBehaviorEvent($this, $this->component, false);
1756
-    $this->assertEquals(array(null, null), $arr);
1754
+	// This tests without the default filtering-out of null
1755
+	$arr=$this->component->onBehaviorEvent($this, $this->component, false);
1756
+	$this->assertEquals(array(null, null), $arr);
1757 1757
 
1758 1758
 
1759
-    unset($this->component->onBehaviorEvent);
1760
-    $this->assertEquals(0, $this->component->onBehaviorEvent->Count);
1759
+	unset($this->component->onBehaviorEvent);
1760
+	$this->assertEquals(0, $this->component->onBehaviorEvent->Count);
1761 1761
 
1762
-    $this->component->onBehaviorEvent = array($this, 'returnValue4');
1763
-    $this->component->onBehaviorEvent = array($this, 'returnValue1');
1762
+	$this->component->onBehaviorEvent = array($this, 'returnValue4');
1763
+	$this->component->onBehaviorEvent = array($this, 'returnValue1');
1764 1764
 
1765
-    // Test the per event post processing function
1766
-    $arr=$this->component->onBehaviorEvent($this, $this->component, array($this, 'postEventFunction'));
1767
-    $this->assertEquals(array(exp(4), exp(1)), $arr);
1768
-    $arr=$this->component->onBehaviorEvent($this, $this->component, array($this, 'postEventFunction2'));
1769
-    $this->assertEquals(array(sin(4), sin(1)), $arr);
1765
+	// Test the per event post processing function
1766
+	$arr=$this->component->onBehaviorEvent($this, $this->component, array($this, 'postEventFunction'));
1767
+	$this->assertEquals(array(exp(4), exp(1)), $arr);
1768
+	$arr=$this->component->onBehaviorEvent($this, $this->component, array($this, 'postEventFunction2'));
1769
+	$this->assertEquals(array(sin(4), sin(1)), $arr);
1770 1770
 
1771 1771
 
1772
-    //Testing Feed-forward functionality
1773
-    unset($this->component->onBehaviorEvent);
1772
+	//Testing Feed-forward functionality
1773
+	unset($this->component->onBehaviorEvent);
1774 1774
 
1775
-    $this->component->onBehaviorEvent = array($this, 'ffValue4');
1776
-    $this->component->onBehaviorEvent = array($this, 'ffValue2');
1777
-    $arr=$this->component->onBehaviorEvent($this, 5, TEventResults::EVENT_RESULT_FEED_FORWARD);
1778
-    $this->assertEquals(array(20, 40), $arr);
1775
+	$this->component->onBehaviorEvent = array($this, 'ffValue4');
1776
+	$this->component->onBehaviorEvent = array($this, 'ffValue2');
1777
+	$arr=$this->component->onBehaviorEvent($this, 5, TEventResults::EVENT_RESULT_FEED_FORWARD);
1778
+	$this->assertEquals(array(20, 40), $arr);
1779 1779
 
1780 1780
 
1781
-    unset($this->component->onBehaviorEvent);
1781
+	unset($this->component->onBehaviorEvent);
1782 1782
 
1783
-    //Order of these events affects the response order in feed forward
1784
-    $this->component->onBehaviorEvent = array($this, 'ffValue2');
1785
-    $this->component->onBehaviorEvent = array($this, 'ffValue4');
1786
-    $arr=$this->component->onBehaviorEvent($this, 5, TEventResults::EVENT_RESULT_FEED_FORWARD);
1787
-    $this->assertEquals(array(10, 40), $arr);
1783
+	//Order of these events affects the response order in feed forward
1784
+	$this->component->onBehaviorEvent = array($this, 'ffValue2');
1785
+	$this->component->onBehaviorEvent = array($this, 'ffValue4');
1786
+	$arr=$this->component->onBehaviorEvent($this, 5, TEventResults::EVENT_RESULT_FEED_FORWARD);
1787
+	$this->assertEquals(array(10, 40), $arr);
1788 1788
   }
1789 1789
 
1790 1790
   public function returnValue1(){return 1;}
@@ -1796,31 +1796,31 @@  discard block
 block discarded – undo
1796 1796
 
1797 1797
 
1798 1798
   public function testGlobalEventListenerInRaiseEvent() {
1799
-    //TODO Test the Global Event Listener
1799
+	//TODO Test the Global Event Listener
1800 1800
   }
1801 1801
 
1802 1802
 
1803 1803
   public function testIDynamicMethodsOnBehavior() {
1804 1804
 
1805 1805
 	//Add Behavior with dynamic call
1806
-    $this->component->attachBehavior('TDynamicBehavior', new TDynamicBehavior);
1806
+	$this->component->attachBehavior('TDynamicBehavior', new TDynamicBehavior);
1807 1807
 
1808
-    //Check that the behavior is working as it should
1809
-    $this->assertTrue($this->component->isa('TDynamicBehavior'));
1810
-    $this->assertNull($this->component->getLastBehaviorDynamicMethodCalled());
1808
+	//Check that the behavior is working as it should
1809
+	$this->assertTrue($this->component->isa('TDynamicBehavior'));
1810
+	$this->assertNull($this->component->getLastBehaviorDynamicMethodCalled());
1811 1811
 
1812
-    // call basic behavior implemented method from object (containing behavior)
1813
-    $this->assertEquals(42, $this->component->TestBehaviorMethod(6, 7));
1812
+	// call basic behavior implemented method from object (containing behavior)
1813
+	$this->assertEquals(42, $this->component->TestBehaviorMethod(6, 7));
1814 1814
 
1815
-    //Test out undefined behavior/host object method
1816
-    try {
1817
-	    $this->component->objectAndBehaviorUndefinedMethod();
1815
+	//Test out undefined behavior/host object method
1816
+	try {
1817
+		$this->component->objectAndBehaviorUndefinedMethod();
1818 1818
 		$this->fail('exception not raised when evaluating an undefined method by the object and behavior');
1819
-    } catch(TApplicationException $e) {
1820
-    }
1819
+	} catch(TApplicationException $e) {
1820
+	}
1821 1821
 
1822
-    // calling undefined dynamic method, caught by the __dycall method in the behavior and implemented
1823
-    //	this behavior catches undefined dynamic event and divides param1 by param 2
1822
+	// calling undefined dynamic method, caught by the __dycall method in the behavior and implemented
1823
+	//	this behavior catches undefined dynamic event and divides param1 by param 2
1824 1824
 	$this->assertEquals(22, $this->component->dyTestDynamicBehaviorMethod(242, 11));
1825 1825
 	$this->assertEquals('dyTestDynamicBehaviorMethod', $this->component->getLastBehaviorDynamicMethodCalled());
1826 1826
 
@@ -1832,30 +1832,30 @@  discard block
 block discarded – undo
1832 1832
 	//	param1 * 2 * param2
1833 1833
 	$this->assertEquals(2420, $this->component->dyTestIntraEvent(121, 10));
1834 1834
 
1835
-    $this->component->detachBehavior('TDynamicBehavior');
1836
-    $this->assertFalse($this->component->isa('TDynamicBehavior'));
1835
+	$this->component->detachBehavior('TDynamicBehavior');
1836
+	$this->assertFalse($this->component->isa('TDynamicBehavior'));
1837 1837
 
1838 1838
 
1839 1839
 
1840 1840
 	//Add Class Behavior with dynamic call
1841
-    $this->component->attachBehavior('TDynamicClassBehavior', new TDynamicClassBehavior);
1841
+	$this->component->attachBehavior('TDynamicClassBehavior', new TDynamicClassBehavior);
1842 1842
 
1843
-    //Check that the behavior is working as it should
1844
-    $this->assertTrue($this->component->isa('TDynamicClassBehavior'));
1845
-    $this->assertNull($this->component->getLastBehaviorDynamicMethodCalled());
1843
+	//Check that the behavior is working as it should
1844
+	$this->assertTrue($this->component->isa('TDynamicClassBehavior'));
1845
+	$this->assertNull($this->component->getLastBehaviorDynamicMethodCalled());
1846 1846
 
1847
-    // call basic behavior implemented method from object (containing behavior)
1848
-    $this->assertEquals(42, $this->component->TestBehaviorMethod(6, 7));
1847
+	// call basic behavior implemented method from object (containing behavior)
1848
+	$this->assertEquals(42, $this->component->TestBehaviorMethod(6, 7));
1849 1849
 
1850
-    //Test out undefined behavior/host object method
1851
-    try {
1852
-	    $this->component->objectAndBehaviorUndefinedMethod();
1850
+	//Test out undefined behavior/host object method
1851
+	try {
1852
+		$this->component->objectAndBehaviorUndefinedMethod();
1853 1853
 		$this->fail('exception not raised when evaluating an undefined method by the object and behavior');
1854
-    } catch(TApplicationException $e) {
1855
-    }
1854
+	} catch(TApplicationException $e) {
1855
+	}
1856 1856
 
1857
-    // calling undefined dynamic method, caught by the __dycall method in the behavior and implemented
1858
-    //	this behavior catches undefined dynamic event and divides param1 by param 2
1857
+	// calling undefined dynamic method, caught by the __dycall method in the behavior and implemented
1858
+	//	this behavior catches undefined dynamic event and divides param1 by param 2
1859 1859
 	$this->assertEquals(22, $this->component->dyTestDynamicClassBehaviorMethod(242, 11));
1860 1860
 	$this->assertEquals('dyTestDynamicClassBehaviorMethod', $this->component->getLastBehaviorDynamicMethodCalled());
1861 1861
 
@@ -1867,8 +1867,8 @@  discard block
 block discarded – undo
1867 1867
 	//	param1 * 2 * param2
1868 1868
 	$this->assertEquals(2420, $this->component->dyTestIntraEvent(121, 10));
1869 1869
 
1870
-    $this->component->detachBehavior('TDynamicClassBehavior');
1871
-    $this->assertFalse($this->component->isa('TDynamicClassBehavior'));
1870
+	$this->component->detachBehavior('TDynamicClassBehavior');
1871
+	$this->assertFalse($this->component->isa('TDynamicClassBehavior'));
1872 1872
 
1873 1873
 
1874 1874
   }
@@ -1899,80 +1899,80 @@  discard block
 block discarded – undo
1899 1899
 
1900 1900
 
1901 1901
   public function testEvaluateExpression() {
1902
-    $expression="1+2";
1903
-    $this->assertTrue(3===$this->component->evaluateExpression($expression));
1904
-    try {
1905
-      $button=$this->component->evaluateExpression('$this->button');
1906
-      $this->fail('exception not raised when evaluating an invalid exception');
1907
-    } catch(Exception $e) {
1908
-    }
1902
+	$expression="1+2";
1903
+	$this->assertTrue(3===$this->component->evaluateExpression($expression));
1904
+	try {
1905
+	  $button=$this->component->evaluateExpression('$this->button');
1906
+	  $this->fail('exception not raised when evaluating an invalid exception');
1907
+	} catch(Exception $e) {
1908
+	}
1909 1909
   }
1910 1910
 
1911 1911
 
1912 1912
 
1913 1913
 
1914 1914
   public function testEvaluateStatements() {
1915
-    $statements='$a="test string"; echo $a;';
1916
-    $this->assertEquals('test string',$this->component->evaluateStatements($statements));
1917
-    try {
1918
-      $statements='$a=new NewComponent; echo $a->button;';
1919
-      $button=$this->component->evaluateStatements($statements);
1920
-      $this->fail('exception not raised when evaluating an invalid statement');
1921
-    } catch(Exception $e) {
1922
-    }
1915
+	$statements='$a="test string"; echo $a;';
1916
+	$this->assertEquals('test string',$this->component->evaluateStatements($statements));
1917
+	try {
1918
+	  $statements='$a=new NewComponent; echo $a->button;';
1919
+	  $button=$this->component->evaluateStatements($statements);
1920
+	  $this->fail('exception not raised when evaluating an invalid statement');
1921
+	} catch(Exception $e) {
1922
+	}
1923 1923
   }
1924 1924
 
1925 1925
 
1926 1926
   public function testDynamicFunctionCall() {
1927 1927
 
1928
-    $this->assertEquals(' aa bb cc __ .. ++ || !! ?? ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1928
+	$this->assertEquals(' aa bb cc __ .. ++ || !! ?? ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1929 1929
 
1930
-    $this->component->attachBehavior('dy1', new dy1TextReplace);
1931
-    $this->assertFalse($this->component->dy1->isCalled());
1932
-    $this->assertEquals(' aa bb cc __ __ ++ || !! ?? ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1933
-    $this->assertTrue($this->component->dy1->isCalled());
1930
+	$this->component->attachBehavior('dy1', new dy1TextReplace);
1931
+	$this->assertFalse($this->component->dy1->isCalled());
1932
+	$this->assertEquals(' aa bb cc __ __ ++ || !! ?? ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1933
+	$this->assertTrue($this->component->dy1->isCalled());
1934 1934
 
1935
-    $this->component->attachBehavior('dy2', new dy2TextReplace);
1936
-    $this->assertFalse($this->component->dy2->isCalled());
1937
-    $this->assertEquals(' aa bb cc __ __ || || !! ?? ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1938
-    $this->assertTrue($this->component->dy2->isCalled());
1935
+	$this->component->attachBehavior('dy2', new dy2TextReplace);
1936
+	$this->assertFalse($this->component->dy2->isCalled());
1937
+	$this->assertEquals(' aa bb cc __ __ || || !! ?? ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1938
+	$this->assertTrue($this->component->dy2->isCalled());
1939 1939
 
1940
-    $this->component->attachBehavior('dy3', new dy3TextReplace);
1941
-    $this->assertFalse($this->component->dy3->isCalled());
1942
-    $this->assertEquals(' aa bb cc __ __ || || ?? ?? ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1943
-    $this->assertTrue($this->component->dy3->isCalled());
1940
+	$this->component->attachBehavior('dy3', new dy3TextReplace);
1941
+	$this->assertFalse($this->component->dy3->isCalled());
1942
+	$this->assertEquals(' aa bb cc __ __ || || ?? ?? ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1943
+	$this->assertTrue($this->component->dy3->isCalled());
1944 1944
 
1945
-    $this->assertEquals(' aa bb cc __ .. ++ || !! ?? ', $this->component->dyUndefinedEvent(' aa bb cc __ .. ++ || !! ?? '));
1945
+	$this->assertEquals(' aa bb cc __ .. ++ || !! ?? ', $this->component->dyUndefinedEvent(' aa bb cc __ .. ++ || !! ?? '));
1946 1946
 
1947
-    $this->assertEquals(0.25, $this->component->dyPowerFunction(2,2));
1947
+	$this->assertEquals(0.25, $this->component->dyPowerFunction(2,2));
1948 1948
 
1949 1949
 
1950
-    $this->component->detachBehavior('dy1');
1951
-    $this->component->detachBehavior('dy2');
1952
-    $this->component->detachBehavior('dy3');
1950
+	$this->component->detachBehavior('dy1');
1951
+	$this->component->detachBehavior('dy2');
1952
+	$this->component->detachBehavior('dy3');
1953 1953
 
1954
-    //test class behaviors of dynamic events and the argument list order
1954
+	//test class behaviors of dynamic events and the argument list order
1955 1955
 
1956
-    $this->assertEquals(' aa bb cc __ .. ++ || !! ?? ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1956
+	$this->assertEquals(' aa bb cc __ .. ++ || !! ?? ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1957 1957
 
1958
-    $this->component->attachBehavior('dy1', new dy1ClassTextReplace);
1959
-    $this->assertFalse($this->component->dy1->isCalled());
1960
-    $this->assertEquals(' aa bb cc .. .. ++ || !! ?? ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1961
-    $this->assertTrue($this->component->dy1->isCalled());
1958
+	$this->component->attachBehavior('dy1', new dy1ClassTextReplace);
1959
+	$this->assertFalse($this->component->dy1->isCalled());
1960
+	$this->assertEquals(' aa bb cc .. .. ++ || !! ?? ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1961
+	$this->assertTrue($this->component->dy1->isCalled());
1962 1962
 
1963
-    $this->component->attachBehavior('dy2', new dy2ClassTextReplace);
1964
-    $this->assertFalse($this->component->dy2->isCalled());
1965
-    $this->assertEquals(' aa bb cc .. .. ++ ++ !! ?? ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1966
-    $this->assertTrue($this->component->dy2->isCalled());
1963
+	$this->component->attachBehavior('dy2', new dy2ClassTextReplace);
1964
+	$this->assertFalse($this->component->dy2->isCalled());
1965
+	$this->assertEquals(' aa bb cc .. .. ++ ++ !! ?? ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1966
+	$this->assertTrue($this->component->dy2->isCalled());
1967 1967
 
1968
-    $this->component->attachBehavior('dy3', new dy3ClassTextReplace);
1969
-    $this->assertFalse($this->component->dy3->isCalled());
1970
-    $this->assertEquals(' aa bb cc .. .. ++ ++ !! ^_^ ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1971
-    $this->assertTrue($this->component->dy3->isCalled());
1968
+	$this->component->attachBehavior('dy3', new dy3ClassTextReplace);
1969
+	$this->assertFalse($this->component->dy3->isCalled());
1970
+	$this->assertEquals(' aa bb cc .. .. ++ ++ !! ^_^ ', $this->component->dyTextFilter(' aa bb cc __ .. ++ || !! ?? '));
1971
+	$this->assertTrue($this->component->dy3->isCalled());
1972 1972
 
1973
-    $this->assertEquals(' aa bb cc __ .. ++ || !! ?? ', $this->component->dyUndefinedEvent(' aa bb cc __ .. ++ || !! ?? '));
1973
+	$this->assertEquals(' aa bb cc __ .. ++ || !! ?? ', $this->component->dyUndefinedEvent(' aa bb cc __ .. ++ || !! ?? '));
1974 1974
 
1975
-    $this->assertEquals(0.25, $this->component->dyPowerFunction(2,2));
1975
+	$this->assertEquals(0.25, $this->component->dyPowerFunction(2,2));
1976 1976
 
1977 1977
 
1978 1978
   }
@@ -1982,61 +1982,61 @@  discard block
 block discarded – undo
1982 1982
 
1983 1983
   public function testDynamicIntraObjectEvents() {
1984 1984
 
1985
-    $this->component->attachBehavior('IntraEvents', new IntraObjectExtenderBehavior);
1985
+	$this->component->attachBehavior('IntraEvents', new IntraObjectExtenderBehavior);
1986 1986
 
1987
-    $this->assertNull($this->component->IntraEvents->LastCall);
1987
+	$this->assertNull($this->component->IntraEvents->LastCall);
1988 1988
 
1989
-    //unlisten first, this object listens upon instantiation.
1990
-    $this->component->unlisten();
1991
-    $this->assertEquals(2, $this->component->IntraEvents->LastCall);
1989
+	//unlisten first, this object listens upon instantiation.
1990
+	$this->component->unlisten();
1991
+	$this->assertEquals(2, $this->component->IntraEvents->LastCall);
1992 1992
 
1993
-    // ensures that IntraEvents nulls the last call variable when calling this getter
1994
-    $this->assertNull($this->component->IntraEvents->LastCall);
1993
+	// ensures that IntraEvents nulls the last call variable when calling this getter
1994
+	$this->assertNull($this->component->IntraEvents->LastCall);
1995 1995
 
1996
-    //listen next to undo the unlisten
1997
-    $this->component->listen();
1998
-    $this->assertEquals(1, $this->component->IntraEvents->LastCall);
1996
+	//listen next to undo the unlisten
1997
+	$this->component->listen();
1998
+	$this->assertEquals(1, $this->component->IntraEvents->LastCall);
1999 1999
 
2000 2000
 
2001
-    $this->assertEquals(3, $this->component->evaluateExpression('1+2'));
2002
-    $this->assertEquals(7, $this->component->IntraEvents->LastCall);
2001
+	$this->assertEquals(3, $this->component->evaluateExpression('1+2'));
2002
+	$this->assertEquals(7, $this->component->IntraEvents->LastCall);
2003 2003
 
2004
-    $statements='$a="test string"; echo $a;';
2005
-    $this->assertEquals('test string', $this->component->evaluateStatements($statements));
2006
-    $this->assertEquals(8, $this->component->IntraEvents->LastCall);
2004
+	$statements='$a="test string"; echo $a;';
2005
+	$this->assertEquals('test string', $this->component->evaluateStatements($statements));
2006
+	$this->assertEquals(8, $this->component->IntraEvents->LastCall);
2007 2007
 
2008 2008
   	$component2 = new NewComponentNoListen();
2009
-    $this->assertNull($this->component->createdOnTemplate($component2));
2010
-    $this->assertEquals(9, $this->component->IntraEvents->LastCall);
2009
+	$this->assertNull($this->component->createdOnTemplate($component2));
2010
+	$this->assertEquals(9, $this->component->IntraEvents->LastCall);
2011 2011
 
2012
-    $this->assertNull($this->component->addParsedObject($component2));
2013
-    $this->assertEquals(10, $this->component->IntraEvents->LastCall);
2012
+	$this->assertNull($this->component->addParsedObject($component2));
2013
+	$this->assertEquals(10, $this->component->IntraEvents->LastCall);
2014 2014
 
2015 2015
 
2016 2016
 
2017
-    $behavior = new BarBehavior;
2018
-    $this->assertEquals($behavior, $this->component->attachBehavior('BarBehavior', $behavior));
2019
-    $this->assertEquals(11, $this->component->IntraEvents->LastCall);
2017
+	$behavior = new BarBehavior;
2018
+	$this->assertEquals($behavior, $this->component->attachBehavior('BarBehavior', $behavior));
2019
+	$this->assertEquals(11, $this->component->IntraEvents->LastCall);
2020 2020
 
2021
-    $this->assertNull($this->component->disableBehaviors());
2022
-    $this->assertNull($this->component->enableBehaviors());
2023
-    $this->assertEquals(27, $this->component->IntraEvents->LastCall);
2021
+	$this->assertNull($this->component->disableBehaviors());
2022
+	$this->assertNull($this->component->enableBehaviors());
2023
+	$this->assertEquals(27, $this->component->IntraEvents->LastCall);
2024 2024
 
2025
-    $this->assertTrue($this->component->disableBehavior('BarBehavior'));
2026
-    $this->assertEquals(16, $this->component->IntraEvents->LastCall);
2025
+	$this->assertTrue($this->component->disableBehavior('BarBehavior'));
2026
+	$this->assertEquals(16, $this->component->IntraEvents->LastCall);
2027 2027
 
2028
-    $this->assertTrue($this->component->enableBehavior('BarBehavior'));
2029
-    $this->assertEquals(15, $this->component->IntraEvents->LastCall);
2028
+	$this->assertTrue($this->component->enableBehavior('BarBehavior'));
2029
+	$this->assertEquals(15, $this->component->IntraEvents->LastCall);
2030 2030
 
2031
-    $this->assertEquals($behavior, $this->component->detachBehavior('BarBehavior'));
2032
-    $this->assertEquals(12, $this->component->IntraEvents->LastCall);
2031
+	$this->assertEquals($behavior, $this->component->detachBehavior('BarBehavior'));
2032
+	$this->assertEquals(12, $this->component->IntraEvents->LastCall);
2033 2033
 
2034 2034
 
2035
-    $this->component->attachEventHandler('OnMyEvent',array($this->component,'myEventHandler'));
2036
-    $this->component->raiseEvent('OnMyEvent',$this,null);
2035
+	$this->component->attachEventHandler('OnMyEvent',array($this->component,'myEventHandler'));
2036
+	$this->component->raiseEvent('OnMyEvent',$this,null);
2037 2037
 
2038
-    //3 + 4 + 5 + 6 = 18 (the behavior adds these together when each raiseEvent dynamic intra event is called)
2039
-    $this->assertEquals(18, $this->component->IntraEvents->LastCall);
2038
+	//3 + 4 + 5 + 6 = 18 (the behavior adds these together when each raiseEvent dynamic intra event is called)
2039
+	$this->assertEquals(18, $this->component->IntraEvents->LastCall);
2040 2040
   }
2041 2041
 
2042 2042
 
@@ -2047,23 +2047,23 @@  discard block
 block discarded – undo
2047 2047
 	$this->assertFalse(isset($this->component->JsColorAttribute));
2048 2048
 
2049 2049
 	$this->component->ColorAttribute = "('#556677', '#abcdef', 503987)";
2050
-    $this->assertEquals("('#556677', '#abcdef', 503987)", $this->component->ColorAttribute);
2050
+	$this->assertEquals("('#556677', '#abcdef', 503987)", $this->component->ColorAttribute);
2051 2051
 
2052 2052
 	$this->assertTrue(isset($this->component->ColorAttribute));
2053 2053
 	$this->assertTrue(isset($this->component->JsColorAttribute));
2054 2054
 
2055 2055
 	$this->component->ColorAttribute = "new Array(1, 2, 3, 4, 5)";
2056
-    $this->assertEquals("new Array(1, 2, 3, 4, 5)", $this->component->JsColorAttribute);
2056
+	$this->assertEquals("new Array(1, 2, 3, 4, 5)", $this->component->JsColorAttribute);
2057 2057
 
2058 2058
 	$this->component->JsColorAttribute = "['#112233', '#fedcba', 22009837]";
2059
-    $this->assertEquals("['#112233', '#fedcba', 22009837]", $this->component->ColorAttribute);
2059
+	$this->assertEquals("['#112233', '#fedcba', 22009837]", $this->component->ColorAttribute);
2060 2060
   }
2061 2061
 
2062 2062
 
2063 2063
   public function testJavascriptIssetUnset() {
2064 2064
 
2065 2065
 	$this->component->JsColorAttribute = "['#112233', '#fedcba', 22009837]";
2066
-    $this->assertEquals("['#112233', '#fedcba', 22009837]", $this->component->ColorAttribute);
2066
+	$this->assertEquals("['#112233', '#fedcba', 22009837]", $this->component->ColorAttribute);
2067 2067
 
2068 2068
 	unset($this->component->ColorAttribute);
2069 2069
 
Please login to merge, or discard this patch.
Spacing   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
   }
21 21
 
22 22
   public function setText($value) {
23
-    $this->_text=$value;
23
+    $this->_text = $value;
24 24
   }
25 25
 
26 26
   public function getReadOnlyProperty() {
@@ -32,22 +32,22 @@  discard block
 block discarded – undo
32 32
   }
33 33
 
34 34
   public function getObject() {
35
-    if(!$this->_object) {
36
-      $this->_object=new NewComponent;
37
-      $this->_object->_text='object text';
35
+    if (!$this->_object) {
36
+      $this->_object = new NewComponent;
37
+      $this->_object->_text = 'object text';
38 38
     }
39 39
     return $this->_object;
40 40
   }
41 41
 
42 42
   public function onMyEvent($param) {
43
-    $this->raiseEvent('OnMyEvent',$this,$param);
43
+    $this->raiseEvent('OnMyEvent', $this, $param);
44 44
   }
45 45
 
46
-  public function myEventHandler($sender,$param) {
47
-    $this->_eventHandled=true;
46
+  public function myEventHandler($sender, $param) {
47
+    $this->_eventHandled = true;
48 48
   }
49 49
 
50
-  public function eventReturnValue($sender,$param) {
50
+  public function eventReturnValue($sender, $param) {
51 51
     return $param->Return;
52 52
   }
53 53
 
@@ -95,22 +95,22 @@  discard block
 block discarded – undo
95 95
 		return $this->_callorder;
96 96
 	}
97 97
 	public function __dycall($method, $args) {
98
-		if(strncasecmp($method,'fx',2)!==0) return;
98
+		if (strncasecmp($method, 'fx', 2) !== 0) return;
99 99
 		$this->_callorder[] = 'fxcall';
100 100
 	}
101
-	public function fxGlobalListener($sender,$param,$name) {
101
+	public function fxGlobalListener($sender, $param, $name) {
102 102
 		$this->_callorder[] = 'fxGL';
103 103
 	}
104
-	public function fxPrimaryGlobalEvent($sender,$param,$name) {
104
+	public function fxPrimaryGlobalEvent($sender, $param, $name) {
105 105
 		$this->_callorder[] = 'primary';
106 106
 	}
107
-	public function commonRaiseEventListener($sender,$param,$name) {
107
+	public function commonRaiseEventListener($sender, $param, $name) {
108 108
 		$this->_callorder[] = 'com';
109 109
 	}
110
-	public function postglobalRaiseEventListener($sender,$param,$name) {
110
+	public function postglobalRaiseEventListener($sender, $param, $name) {
111 111
 		$this->_callorder[] = 'postgl';
112 112
 	}
113
-	public function preglobalRaiseEventListener($sender,$param,$name) {
113
+	public function preglobalRaiseEventListener($sender, $param, $name) {
114 114
 		$this->_callorder[] = 'pregl';
115 115
 	}
116 116
 }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		$this->_baseObject = $object;
124 124
 		return $laa * $sol;
125 125
 	}
126
-	public function getLastClassObject() {return $this->_baseObject;}
126
+	public function getLastClassObject() {return $this->_baseObject; }
127 127
 }
128 128
 
129 129
 class FooFooClassBehavior extends FooClassBehavior {
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
 	private $_instanceReturn = null;
165 165
 
166 166
 	public function moreFunction($laa, $sol) {
167
-		return pow($laa+$sol+1, 2);
167
+		return pow($laa + $sol + 1, 2);
168 168
 	}
169 169
 
170
-	public function isinstanceof($class, $instance=null) {
170
+	public function isinstanceof($class, $instance = null) {
171 171
 		return $this->_instanceReturn;
172 172
 	}
173 173
 	public function setInstanceReturn($value) {
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
 }
177 177
 class DynamicCallComponent extends NewComponent implements IDynamicMethods {
178 178
 	public function __dycall($method, $args) {
179
-		if($method === 'dyPowerFunction')
179
+		if ($method === 'dyPowerFunction')
180 180
 			return pow($args[0], $args[1]);
181
-		if($method === 'dyDivisionFunction')
181
+		if ($method === 'dyDivisionFunction')
182 182
 			return $args[0] / $args[1];
183
-		if($method === 'fxPowerFunction')
184
-			return 2*pow($args[0], $args[1]);
185
-		if($method === 'fxDivisionFunction')
186
-			return 2*$args[0] / $args[1];
183
+		if ($method === 'fxPowerFunction')
184
+			return 2 * pow($args[0], $args[1]);
185
+		if ($method === 'fxDivisionFunction')
186
+			return 2 * $args[0] / $args[1];
187 187
 	}
188 188
 }
189 189
 
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 		return true;
202 202
 	}
203 203
 
204
-	public function onBehaviorEvent($sender, $param,$responsetype=null,$postfunction=null) {
205
-    	return $this->getOwner()->raiseEvent('onBehaviorEvent',$sender,$param,$responsetype,$postfunction);
204
+	public function onBehaviorEvent($sender, $param, $responsetype = null, $postfunction = null) {
205
+    	return $this->getOwner()->raiseEvent('onBehaviorEvent', $sender, $param, $responsetype, $postfunction);
206 206
 	}
207 207
 	public function fxGlobalBehaviorEvent($sender, $param) {
208 208
 	}
@@ -294,22 +294,22 @@  discard block
 block discarded – undo
294 294
 
295 295
 		return $chain->dyUnlisten($fx);
296 296
 	}
297
-	public function dyPreRaiseEvent($name,$sender,$param,$responsetype,$postfunction, $chain) {
297
+	public function dyPreRaiseEvent($name, $sender, $param, $responsetype, $postfunction, $chain) {
298 298
 		$this->lastCall = 3;
299 299
 		$this->arglist = func_get_args();
300 300
 
301
-		return $chain->dyPreRaiseEvent($name);// Calls the next event, within a chain, if parameters are left off, they are filled in with
301
+		return $chain->dyPreRaiseEvent($name); // Calls the next event, within a chain, if parameters are left off, they are filled in with
302 302
 		//	 the original parameters passed to the dynamic event. Parameters can be passed if they are changed.
303 303
 	}
304
-	public function dyIntraRaiseEventTestHandler($handler,$sender,$param,$name, $chain) {
304
+	public function dyIntraRaiseEventTestHandler($handler, $sender, $param, $name, $chain) {
305 305
 		$this->lastCall += 4;
306 306
 		$this->arglist = func_get_args();
307 307
 	}
308
-	public function dyIntraRaiseEventPostHandler($name,$sender,$param,$handler, $chain) {
308
+	public function dyIntraRaiseEventPostHandler($name, $sender, $param, $handler, $chain) {
309 309
 		$this->lastCall += 5;
310 310
 		$this->arglist = func_get_args();
311 311
 	}
312
-	public function dyPostRaiseEvent($responses,$name,$sender,$param,$responsetype,$postfunction, $chain) {
312
+	public function dyPostRaiseEvent($responses, $name, $sender, $param, $responsetype, $postfunction, $chain) {
313 313
 		$this->lastCall += 6;
314 314
 		$this->arglist = func_get_args();
315 315
 	}
@@ -332,11 +332,11 @@  discard block
 block discarded – undo
332 332
 		$this->lastCall = 10;
333 333
 		$this->arglist = func_get_args();
334 334
 	}
335
-	public function dyAttachBehavior($name,$behavior, $chain) {
335
+	public function dyAttachBehavior($name, $behavior, $chain) {
336 336
 		$this->lastCall = 11;
337 337
 		$this->arglist = func_get_args();
338 338
 	}
339
-	public function dyDetachBehavior($name,$behavior, $chain) {
339
+	public function dyDetachBehavior($name, $behavior, $chain) {
340 340
 		$this->lastCall = 12;
341 341
 		$this->arglist = func_get_args();
342 342
 	}
@@ -348,11 +348,11 @@  discard block
 block discarded – undo
348 348
 		$this->lastCall = 14;
349 349
 		$this->arglist = func_get_args();
350 350
 	}
351
-	public function dyEnableBehavior($name,$behavior, $chain) {
351
+	public function dyEnableBehavior($name, $behavior, $chain) {
352 352
 		$this->lastCall = 15;
353 353
 		$this->arglist = func_get_args();
354 354
 	}
355
-	public function dyDisableBehavior($name,$behavior, $chain) {
355
+	public function dyDisableBehavior($name, $behavior, $chain) {
356 356
 		$this->lastCall = 16;
357 357
 		$this->arglist = func_get_args();
358 358
 	}
@@ -370,11 +370,11 @@  discard block
 block discarded – undo
370 370
 	}
371 371
 	public function __dycall($method, $args) {
372 372
 		$this->_dyMethod = $method;
373
-		if($method == 'dyTestDynamicBehaviorMethod')
373
+		if ($method == 'dyTestDynamicBehaviorMethod')
374 374
 			return $args[0] / $args[1];
375 375
 	}
376 376
 	public function dyTestIntraEvent($param1, $param2, $chain) {
377
-		return $chain->dyTestIntraEvent($param1*2*$param2, $param2);
377
+		return $chain->dyTestIntraEvent($param1 * 2 * $param2, $param2);
378 378
 	}
379 379
 	public function TestBehaviorMethod($param1, $param2) {
380 380
 		return $param1 * $param2;
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
 	public function __dycall($method, $args) {
392 392
 		$this->_dyMethod = $method;
393 393
 		$object = array_shift($args);
394
-		if($method == 'dyTestDynamicClassBehaviorMethod')
394
+		if ($method == 'dyTestDynamicClassBehaviorMethod')
395 395
 			return $args[0] / $args[1];
396 396
 	}
397 397
 	public function dyTestIntraEvent($object, $param1, $param2, $chain) {
398
-		return $chain->dyTestIntraEvent($param1*2*$param2, $param2);
398
+		return $chain->dyTestIntraEvent($param1 * 2 * $param2, $param2);
399 399
 	}
400 400
 	public function TestBehaviorMethod($object, $param1, $param2) {
401 401
 		return $param1 * $param2;
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
   public function tearDown() {
421 421
   	// PHP version 5.3.6 doesn't call the __destruct method when unsetting variables;
422 422
   	//	Thus any object that listens must be explicitly call unlisten in this version of PHP.
423
-  	if($this->component)
423
+  	if ($this->component)
424 424
 	    $this->component->unlisten();
425 425
     $this->component = null;
426 426
   }
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 	$this->assertEquals(25, $component->Bar->moreFunction(2, 2));
462 462
 	$this->assertEquals(8, $component->FooBar->moreFunction(2, 2));
463 463
 
464
-  	$component->unlisten();// unwind object and class behaviors
464
+  	$component->unlisten(); // unwind object and class behaviors
465 465
   	$this->component->detachClassBehavior('FooBar', 'NewComponent');
466 466
   	$this->component->detachClassBehavior('Bar', 'NewComponentNoListen');
467 467
 
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
     try {
546 546
       $this->component->attachClassBehavior('FooClassBehavior', new BarClassBehavior);
547 547
       $this->fail('TInvalidOperationException not raised when overwriting an existing behavior');
548
-    } catch(TInvalidOperationException $e) {
548
+    } catch (TInvalidOperationException $e) {
549 549
     }
550 550
 
551 551
 
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
     try {
554 554
   	  $this->component->attachClassBehavior('FooBarBehavior', 'FooBarBehavior', 'TComponent');
555 555
       $this->fail('TInvalidOperationException not raised when trying to place a behavior on the root object TComponent');
556
-    } catch(TInvalidOperationException $e) {
556
+    } catch (TInvalidOperationException $e) {
557 557
     }
558 558
 
559 559
 
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
     try {
816 816
 	  $this->component->faaEverMore(true, true);
817 817
       $this->fail('TApplicationException not raised trying to execute a undefined class method');
818
-    } catch(TApplicationException $e) {}
818
+    } catch (TApplicationException $e) {}
819 819
 
820 820
     $this->assertNull($this->component->asa('FooBehavior'));
821 821
     $this->assertFalse($this->component->isa('FooBehavior'));
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
     try {
826 826
       $this->component->attachBehavior('FooBehavior', new TComponent);
827 827
       $this->fail('TApplicationException not raised trying to execute a undefined class method');
828
-    } catch(TInvalidDataTypeException $e) {}
828
+    } catch (TInvalidDataTypeException $e) {}
829 829
 
830 830
     $this->component->attachBehavior('FooBehavior', new FooBehavior);
831 831
 
@@ -836,14 +836,14 @@  discard block
 block discarded – undo
836 836
 
837 837
     try {
838 838
 	    $this->assertTrue($this->component->faaEverMore(true, true));
839
-    } catch(TApplicationException $e) {
839
+    } catch (TApplicationException $e) {
840 840
       $this->fail('TApplicationException raised while trying to execute a behavior class method');
841 841
     }
842 842
 
843 843
     try {
844 844
 	  $this->component->noMethodHere(true);
845 845
       $this->fail('TApplicationException not raised trying to execute a undefined class method');
846
-    } catch(TApplicationException $e) {}
846
+    } catch (TApplicationException $e) {}
847 847
 
848 848
     $this->assertTrue($this->component->disableBehavior('FooBehavior'));
849 849
 
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
     try {
854 854
 	  $this->component->faaEverMore(true, true);
855 855
       $this->fail('TApplicationException not raised trying to execute a undefined class method');
856
-    } catch(TApplicationException $e) {}
856
+    } catch (TApplicationException $e) {}
857 857
 
858 858
     $this->assertTrue($this->component->enableBehavior('FooBehavior'));
859 859
 
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 
863 863
     try {
864 864
 	    $this->assertTrue($this->component->faaEverMore(true, true));
865
-    } catch(TApplicationException $e) {
865
+    } catch (TApplicationException $e) {
866 866
       $this->fail('TApplicationException raised while trying to execute a behavior class method');
867 867
     }
868 868
 
@@ -962,14 +962,14 @@  discard block
 block discarded – undo
962 962
     try {
963 963
 	  $this->component->faaEverMore(true, true);
964 964
       $this->fail('TApplicationException not raised trying to execute a undefined class method');
965
-    } catch(TApplicationException $e) {}
965
+    } catch (TApplicationException $e) {}
966 966
 
967 967
     $this->component->attachBehavior('FooBehavior', new FooBehavior);
968 968
 
969 969
     $this->assertTrue($this->component->isa('FooBehavior'));
970 970
     try {
971 971
 	    $this->assertTrue($this->component->faaEverMore(true, true));
972
-    } catch(TApplicationException $e) {
972
+    } catch (TApplicationException $e) {
973 973
       $this->fail('TApplicationException raised while trying to execute a behavior class method');
974 974
     }
975 975
 
@@ -980,14 +980,14 @@  discard block
 block discarded – undo
980 980
     try {
981 981
 	  $this->component->faaEverMore(true, true);
982 982
       $this->fail('TApplicationException not raised trying to execute a undefined class method');
983
-    } catch(TApplicationException $e) {}
983
+    } catch (TApplicationException $e) {}
984 984
 
985 985
     $this->assertTrue($this->component->enableBehavior('FooBehavior'));
986 986
 
987 987
     $this->assertTrue($this->component->isa('FooBehavior'));
988 988
     try {
989 989
 	    $this->assertTrue($this->component->faaEverMore(true, true));
990
-    } catch(TApplicationException $e) {
990
+    } catch (TApplicationException $e) {
991 991
       $this->fail('TApplicationException raised while trying to execute a behavior class method');
992 992
     }
993 993
 
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
     try {
1000 1000
 	  $this->component->moreFunction(true, true);
1001 1001
       $this->fail('TApplicationException not raised trying to execute an undefined class method');
1002
-    } catch(TApplicationException $e) {}
1002
+    } catch (TApplicationException $e) {}
1003 1003
 
1004 1004
     $this->component->attachClassBehavior('BarClassBehavior', new BarClassBehavior);
1005 1005
 
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 
1009 1009
     try {
1010 1010
 	    $this->assertTrue($this->component->moreFunction(true, true));
1011
-    } catch(TApplicationException $e) {
1011
+    } catch (TApplicationException $e) {
1012 1012
       $this->fail('TApplicationException raised while trying to execute a behavior class method');
1013 1013
     }
1014 1014
 
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
     try {
1036 1036
 	    $this->assertNull($this->component->moreFunction(3, 4));
1037 1037
       	$this->fail('TApplicationException not raised trying to execute a disabled behavior');
1038
-    } catch(TApplicationException $e) {}
1038
+    } catch (TApplicationException $e) {}
1039 1039
     $this->assertTrue($this->component->enableBehavior('FooBarBehavior'));
1040 1040
 
1041 1041
 	// Test the global event space, this should work and return false because no function implements these methods
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
     try {
1062 1062
     	$this->component->faafaaEverMore(3, 4);
1063 1063
       	$this->fail('TApplicationException not raised trying to execute a disabled behavior');
1064
-    } catch(TApplicationException $e) {}
1064
+    } catch (TApplicationException $e) {}
1065 1065
 
1066 1066
 
1067 1067
 
@@ -1174,18 +1174,18 @@  discard block
 block discarded – undo
1174 1174
   }
1175 1175
 
1176 1176
   public function testGetProperty() {
1177
-    $this->assertTrue('default'===$this->component->Text);
1177
+    $this->assertTrue('default' === $this->component->Text);
1178 1178
     try {
1179
-      $value2=$this->component->Caption;
1179
+      $value2 = $this->component->Caption;
1180 1180
       $this->fail('exception not raised when getting undefined property');
1181
-    } catch(TInvalidOperationException $e) {
1181
+    } catch (TInvalidOperationException $e) {
1182 1182
     }
1183 1183
 
1184 1184
     $this->assertTrue($this->component->OnMyEvent instanceof TPriorityList);
1185 1185
     try {
1186
-      $value2=$this->component->onUndefinedEvent;
1186
+      $value2 = $this->component->onUndefinedEvent;
1187 1187
       $this->fail('exception not raised when getting undefined property');
1188
-    } catch(TInvalidOperationException $e) {
1188
+    } catch (TInvalidOperationException $e) {
1189 1189
     }
1190 1190
 
1191 1191
     //Without the function parenthesis, the function is _not_ called but the __get
@@ -1201,9 +1201,9 @@  discard block
 block discarded – undo
1201 1201
     $this->component->enableBehaviors();
1202 1202
 
1203 1203
     try {
1204
-      $value2=$this->component->Excitement;
1204
+      $value2 = $this->component->Excitement;
1205 1205
       $this->fail('exception not raised when getting undefined property');
1206
-    } catch(TInvalidOperationException $e) {
1206
+    } catch (TInvalidOperationException $e) {
1207 1207
     }
1208 1208
 
1209 1209
     $this->component->attachBehavior('BehaviorTestBehavior', $behavior = new BehaviorTestBehavior);
@@ -1214,7 +1214,7 @@  discard block
 block discarded – undo
1214 1214
     try {
1215 1215
       $this->assertEquals('faa', $this->component->Excitement);
1216 1216
       $this->fail('exception not raised when getting undefined property');
1217
-    } catch(TInvalidOperationException $e) {
1217
+    } catch (TInvalidOperationException $e) {
1218 1218
     }
1219 1219
 
1220 1220
     $this->component->enableBehaviors();
@@ -1226,13 +1226,13 @@  discard block
 block discarded – undo
1226 1226
     try {
1227 1227
 	      $behavior = $this->component->BehaviorTestBehavior2;
1228 1228
 	      $this->fail('exception not raised when getting undefined property');
1229
-	    } catch(TInvalidOperationException $e) {
1229
+	    } catch (TInvalidOperationException $e) {
1230 1230
     }
1231 1231
 
1232 1232
     try {
1233 1233
       $this->assertEquals('faa', $this->component->Excitement);
1234 1234
       $this->fail('exception not raised when getting undefined property');
1235
-    } catch(TInvalidOperationException $e) {
1235
+    } catch (TInvalidOperationException $e) {
1236 1236
     }
1237 1237
     $this->component->enableBehavior('BehaviorTestBehavior');
1238 1238
     $this->assertEquals('faa', $this->component->getExcitement());
@@ -1244,39 +1244,39 @@  discard block
 block discarded – undo
1244 1244
   }
1245 1245
 
1246 1246
   public function testSetProperty() {
1247
-    $value='new value';
1248
-    $this->component->Text=$value;
1249
-    $text=$this->component->Text;
1250
-    $this->assertTrue($value===$this->component->Text);
1247
+    $value = 'new value';
1248
+    $this->component->Text = $value;
1249
+    $text = $this->component->Text;
1250
+    $this->assertTrue($value === $this->component->Text);
1251 1251
     try {
1252
-      $this->component->NewMember=$value;
1252
+      $this->component->NewMember = $value;
1253 1253
       $this->fail('exception not raised when setting undefined property');
1254
-    } catch(TInvalidOperationException $e) {
1254
+    } catch (TInvalidOperationException $e) {
1255 1255
     }
1256 1256
 
1257 1257
     // Test get only properties is a set function
1258 1258
     try {
1259 1259
       $this->component->ReadOnlyProperty = 'setting read only';
1260 1260
       $this->fail('a property without a set function was set to a new value without error');
1261
-    } catch(TInvalidOperationException $e) {
1261
+    } catch (TInvalidOperationException $e) {
1262 1262
     }
1263 1263
 
1264 1264
     try {
1265 1265
       $this->component->ReadOnlyJsProperty = 'jssetting read only';
1266 1266
       $this->fail('a js property without a set function was set to a new value without error');
1267
-    } catch(TInvalidOperationException $e) {
1267
+    } catch (TInvalidOperationException $e) {
1268 1268
     }
1269 1269
 
1270 1270
     try {
1271 1271
       $this->component->JsReadOnlyJsProperty = 'jssetting read only';
1272 1272
       $this->fail('a js property without a set function was set to a new value without error');
1273
-    } catch(TInvalidOperationException $e) {
1273
+    } catch (TInvalidOperationException $e) {
1274 1274
     }
1275 1275
 
1276 1276
     $this->assertEquals(0, $this->component->getEventHandlers('onMyEvent')->getCount());
1277
-    $this->component->onMyEvent = array($this->component,'myEventHandler');
1277
+    $this->component->onMyEvent = array($this->component, 'myEventHandler');
1278 1278
     $this->assertEquals(1, $this->component->getEventHandlers('onMyEvent')->getCount());
1279
-    $this->component->onMyEvent[] = array($this->component,'Object.myEventHandler');
1279
+    $this->component->onMyEvent[] = array($this->component, 'Object.myEventHandler');
1280 1280
     $this->assertEquals(2, $this->component->getEventHandlers('onMyEvent')->getCount());
1281 1281
 
1282 1282
     $this->component->getEventHandlers('onMyEvent')->clear();
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
     try {
1288 1288
       $this->component->Excitement = 'laa';
1289 1289
       $this->fail('exception not raised when getting undefined property');
1290
-    } catch(TInvalidOperationException $e) {
1290
+    } catch (TInvalidOperationException $e) {
1291 1291
     }
1292 1292
 
1293 1293
     $this->component->attachBehavior('BehaviorTestBehavior', $behavior1 = new BehaviorTestBehavior);
@@ -1302,7 +1302,7 @@  discard block
 block discarded – undo
1302 1302
       $this->component->Excitement = false;
1303 1303
       $this->assertEquals(false, $this->component->Excitement);
1304 1304
       $this->fail('exception not raised when getting undefined property');
1305
-    } catch(TInvalidOperationException $e) {
1305
+    } catch (TInvalidOperationException $e) {
1306 1306
     }
1307 1307
 
1308 1308
     $this->component->enableBehaviors();
@@ -1315,7 +1315,7 @@  discard block
 block discarded – undo
1315 1315
       $this->component->Excitement = false;
1316 1316
       $this->assertEquals(false, $this->component->Excitement);
1317 1317
       $this->fail('exception not raised when getting undefined property');
1318
-    } catch(TInvalidOperationException $e) {
1318
+    } catch (TInvalidOperationException $e) {
1319 1319
     }
1320 1320
     $this->component->enableBehavior('BehaviorTestBehavior');
1321 1321
     $this->component->Excitement = 'sol';
@@ -1341,9 +1341,9 @@  discard block
 block discarded – undo
1341 1341
     $this->assertTrue($this->component->BehaviorTestBehavior->onBehaviorEvent instanceof TPriorityList);
1342 1342
 
1343 1343
     $this->assertEquals(0, $this->component->BehaviorTestBehavior->getEventHandlers('onBehaviorEvent')->getCount());
1344
-    $this->component->onBehaviorEvent = array($this->component,'myEventHandler');
1344
+    $this->component->onBehaviorEvent = array($this->component, 'myEventHandler');
1345 1345
     $this->assertEquals(1, $this->component->BehaviorTestBehavior->getEventHandlers('onBehaviorEvent')->getCount());
1346
-    $this->component->onBehaviorEvent[] = array($this->component,'Object.myEventHandler');
1346
+    $this->component->onBehaviorEvent[] = array($this->component, 'Object.myEventHandler');
1347 1347
     $this->assertEquals(2, $this->component->BehaviorTestBehavior->getEventHandlers('onBehaviorEvent')->getCount());
1348 1348
 
1349 1349
     $this->component->BehaviorTestBehavior->getEventHandlers('onBehaviorEvent')->clear();
@@ -1366,10 +1366,10 @@  discard block
 block discarded – undo
1366 1366
     $this->assertTrue(isset($this->component->BehaviorTestBehavior));
1367 1367
     $this->assertFalse(isset($this->component->onBehaviorEvent));
1368 1368
 
1369
-    $this->component->attachEventHandler('onBehaviorEvent','foo');
1369
+    $this->component->attachEventHandler('onBehaviorEvent', 'foo');
1370 1370
     $this->assertTrue(isset($this->component->onBehaviorEvent));
1371 1371
 
1372
-    $this->component->attachEventHandler('onMyEvent','foo');
1372
+    $this->component->attachEventHandler('onMyEvent', 'foo');
1373 1373
     $this->assertTrue(isset($this->component->onMyEvent));
1374 1374
 
1375 1375
     $this->assertTrue(isset($this->component->Excitement));
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
 
1392 1392
  	// object events
1393 1393
  	$this->assertEquals(0, $this->component->onMyEvent->Count);
1394
-    $this->component->attachEventHandler('onMyEvent','foo');
1394
+    $this->component->attachEventHandler('onMyEvent', 'foo');
1395 1395
  	$this->assertEquals(1, $this->component->onMyEvent->Count);
1396 1396
  	unset($this->component->onMyEvent);
1397 1397
  	$this->assertEquals(0, $this->component->onMyEvent->Count);
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
   	try {
1409 1409
 	  	unset($this->component->Object);
1410 1410
     	$this->fail('TInvalidOperationException not raised when unsetting get only property');
1411
-  	} catch(TInvalidOperationException $e) {}
1411
+  	} catch (TInvalidOperationException $e) {}
1412 1412
 
1413 1413
     $this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1414 1414
  	$this->assertTrue($this->component->asa('BehaviorTestBehavior') instanceof BehaviorTestBehavior);
@@ -1437,7 +1437,7 @@  discard block
 block discarded – undo
1437 1437
   	try {
1438 1438
 	  	unset($this->component->ReadOnly);
1439 1439
     	$this->fail('TInvalidOperationException not raised when unsetting get only property');
1440
-  	} catch(TInvalidOperationException $e) {}
1440
+  	} catch (TInvalidOperationException $e) {}
1441 1441
 
1442 1442
   	$this->component->onBehaviorEvent = 'foo';
1443 1443
   	$this->assertEquals(1, count($this->component->onBehaviorEvent));
@@ -1453,12 +1453,12 @@  discard block
 block discarded – undo
1453 1453
   }
1454 1454
 
1455 1455
   public function testGetSubProperty() {
1456
-    $this->assertTrue('object text'===$this->component->getSubProperty('Object.Text'));
1456
+    $this->assertTrue('object text' === $this->component->getSubProperty('Object.Text'));
1457 1457
   }
1458 1458
 
1459 1459
   public function testSetSubProperty() {
1460
-    $this->component->setSubProperty('Object.Text','new object text');
1461
-    $this->assertEquals('new object text',$this->component->getSubProperty('Object.Text'));
1460
+    $this->component->setSubProperty('Object.Text', 'new object text');
1461
+    $this->assertEquals('new object text', $this->component->getSubProperty('Object.Text'));
1462 1462
   }
1463 1463
 
1464 1464
   public function testHasEvent() {
@@ -1492,11 +1492,11 @@  discard block
 block discarded – undo
1492 1492
 
1493 1493
   public function testHasEventHandler() {
1494 1494
     $this->assertFalse($this->component->hasEventHandler('OnMyEvent'));
1495
-    $this->component->attachEventHandler('OnMyEvent','foo');
1495
+    $this->component->attachEventHandler('OnMyEvent', 'foo');
1496 1496
     $this->assertTrue($this->component->hasEventHandler('OnMyEvent'));
1497 1497
 
1498 1498
     $this->assertFalse($this->component->hasEventHandler('fxNonExistantGlobalEvent'));
1499
-    $this->component->attachEventHandler('fxNonExistantGlobalEvent','foo');
1499
+    $this->component->attachEventHandler('fxNonExistantGlobalEvent', 'foo');
1500 1500
     $this->assertTrue($this->component->hasEventHandler('fxNonExistantGlobalEvent'));
1501 1501
 
1502 1502
     //Test behavior events
@@ -1505,7 +1505,7 @@  discard block
 block discarded – undo
1505 1505
     $this->assertFalse($this->component->hasEventHandler('onBehaviorEvent'));
1506 1506
     $this->assertFalse($this->component->BehaviorTestBehavior->hasEventHandler('onBehaviorEvent'));
1507 1507
 
1508
-    $this->component->attachEventHandler('onBehaviorEvent','foo');
1508
+    $this->component->attachEventHandler('onBehaviorEvent', 'foo');
1509 1509
     $this->assertTrue($this->component->hasEventHandler('onBehaviorEvent'));
1510 1510
 
1511 1511
     $this->component->disableBehavior('BehaviorTestBehavior');
@@ -1517,23 +1517,23 @@  discard block
 block discarded – undo
1517 1517
   }
1518 1518
 
1519 1519
   public function testGetEventHandlers() {
1520
-    $list=$this->component->getEventHandlers('OnMyEvent');
1521
-    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===0));
1522
-    $this->component->attachEventHandler('OnMyEvent','foo');
1523
-    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===1));
1520
+    $list = $this->component->getEventHandlers('OnMyEvent');
1521
+    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount() === 0));
1522
+    $this->component->attachEventHandler('OnMyEvent', 'foo');
1523
+    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount() === 1));
1524 1524
     try {
1525
-      $list=$this->component->getEventHandlers('YourEvent');
1525
+      $list = $this->component->getEventHandlers('YourEvent');
1526 1526
       $this->fail('exception not raised when getting event handlers for undefined event');
1527
-    } catch(TInvalidOperationException $e) {
1527
+    } catch (TInvalidOperationException $e) {
1528 1528
     }
1529 1529
 
1530
-    $list=$this->component->getEventHandlers('fxRandomEvent');
1531
-    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===0));
1532
-    $this->component->attachEventHandler('fxRandomEvent','foo');
1533
-    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===1));
1530
+    $list = $this->component->getEventHandlers('fxRandomEvent');
1531
+    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount() === 0));
1532
+    $this->component->attachEventHandler('fxRandomEvent', 'foo');
1533
+    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount() === 1));
1534 1534
     try {
1535
-      $list=$this->component->getEventHandlers('fxSomeUndefinedGlobalEvent');
1536
-    } catch(TInvalidOperationException $e) {
1535
+      $list = $this->component->getEventHandlers('fxSomeUndefinedGlobalEvent');
1536
+    } catch (TInvalidOperationException $e) {
1537 1537
       $this->fail('exception raised when getting event handlers for universal global event');
1538 1538
     }
1539 1539
 
@@ -1541,43 +1541,43 @@  discard block
 block discarded – undo
1541 1541
 
1542 1542
     //Test behavior events
1543 1543
     try {
1544
-      $list=$this->component->getEventHandlers('onBehaviorEvent');
1544
+      $list = $this->component->getEventHandlers('onBehaviorEvent');
1545 1545
       $this->fail('exception not raised when getting event handlers for undefined event');
1546
-    } catch(TInvalidOperationException $e) {
1546
+    } catch (TInvalidOperationException $e) {
1547 1547
     }
1548 1548
     $this->assertFalse($this->component->hasEventHandler('onBehaviorEvent'));
1549 1549
 
1550 1550
     $this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1551
-    $list=$this->component->getEventHandlers('onBehaviorEvent');
1552
-    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===0));
1553
-    $this->component->attachEventHandler('onBehaviorEvent','foo');
1554
-    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount()===1));
1551
+    $list = $this->component->getEventHandlers('onBehaviorEvent');
1552
+    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount() === 0));
1553
+    $this->component->attachEventHandler('onBehaviorEvent', 'foo');
1554
+    $this->assertTrue(($list instanceof TPriorityList) && ($list->getCount() === 1));
1555 1555
 
1556 1556
     $this->component->disableBehavior('BehaviorTestBehavior');
1557 1557
     try {
1558
-      $list=$this->component->getEventHandlers('onBehaviorEvent');
1558
+      $list = $this->component->getEventHandlers('onBehaviorEvent');
1559 1559
       $this->fail('exception not raised when getting event handlers for undefined event');
1560
-    } catch(TInvalidOperationException $e) {
1560
+    } catch (TInvalidOperationException $e) {
1561 1561
     }
1562 1562
     $this->component->enableBehavior('BehaviorTestBehavior');
1563
-    $this->assertTrue(($this->component->getEventHandlers('onBehaviorEvent') instanceof TPriorityList) && ($list->getCount()===1));
1563
+    $this->assertTrue(($this->component->getEventHandlers('onBehaviorEvent') instanceof TPriorityList) && ($list->getCount() === 1));
1564 1564
 
1565 1565
   }
1566 1566
 
1567 1567
   public function testAttachEventHandler() {
1568 1568
 
1569
-    $this->component->attachEventHandler('OnMyEvent','foo');
1569
+    $this->component->attachEventHandler('OnMyEvent', 'foo');
1570 1570
     $this->assertEquals(1, $this->component->getEventHandlers('OnMyEvent')->getCount());
1571 1571
     try {
1572
-      $this->component->attachEventHandler('YourEvent','foo');
1572
+      $this->component->attachEventHandler('YourEvent', 'foo');
1573 1573
       $this->fail('exception not raised when attaching event handlers for undefined event');
1574
-    } catch(TInvalidOperationException $e) {
1574
+    } catch (TInvalidOperationException $e) {
1575 1575
     }
1576 1576
 
1577 1577
     //Testing the priorities of attaching events
1578
-    $this->component->attachEventHandler('OnMyEvent','foopre', 5);
1579
-    $this->component->attachEventHandler('OnMyEvent','foopost', 15);
1580
-    $this->component->attachEventHandler('OnMyEvent','foobar', 10);
1578
+    $this->component->attachEventHandler('OnMyEvent', 'foopre', 5);
1579
+    $this->component->attachEventHandler('OnMyEvent', 'foopost', 15);
1580
+    $this->component->attachEventHandler('OnMyEvent', 'foobar', 10);
1581 1581
     $this->assertEquals(4, $this->component->getEventHandlers('OnMyEvent')->getCount());
1582 1582
     $list = $this->component->getEventHandlers('OnMyEvent');
1583 1583
     $this->assertEquals('foopre', $list[0]);
@@ -1588,19 +1588,19 @@  discard block
 block discarded – undo
1588 1588
 
1589 1589
     //Test attaching behavior events
1590 1590
     try {
1591
-      $this->component->attachEventHandler('onBehaviorEvent','foo');
1591
+      $this->component->attachEventHandler('onBehaviorEvent', 'foo');
1592 1592
       $this->fail('exception not raised when getting event handlers for undefined event');
1593
-    } catch(TInvalidOperationException $e) {
1593
+    } catch (TInvalidOperationException $e) {
1594 1594
     }
1595 1595
     $this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1596 1596
 
1597
-    $this->component->attachEventHandler('onBehaviorEvent','foo');
1597
+    $this->component->attachEventHandler('onBehaviorEvent', 'foo');
1598 1598
 
1599 1599
     //Testing the priorities of attaching behavior events
1600
-    $this->component->attachEventHandler('onBehaviorEvent','foopre', 5);
1601
-    $this->component->attachEventHandler('onBehaviorEvent','foopost', 15);
1602
-    $this->component->attachEventHandler('onBehaviorEvent','foobar', 10);
1603
-    $this->component->attachEventHandler('onBehaviorEvent','foobarfoobar', 10);
1600
+    $this->component->attachEventHandler('onBehaviorEvent', 'foopre', 5);
1601
+    $this->component->attachEventHandler('onBehaviorEvent', 'foopost', 15);
1602
+    $this->component->attachEventHandler('onBehaviorEvent', 'foobar', 10);
1603
+    $this->component->attachEventHandler('onBehaviorEvent', 'foobarfoobar', 10);
1604 1604
     $this->assertEquals(5, $this->component->getEventHandlers('onBehaviorEvent')->getCount());
1605 1605
     $list = $this->component->getEventHandlers('onBehaviorEvent');
1606 1606
     $this->assertEquals('foopre', $list[0]);
@@ -1611,9 +1611,9 @@  discard block
 block discarded – undo
1611 1611
 
1612 1612
     $this->component->disableBehavior('BehaviorTestBehavior');
1613 1613
     try {
1614
-      $this->component->attachEventHandler('onBehaviorEvent','bar');
1614
+      $this->component->attachEventHandler('onBehaviorEvent', 'bar');
1615 1615
       $this->fail('exception not raised when getting event handlers for undefined event');
1616
-    } catch(TInvalidOperationException $e) {
1616
+    } catch (TInvalidOperationException $e) {
1617 1617
     }
1618 1618
     $this->component->enableBehavior('BehaviorTestBehavior');
1619 1619
 
@@ -1621,17 +1621,17 @@  discard block
 block discarded – undo
1621 1621
 
1622 1622
   public function testDetachEventHandler() {
1623 1623
 
1624
-    $this->component->attachEventHandler('OnMyEvent','foo');
1624
+    $this->component->attachEventHandler('OnMyEvent', 'foo');
1625 1625
     $this->assertEquals(1, $this->component->getEventHandlers('OnMyEvent')->getCount());
1626 1626
 
1627
-    $this->component->attachEventHandler('OnMyEvent','foopre', 5);
1628
-    $this->component->attachEventHandler('OnMyEvent','foopost', 15);
1629
-    $this->component->attachEventHandler('OnMyEvent','foobar', 10);
1630
-    $this->component->attachEventHandler('OnMyEvent','foobarfoobar', 10);
1627
+    $this->component->attachEventHandler('OnMyEvent', 'foopre', 5);
1628
+    $this->component->attachEventHandler('OnMyEvent', 'foopost', 15);
1629
+    $this->component->attachEventHandler('OnMyEvent', 'foobar', 10);
1630
+    $this->component->attachEventHandler('OnMyEvent', 'foobarfoobar', 10);
1631 1631
 
1632 1632
 
1633 1633
 
1634
-    $this->component->detachEventHandler('OnMyEvent','foo');
1634
+    $this->component->detachEventHandler('OnMyEvent', 'foo');
1635 1635
     $list = $this->component->getEventHandlers('OnMyEvent');
1636 1636
     $this->assertEquals(4, $list->getCount());
1637 1637
 
@@ -1640,32 +1640,32 @@  discard block
 block discarded – undo
1640 1640
     $this->assertEquals('foobarfoobar', $list[2]);
1641 1641
     $this->assertEquals('foopost', $list[3]);
1642 1642
 
1643
-    $this->component->detachEventHandler('OnMyEvent','foopre', null);
1643
+    $this->component->detachEventHandler('OnMyEvent', 'foopre', null);
1644 1644
     $this->assertEquals(4, $list->getCount());
1645 1645
 
1646
-    $this->component->detachEventHandler('OnMyEvent','foopre', 5);
1646
+    $this->component->detachEventHandler('OnMyEvent', 'foopre', 5);
1647 1647
     $this->assertEquals(3, $list->getCount());
1648 1648
 
1649 1649
 
1650 1650
     // Now do detaching of behavior on events
1651 1651
     try {
1652
-      $this->component->attachEventHandler('onBehaviorEvent','foo');
1652
+      $this->component->attachEventHandler('onBehaviorEvent', 'foo');
1653 1653
       $this->fail('exception not raised when getting event handlers for undefined event');
1654
-    } catch(TInvalidOperationException $e) {
1654
+    } catch (TInvalidOperationException $e) {
1655 1655
     }
1656 1656
     $this->component->attachBehavior('BehaviorTestBehavior', new BehaviorTestBehavior);
1657 1657
 
1658
-    $this->component->attachEventHandler('onBehaviorEvent','foo');
1658
+    $this->component->attachEventHandler('onBehaviorEvent', 'foo');
1659 1659
     $this->assertEquals(1, $this->component->getEventHandlers('onBehaviorEvent')->getCount());
1660 1660
 
1661
-    $this->component->attachEventHandler('onBehaviorEvent','foopre', 5);
1662
-    $this->component->attachEventHandler('onBehaviorEvent','foopost', 15);
1663
-    $this->component->attachEventHandler('onBehaviorEvent','foobar', 10);
1664
-    $this->component->attachEventHandler('onBehaviorEvent','foobarfoobar', 10);
1661
+    $this->component->attachEventHandler('onBehaviorEvent', 'foopre', 5);
1662
+    $this->component->attachEventHandler('onBehaviorEvent', 'foopost', 15);
1663
+    $this->component->attachEventHandler('onBehaviorEvent', 'foobar', 10);
1664
+    $this->component->attachEventHandler('onBehaviorEvent', 'foobarfoobar', 10);
1665 1665
 
1666 1666
 
1667 1667
 
1668
-    $this->component->detachEventHandler('onBehaviorEvent','foo');
1668
+    $this->component->detachEventHandler('onBehaviorEvent', 'foo');
1669 1669
     $list = $this->component->getEventHandlers('onBehaviorEvent');
1670 1670
     $this->assertEquals(4, $list->getCount());
1671 1671
 
@@ -1674,10 +1674,10 @@  discard block
 block discarded – undo
1674 1674
     $this->assertEquals('foobarfoobar', $list[2]);
1675 1675
     $this->assertEquals('foopost', $list[3]);
1676 1676
 
1677
-    $this->component->detachEventHandler('onBehaviorEvent','foopre', null);
1677
+    $this->component->detachEventHandler('onBehaviorEvent', 'foopre', null);
1678 1678
     $this->assertEquals(4, $list->getCount());
1679 1679
 
1680
-    $this->component->detachEventHandler('onBehaviorEvent','foopre', 5);
1680
+    $this->component->detachEventHandler('onBehaviorEvent', 'foopre', 5);
1681 1681
     $this->assertEquals(3, $list->getCount());
1682 1682
   }
1683 1683
 
@@ -1685,13 +1685,13 @@  discard block
 block discarded – undo
1685 1685
 
1686 1686
 
1687 1687
   public function testRaiseEvent() {
1688
-    $this->component->attachEventHandler('OnMyEvent',array($this->component,'myEventHandler'));
1688
+    $this->component->attachEventHandler('OnMyEvent', array($this->component, 'myEventHandler'));
1689 1689
     $this->assertFalse($this->component->isEventHandled());
1690
-    $this->component->raiseEvent('OnMyEvent',$this,null);
1690
+    $this->component->raiseEvent('OnMyEvent', $this, null);
1691 1691
     $this->assertTrue($this->component->isEventHandled());
1692
-    $this->component->attachEventHandler('OnMyEvent',array($this->component,'Object.myEventHandler'));
1692
+    $this->component->attachEventHandler('OnMyEvent', array($this->component, 'Object.myEventHandler'));
1693 1693
     $this->assertFalse($this->component->Object->isEventHandled());
1694
-    $this->component->raiseEvent('OnMyEvent',$this,null);
1694
+    $this->component->raiseEvent('OnMyEvent', $this, null);
1695 1695
     $this->assertTrue($this->component->Object->isEventHandled());
1696 1696
 
1697 1697
     $this->component->resetEventHandled();
@@ -1701,13 +1701,13 @@  discard block
 block discarded – undo
1701 1701
     // Test a behavior on event
1702 1702
     $this->component->attachBehavior('test', new BehaviorTestBehavior);
1703 1703
 
1704
-    $this->component->attachEventHandler('onBehaviorEvent',array($this->component,'myEventHandler'));
1704
+    $this->component->attachEventHandler('onBehaviorEvent', array($this->component, 'myEventHandler'));
1705 1705
     $this->assertFalse($this->component->isEventHandled());
1706
-    $this->component->raiseEvent('onBehaviorEvent',$this,null);
1706
+    $this->component->raiseEvent('onBehaviorEvent', $this, null);
1707 1707
     $this->assertTrue($this->component->isEventHandled());
1708
-    $this->component->attachEventHandler('onBehaviorEvent',array($this->component,'Object.myEventHandler'));
1708
+    $this->component->attachEventHandler('onBehaviorEvent', array($this->component, 'Object.myEventHandler'));
1709 1709
     $this->assertFalse($this->component->Object->isEventHandled());
1710
-    $this->component->raiseEvent('onBehaviorEvent',$this,null);
1710
+    $this->component->raiseEvent('onBehaviorEvent', $this, null);
1711 1711
     $this->assertTrue($this->component->Object->isEventHandled());
1712 1712
 
1713 1713
     //test behavior enabled/disabled events
@@ -1717,14 +1717,14 @@  discard block
 block discarded – undo
1717 1717
     $this->component->Object->resetEventHandled();
1718 1718
 
1719 1719
     try {
1720
-    	$this->component->attachEventHandler('onBehaviorEvent',array($this->component,'myEventHandler'));
1720
+    	$this->component->attachEventHandler('onBehaviorEvent', array($this->component, 'myEventHandler'));
1721 1721
       $this->fail('exception not raised when getting event handlers for undefined event');
1722
-    } catch(TInvalidOperationException $e) {}
1722
+    } catch (TInvalidOperationException $e) {}
1723 1723
     $this->assertFalse($this->component->isEventHandled());
1724 1724
     try {
1725
-      $this->component->raiseEvent('onBehaviorEvent',$this,null);
1725
+      $this->component->raiseEvent('onBehaviorEvent', $this, null);
1726 1726
       $this->fail('exception not raised when getting event handlers for undefined event');
1727
-    } catch(TInvalidOperationException $e) {}
1727
+    } catch (TInvalidOperationException $e) {}
1728 1728
     $this->assertFalse($this->component->isEventHandled());
1729 1729
 
1730 1730
     $this->component->enableBehavior('test');
@@ -1735,12 +1735,12 @@  discard block
 block discarded – undo
1735 1735
 
1736 1736
     $this->assertFalse($this->component->isEventHandled());
1737 1737
     $this->assertFalse($this->component->Object->isEventHandled());
1738
-    $this->assertEquals(array(), $this->component->onBehaviorEvent($this,$this->component));
1738
+    $this->assertEquals(array(), $this->component->onBehaviorEvent($this, $this->component));
1739 1739
     $this->assertTrue($this->component->isEventHandled());
1740 1740
     $this->assertTrue($this->component->Object->isEventHandled());
1741 1741
 
1742 1742
     // This accumulates all the responses from each of the events
1743
-    $arr=$this->component->onBehaviorEvent($this, $this->component, TEventResults::EVENT_RESULT_ALL);
1743
+    $arr = $this->component->onBehaviorEvent($this, $this->component, TEventResults::EVENT_RESULT_ALL);
1744 1744
     $this->assertEquals($this, $arr[0]['sender']);
1745 1745
     $this->assertEquals($this->component, $arr[0]['param']);
1746 1746
     $this->assertTrue(null === $arr[0]['response']);
@@ -1752,7 +1752,7 @@  discard block
 block discarded – undo
1752 1752
     $this->assertEquals(2, count($arr));
1753 1753
 
1754 1754
     // This tests without the default filtering-out of null
1755
-    $arr=$this->component->onBehaviorEvent($this, $this->component, false);
1755
+    $arr = $this->component->onBehaviorEvent($this, $this->component, false);
1756 1756
     $this->assertEquals(array(null, null), $arr);
1757 1757
 
1758 1758
 
@@ -1763,9 +1763,9 @@  discard block
 block discarded – undo
1763 1763
     $this->component->onBehaviorEvent = array($this, 'returnValue1');
1764 1764
 
1765 1765
     // Test the per event post processing function
1766
-    $arr=$this->component->onBehaviorEvent($this, $this->component, array($this, 'postEventFunction'));
1766
+    $arr = $this->component->onBehaviorEvent($this, $this->component, array($this, 'postEventFunction'));
1767 1767
     $this->assertEquals(array(exp(4), exp(1)), $arr);
1768
-    $arr=$this->component->onBehaviorEvent($this, $this->component, array($this, 'postEventFunction2'));
1768
+    $arr = $this->component->onBehaviorEvent($this, $this->component, array($this, 'postEventFunction2'));
1769 1769
     $this->assertEquals(array(sin(4), sin(1)), $arr);
1770 1770
 
1771 1771
 
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
 
1775 1775
     $this->component->onBehaviorEvent = array($this, 'ffValue4');
1776 1776
     $this->component->onBehaviorEvent = array($this, 'ffValue2');
1777
-    $arr=$this->component->onBehaviorEvent($this, 5, TEventResults::EVENT_RESULT_FEED_FORWARD);
1777
+    $arr = $this->component->onBehaviorEvent($this, 5, TEventResults::EVENT_RESULT_FEED_FORWARD);
1778 1778
     $this->assertEquals(array(20, 40), $arr);
1779 1779
 
1780 1780
 
@@ -1783,16 +1783,16 @@  discard block
 block discarded – undo
1783 1783
     //Order of these events affects the response order in feed forward
1784 1784
     $this->component->onBehaviorEvent = array($this, 'ffValue2');
1785 1785
     $this->component->onBehaviorEvent = array($this, 'ffValue4');
1786
-    $arr=$this->component->onBehaviorEvent($this, 5, TEventResults::EVENT_RESULT_FEED_FORWARD);
1786
+    $arr = $this->component->onBehaviorEvent($this, 5, TEventResults::EVENT_RESULT_FEED_FORWARD);
1787 1787
     $this->assertEquals(array(10, 40), $arr);
1788 1788
   }
1789 1789
 
1790
-  public function returnValue1(){return 1;}
1791
-  public function returnValue4(){return 4;}
1792
-  public function postEventFunction($sender, $param, $caller, $response){return exp($response);}
1793
-  public function postEventFunction2($sender, $param, $caller, $response){return sin($response);}
1794
-  public function ffValue2($sender, $param){return $param*2;}
1795
-  public function ffValue4($sender, $param){return $param*4;}
1790
+  public function returnValue1() {return 1; }
1791
+  public function returnValue4() {return 4; }
1792
+  public function postEventFunction($sender, $param, $caller, $response) {return exp($response); }
1793
+  public function postEventFunction2($sender, $param, $caller, $response) {return sin($response); }
1794
+  public function ffValue2($sender, $param) {return $param * 2; }
1795
+  public function ffValue4($sender, $param) {return $param * 4; }
1796 1796
 
1797 1797
 
1798 1798
   public function testGlobalEventListenerInRaiseEvent() {
@@ -1816,7 +1816,7 @@  discard block
 block discarded – undo
1816 1816
     try {
1817 1817
 	    $this->component->objectAndBehaviorUndefinedMethod();
1818 1818
 		$this->fail('exception not raised when evaluating an undefined method by the object and behavior');
1819
-    } catch(TApplicationException $e) {
1819
+    } catch (TApplicationException $e) {
1820 1820
     }
1821 1821
 
1822 1822
     // calling undefined dynamic method, caught by the __dycall method in the behavior and implemented
@@ -1851,7 +1851,7 @@  discard block
 block discarded – undo
1851 1851
     try {
1852 1852
 	    $this->component->objectAndBehaviorUndefinedMethod();
1853 1853
 		$this->fail('exception not raised when evaluating an undefined method by the object and behavior');
1854
-    } catch(TApplicationException $e) {
1854
+    } catch (TApplicationException $e) {
1855 1855
     }
1856 1856
 
1857 1857
     // calling undefined dynamic method, caught by the __dycall method in the behavior and implemented
@@ -1899,12 +1899,12 @@  discard block
 block discarded – undo
1899 1899
 
1900 1900
 
1901 1901
   public function testEvaluateExpression() {
1902
-    $expression="1+2";
1903
-    $this->assertTrue(3===$this->component->evaluateExpression($expression));
1902
+    $expression = "1+2";
1903
+    $this->assertTrue(3 === $this->component->evaluateExpression($expression));
1904 1904
     try {
1905
-      $button=$this->component->evaluateExpression('$this->button');
1905
+      $button = $this->component->evaluateExpression('$this->button');
1906 1906
       $this->fail('exception not raised when evaluating an invalid exception');
1907
-    } catch(Exception $e) {
1907
+    } catch (Exception $e) {
1908 1908
     }
1909 1909
   }
1910 1910
 
@@ -1912,13 +1912,13 @@  discard block
 block discarded – undo
1912 1912
 
1913 1913
 
1914 1914
   public function testEvaluateStatements() {
1915
-    $statements='$a="test string"; echo $a;';
1916
-    $this->assertEquals('test string',$this->component->evaluateStatements($statements));
1915
+    $statements = '$a="test string"; echo $a;';
1916
+    $this->assertEquals('test string', $this->component->evaluateStatements($statements));
1917 1917
     try {
1918
-      $statements='$a=new NewComponent; echo $a->button;';
1919
-      $button=$this->component->evaluateStatements($statements);
1918
+      $statements = '$a=new NewComponent; echo $a->button;';
1919
+      $button = $this->component->evaluateStatements($statements);
1920 1920
       $this->fail('exception not raised when evaluating an invalid statement');
1921
-    } catch(Exception $e) {
1921
+    } catch (Exception $e) {
1922 1922
     }
1923 1923
   }
1924 1924
 
@@ -1944,7 +1944,7 @@  discard block
 block discarded – undo
1944 1944
 
1945 1945
     $this->assertEquals(' aa bb cc __ .. ++ || !! ?? ', $this->component->dyUndefinedEvent(' aa bb cc __ .. ++ || !! ?? '));
1946 1946
 
1947
-    $this->assertEquals(0.25, $this->component->dyPowerFunction(2,2));
1947
+    $this->assertEquals(0.25, $this->component->dyPowerFunction(2, 2));
1948 1948
 
1949 1949
 
1950 1950
     $this->component->detachBehavior('dy1');
@@ -1972,7 +1972,7 @@  discard block
 block discarded – undo
1972 1972
 
1973 1973
     $this->assertEquals(' aa bb cc __ .. ++ || !! ?? ', $this->component->dyUndefinedEvent(' aa bb cc __ .. ++ || !! ?? '));
1974 1974
 
1975
-    $this->assertEquals(0.25, $this->component->dyPowerFunction(2,2));
1975
+    $this->assertEquals(0.25, $this->component->dyPowerFunction(2, 2));
1976 1976
 
1977 1977
 
1978 1978
   }
@@ -2001,7 +2001,7 @@  discard block
 block discarded – undo
2001 2001
     $this->assertEquals(3, $this->component->evaluateExpression('1+2'));
2002 2002
     $this->assertEquals(7, $this->component->IntraEvents->LastCall);
2003 2003
 
2004
-    $statements='$a="test string"; echo $a;';
2004
+    $statements = '$a="test string"; echo $a;';
2005 2005
     $this->assertEquals('test string', $this->component->evaluateStatements($statements));
2006 2006
     $this->assertEquals(8, $this->component->IntraEvents->LastCall);
2007 2007
 
@@ -2032,8 +2032,8 @@  discard block
 block discarded – undo
2032 2032
     $this->assertEquals(12, $this->component->IntraEvents->LastCall);
2033 2033
 
2034 2034
 
2035
-    $this->component->attachEventHandler('OnMyEvent',array($this->component,'myEventHandler'));
2036
-    $this->component->raiseEvent('OnMyEvent',$this,null);
2035
+    $this->component->attachEventHandler('OnMyEvent', array($this->component, 'myEventHandler'));
2036
+    $this->component->raiseEvent('OnMyEvent', $this, null);
2037 2037
 
2038 2038
     //3 + 4 + 5 + 6 = 18 (the behavior adds these together when each raiseEvent dynamic intra event is called)
2039 2039
     $this->assertEquals(18, $this->component->IntraEvents->LastCall);
Please login to merge, or discard this patch.
Braces   +24 added lines, -15 removed lines patch added patch discarded remove patch
@@ -95,7 +95,9 @@  discard block
 block discarded – undo
95 95
 		return $this->_callorder;
96 96
 	}
97 97
 	public function __dycall($method, $args) {
98
-		if(strncasecmp($method,'fx',2)!==0) return;
98
+		if(strncasecmp($method,'fx',2)!==0) {
99
+			return;
100
+		}
99 101
 		$this->_callorder[] = 'fxcall';
100 102
 	}
101 103
 	public function fxGlobalListener($sender,$param,$name) {
@@ -176,14 +178,18 @@  discard block
 block discarded – undo
176 178
 }
177 179
 class DynamicCallComponent extends NewComponent implements IDynamicMethods {
178 180
 	public function __dycall($method, $args) {
179
-		if($method === 'dyPowerFunction')
180
-			return pow($args[0], $args[1]);
181
-		if($method === 'dyDivisionFunction')
182
-			return $args[0] / $args[1];
183
-		if($method === 'fxPowerFunction')
184
-			return 2*pow($args[0], $args[1]);
185
-		if($method === 'fxDivisionFunction')
186
-			return 2*$args[0] / $args[1];
181
+		if($method === 'dyPowerFunction') {
182
+					return pow($args[0], $args[1]);
183
+		}
184
+		if($method === 'dyDivisionFunction') {
185
+					return $args[0] / $args[1];
186
+		}
187
+		if($method === 'fxPowerFunction') {
188
+					return 2*pow($args[0], $args[1]);
189
+		}
190
+		if($method === 'fxDivisionFunction') {
191
+					return 2*$args[0] / $args[1];
192
+		}
187 193
 	}
188 194
 }
189 195
 
@@ -370,8 +376,9 @@  discard block
 block discarded – undo
370 376
 	}
371 377
 	public function __dycall($method, $args) {
372 378
 		$this->_dyMethod = $method;
373
-		if($method == 'dyTestDynamicBehaviorMethod')
374
-			return $args[0] / $args[1];
379
+		if($method == 'dyTestDynamicBehaviorMethod') {
380
+					return $args[0] / $args[1];
381
+		}
375 382
 	}
376 383
 	public function dyTestIntraEvent($param1, $param2, $chain) {
377 384
 		return $chain->dyTestIntraEvent($param1*2*$param2, $param2);
@@ -391,8 +398,9 @@  discard block
 block discarded – undo
391 398
 	public function __dycall($method, $args) {
392 399
 		$this->_dyMethod = $method;
393 400
 		$object = array_shift($args);
394
-		if($method == 'dyTestDynamicClassBehaviorMethod')
395
-			return $args[0] / $args[1];
401
+		if($method == 'dyTestDynamicClassBehaviorMethod') {
402
+					return $args[0] / $args[1];
403
+		}
396 404
 	}
397 405
 	public function dyTestIntraEvent($object, $param1, $param2, $chain) {
398 406
 		return $chain->dyTestIntraEvent($param1*2*$param2, $param2);
@@ -420,8 +428,9 @@  discard block
 block discarded – undo
420 428
   public function tearDown() {
421 429
   	// PHP version 5.3.6 doesn't call the __destruct method when unsetting variables;
422 430
   	//	Thus any object that listens must be explicitly call unlisten in this version of PHP.
423
-  	if($this->component)
424
-	    $this->component->unlisten();
431
+  	if($this->component) {
432
+  		    $this->component->unlisten();
433
+  	}
425 434
     $this->component = null;
426 435
   }
427 436
 
Please login to merge, or discard this patch.