~tsep-dev/tsep/0.9-beta

« back to all changes in this revision

Viewing changes to branches/symfony/cake/tests/cases/libs/sanitize.test.php

  • Committer: geoffreyfishing
  • Date: 2011-01-11 23:46:12 UTC
  • Revision ID: svn-v4:ae0de26e-ed09-4cbe-9a20-e40b4c60ac6c::125
Created a symfony branch for future migration to symfony

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * SanitizeTest file
 
4
 *
 
5
 * PHP versions 4 and 5
 
6
 *
 
7
 * CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
 
8
 * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
 
9
 *
 
10
 *  Licensed under The Open Group Test Suite License
 
11
 *  Redistributions of files must retain the above copyright notice.
 
12
 *
 
13
 * @copyright     Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
 
14
 * @link          http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
 
15
 * @package       cake
 
16
 * @subpackage    cake.tests.cases.libs
 
17
 * @since         CakePHP(tm) v 1.2.0.5428
 
18
 * @license       http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
 
19
 */
 
20
App::import('Core', 'Sanitize');
 
21
 
 
22
/**
 
23
 * DataTest class
 
24
 *
 
25
 * @package       cake
 
26
 * @subpackage    cake.tests.cases.libs
 
27
 */
 
28
class SanitizeDataTest extends CakeTestModel {
 
29
 
 
30
/**
 
31
 * name property
 
32
 *
 
33
 * @var string 'SanitizeDataTest'
 
34
 * @access public
 
35
 */
 
36
        var $name = 'SanitizeDataTest';
 
37
 
 
38
/**
 
39
 * useTable property
 
40
 *
 
41
 * @var string 'data_tests'
 
42
 * @access public
 
43
 */
 
44
        var $useTable = 'data_tests';
 
45
}
 
46
 
 
47
/**
 
48
 * Article class
 
49
 *
 
50
 * @package       cake
 
51
 * @subpackage    cake.tests.cases.libs
 
52
 */
 
53
class SanitizeArticle extends CakeTestModel {
 
54
 
 
55
/**
 
56
 * name property
 
57
 *
 
58
 * @var string 'Article'
 
59
 * @access public
 
60
 */
 
61
        var $name = 'SanitizeArticle';
 
62
 
 
63
/**
 
64
 * useTable property
 
65
 *
 
66
 * @var string 'articles'
 
67
 * @access public
 
68
 */
 
69
        var $useTable = 'articles';
 
70
}
 
71
 
 
72
/**
 
73
 * SanitizeTest class
 
74
 *
 
75
 * @package       cake
 
76
 * @subpackage    cake.tests.cases.libs
 
77
 */
 
78
class SanitizeTest extends CakeTestCase {
 
79
 
 
80
/**
 
81
 * autoFixtures property
 
82
 *
 
83
 * @var bool false
 
84
 * @access public
 
85
 */
 
86
        var $autoFixtures = false;
 
87
 
 
88
/**
 
89
 * fixtures property
 
90
 *
 
91
 * @var array
 
92
 * @access public
 
93
 */
 
94
        var $fixtures = array('core.data_test', 'core.article');
 
95
 
 
96
/**
 
97
 * startTest method
 
98
 *
 
99
 * @param mixed $method
 
100
 * @access public
 
101
 * @return void
 
102
 */
 
103
        function startTest($method) {
 
104
                parent::startTest($method);
 
105
                $this->_initDb();
 
106
        }
 
107
 
 
108
/**
 
109
 * testEscapeAlphaNumeric method
 
110
 *
 
111
 * @access public
 
112
 * @return void
 
113
 */
 
114
        function testEscapeAlphaNumeric() {
 
115
                $resultAlpha = Sanitize::escape('abc', 'test_suite');
 
116
                $this->assertEqual($resultAlpha, 'abc');
 
117
 
 
118
                $resultNumeric = Sanitize::escape('123', 'test_suite');
 
119
                $this->assertEqual($resultNumeric, '123');
 
120
 
 
121
                $resultNumeric = Sanitize::escape(1234, 'test_suite');
 
122
                $this->assertEqual($resultNumeric, 1234);
 
123
 
 
124
                $resultNumeric = Sanitize::escape(1234.23, 'test_suite');
 
125
                $this->assertEqual($resultNumeric, 1234.23);
 
126
 
 
127
                $resultNumeric = Sanitize::escape('#1234.23', 'test_suite');
 
128
                $this->assertEqual($resultNumeric, '#1234.23');
 
129
 
 
130
                $resultNull = Sanitize::escape(null, 'test_suite');
 
131
                $this->assertEqual($resultNull, null);
 
132
 
 
133
                $resultNull = Sanitize::escape(false, 'test_suite');
 
134
                $this->assertEqual($resultNull, false);
 
135
 
 
136
                $resultNull = Sanitize::escape(true, 'test_suite');
 
137
                $this->assertEqual($resultNull, true);
 
138
        }
 
139
 
 
140
/**
 
141
 * testClean method
 
142
 *
 
143
 * @access public
 
144
 * @return void
 
145
 */
 
146
        function testClean() {
 
147
                $string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line';
 
148
                $expected = 'test &amp; &quot;quote&quot; &#039;other&#039; ;.$ symbol.another line';
 
149
                $result = Sanitize::clean($string, array('connection' => 'test_suite'));
 
150
                $this->assertEqual($result, $expected);
 
151
 
 
152
                $string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line';
 
153
                $expected = 'test & ' . Sanitize::escape('"quote"', 'test_suite') . ' ' . Sanitize::escape('\'other\'', 'test_suite') . ' ;.$ symbol.another line';
 
154
                $result = Sanitize::clean($string, array('encode' => false, 'connection' => 'test_suite'));
 
155
                $this->assertEqual($result, $expected);
 
156
 
 
157
                $string = 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line';
 
158
                $expected = 'test & "quote" \'other\' ;.$ $ symbol.another line';
 
159
                $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'connection' => 'test_suite'));
 
160
                $this->assertEqual($result, $expected);
 
161
 
 
162
                $string = 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line';
 
163
                $expected = 'test & "quote" \'other\' ;.$ \\$ symbol.another line';
 
164
                $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'dollar' => false, 'connection' => 'test_suite'));
 
165
                $this->assertEqual($result, $expected);
 
166
 
 
167
                $string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line';
 
168
                $expected = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line';
 
169
                $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'carriage' => false, 'connection' => 'test_suite'));
 
170
                $this->assertEqual($result, $expected);
 
171
 
 
172
                $array = array(array('test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'));
 
173
                $expected = array(array('test &amp; &quot;quote&quot; &#039;other&#039; ;.$ symbol.another line'));
 
174
                $result = Sanitize::clean($array, array('connection' => 'test_suite'));
 
175
                $this->assertEqual($result, $expected);
 
176
 
 
177
                $array = array(array('test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line'));
 
178
                $expected = array(array('test & "quote" \'other\' ;.$ $ symbol.another line'));
 
179
                $result = Sanitize::clean($array, array('encode' => false, 'escape' => false, 'connection' => 'test_suite'));
 
180
                $this->assertEqual($result, $expected);
 
181
 
 
182
                $array = array(array('test odd Ä spacesé'));
 
183
                $expected = array(array('test odd &Auml; spaces&eacute;'));
 
184
                $result = Sanitize::clean($array, array('odd_spaces' => false, 'escape' => false, 'connection' => 'test_suite'));
 
185
                $this->assertEqual($result, $expected);
 
186
 
 
187
                $array = array(array('\\$', array('key' => 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line')));
 
188
                $expected = array(array('$', array('key' => 'test & "quote" \'other\' ;.$ $ symbol.another line')));
 
189
                $result = Sanitize::clean($array, array('encode' => false, 'escape' => false));
 
190
                $this->assertEqual($result, $expected);
 
191
 
 
192
                $string = '';
 
193
                $expected = '';
 
194
                $result = Sanitize::clean($string);
 
195
                $this->assertEqual($string, $expected);
 
196
 
 
197
                $data = array(
 
198
                        'Grant' => array(
 
199
                                'title' => '2 o clock grant',
 
200
                                'grant_peer_review_id' => 3,
 
201
                                'institution_id' => 5,
 
202
                                'created_by' => 1,
 
203
                                'modified_by' => 1,
 
204
                                'created' => '2010-07-15 14:11:00',
 
205
                                'modified' => '2010-07-19 10:45:41'
 
206
                        ),
 
207
                        'GrantsMember' => array(
 
208
                                0 => array(
 
209
                                        'id' => 68,
 
210
                                        'grant_id' => 120,
 
211
                                        'member_id' => 16,
 
212
                                        'program_id' => 29,
 
213
                                        'pi_percent_commitment' => 1
 
214
                                )
 
215
                        )
 
216
                );
 
217
                $result = Sanitize::clean($data);
 
218
                $this->assertEqual($result, $data);
 
219
        }
 
220
 
 
221
/**
 
222
 * testHtml method
 
223
 *
 
224
 * @access public
 
225
 * @return void
 
226
 */
 
227
        function testHtml() {
 
228
                $string = '<p>This is a <em>test string</em> & so is this</p>';
 
229
                $expected = 'This is a test string &amp; so is this';
 
230
                $result = Sanitize::html($string, array('remove' => true));
 
231
                $this->assertEqual($result, $expected);
 
232
 
 
233
                $string = 'The "lazy" dog \'jumped\' & flew over the moon. If (1+1) = 2 <em>is</em> true, (2-1) = 1 is also true';
 
234
                $expected = 'The &quot;lazy&quot; dog &#039;jumped&#039; &amp; flew over the moon. If (1+1) = 2 &lt;em&gt;is&lt;/em&gt; true, (2-1) = 1 is also true';
 
235
                $result = Sanitize::html($string);
 
236
                $this->assertEqual($result, $expected);
 
237
                
 
238
                $string = 'The "lazy" dog \'jumped\'';
 
239
                $expected = 'The &quot;lazy&quot; dog \'jumped\'';
 
240
                $result = Sanitize::html($string, array('quotes' => ENT_COMPAT));
 
241
                $this->assertEqual($result, $expected);
 
242
                
 
243
                $string = 'The "lazy" dog \'jumped\'';
 
244
                $result = Sanitize::html($string, array('quotes' => ENT_NOQUOTES));
 
245
                $this->assertEqual($result, $string);
 
246
                
 
247
                $string = 'The "lazy" dog \'jumped\' & flew over the moon. If (1+1) = 2 <em>is</em> true, (2-1) = 1 is also true';
 
248
                $expected = 'The &quot;lazy&quot; dog &#039;jumped&#039; &amp; flew over the moon. If (1+1) = 2 &lt;em&gt;is&lt;/em&gt; true, (2-1) = 1 is also true';
 
249
                $result = Sanitize::html($string);
 
250
                $this->assertEqual($result, $expected);
 
251
        }
 
252
 
 
253
/**
 
254
 * testStripWhitespace method
 
255
 *
 
256
 * @access public
 
257
 * @return void
 
258
 */
 
259
        function testStripWhitespace() {
 
260
                $string = "This     sentence \t\t\t has lots of \n\n white\nspace \rthat \r\n needs to be    \t    \n trimmed.";
 
261
                $expected = "This sentence has lots of whitespace that needs to be trimmed.";
 
262
                $result = Sanitize::stripWhitespace($string);
 
263
                $this->assertEqual($result, $expected);
 
264
        }
 
265
 
 
266
/**
 
267
 * testParanoid method
 
268
 *
 
269
 * @access public
 
270
 * @return void
 
271
 */
 
272
        function testParanoid() {
 
273
                $string = 'I would like to !%@#% & dance & sing ^$&*()-+';
 
274
                $expected = 'Iwouldliketodancesing';
 
275
                $result = Sanitize::paranoid($string);
 
276
                $this->assertEqual($result, $expected);
 
277
 
 
278
                $string = array('This |s th% s0ng that never ends it g*es',
 
279
                                                'on and on my friends, b^ca#use it is the',
 
280
                                                'so&g th===t never ends.');
 
281
                $expected = array('This s th% s0ng that never ends it g*es',
 
282
                                                'on and on my friends bcause it is the',
 
283
                                                'sog tht never ends.');
 
284
                $result = Sanitize::paranoid($string, array('%', '*', '.', ' '));
 
285
                $this->assertEqual($result, $expected);
 
286
 
 
287
                $string = "anything' OR 1 = 1";
 
288
                $expected = 'anythingOR11';
 
289
                $result = Sanitize::paranoid($string);
 
290
                $this->assertEqual($result, $expected);
 
291
 
 
292
                $string = "x' AND email IS NULL; --";
 
293
                $expected = 'xANDemailISNULL';
 
294
                $result = Sanitize::paranoid($string);
 
295
                $this->assertEqual($result, $expected);
 
296
 
 
297
                $string = "x' AND 1=(SELECT COUNT(*) FROM users); --";
 
298
                $expected = "xAND1SELECTCOUNTFROMusers";
 
299
                $result = Sanitize::paranoid($string);
 
300
                $this->assertEqual($result, $expected);
 
301
 
 
302
                $string = "x'; DROP TABLE members; --";
 
303
                $expected = "xDROPTABLEmembers";
 
304
                $result = Sanitize::paranoid($string);
 
305
                $this->assertEqual($result, $expected);
 
306
        }
 
307
 
 
308
/**
 
309
 * testStripImages method
 
310
 *
 
311
 * @access public
 
312
 * @return void
 
313
 */
 
314
        function testStripImages() {
 
315
                $string = '<img src="/img/test.jpg" alt="my image" />';
 
316
                $expected = 'my image<br />';
 
317
                $result = Sanitize::stripImages($string);
 
318
                $this->assertEqual($result, $expected);
 
319
 
 
320
                $string = '<img src="javascript:alert(\'XSS\');" />';
 
321
                $expected = '';
 
322
                $result = Sanitize::stripImages($string);
 
323
                $this->assertEqual($result, $expected);
 
324
 
 
325
                $string = '<a href="http://www.badsite.com/phising"><img src="/img/test.jpg" alt="test image alt" title="test image title" id="myImage" class="image-left"/></a>';
 
326
                $expected = '<a href="http://www.badsite.com/phising">test image alt</a><br />';
 
327
                $result = Sanitize::stripImages($string);
 
328
                $this->assertEqual($result, $expected);
 
329
 
 
330
                $string = '<a onclick="medium()" href="http://example.com"><img src="foobar.png" onclick="evilFunction(); return false;"/></a>';
 
331
                $expected = '<a onclick="medium()" href="http://example.com"></a>';
 
332
                $result = Sanitize::stripImages($string);
 
333
                $this->assertEqual($result, $expected);
 
334
        }
 
335
 
 
336
/**
 
337
 * testStripScripts method
 
338
 *
 
339
 * @access public
 
340
 * @return void
 
341
 */
 
342
        function testStripScripts() {
 
343
                $string = '<link href="/css/styles.css" media="screen" rel="stylesheet" />';
 
344
                $expected = '';
 
345
                $result = Sanitize::stripScripts($string);
 
346
                $this->assertEqual($result, $expected);
 
347
 
 
348
                $string = '<link href="/css/styles.css" media="screen" rel="stylesheet" />' . "\n" . '<link rel="icon" href="/favicon.ico" type="image/x-icon" />' . "\n" . '<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />' . "\n" . '<link rel="alternate" href="/feed.xml" title="RSS Feed" type="application/rss+xml" />';
 
349
                $expected = "\n" . '<link rel="icon" href="/favicon.ico" type="image/x-icon" />' . "\n" . '<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />'."\n".'<link rel="alternate" href="/feed.xml" title="RSS Feed" type="application/rss+xml" />';
 
350
                $result = Sanitize::stripScripts($string);
 
351
                $this->assertEqual($result, $expected);
 
352
 
 
353
                $string = '<script type="text/javascript"> alert("hacked!");</script>';
 
354
                $expected = '';
 
355
                $result = Sanitize::stripScripts($string);
 
356
                $this->assertEqual($result, $expected);
 
357
 
 
358
                $string = '<script> alert("hacked!");</script>';
 
359
                $expected = '';
 
360
                $result = Sanitize::stripScripts($string);
 
361
                $this->assertEqual($result, $expected);
 
362
 
 
363
                $string = '<style>#content { display:none; }</style>';
 
364
                $expected = '';
 
365
                $result = Sanitize::stripScripts($string);
 
366
                $this->assertEqual($result, $expected);
 
367
 
 
368
                $string = '<style type="text/css"><!-- #content { display:none; } --></style>';
 
369
                $expected = '';
 
370
                $result = Sanitize::stripScripts($string);
 
371
                $this->assertEqual($result, $expected);
 
372
 
 
373
                $string = <<<HTML
 
374
text
 
375
<style type="text/css">
 
376
<!-- 
 
377
#content { display:none; } 
 
378
-->
 
379
</style>
 
380
text
 
381
HTML;
 
382
                $expected = "text\n\ntext";
 
383
                $result = Sanitize::stripScripts($string);
 
384
                $this->assertEqual($result, $expected);
 
385
 
 
386
                $string = <<<HTML
 
387
text
 
388
<script type="text/javascript">
 
389
<!-- 
 
390
alert('wooo');
 
391
-->
 
392
</script>
 
393
text
 
394
HTML;
 
395
                $expected = "text\n\ntext";
 
396
                $result = Sanitize::stripScripts($string);
 
397
                $this->assertEqual($result, $expected);
 
398
        }
 
399
 
 
400
/**
 
401
 * testStripAll method
 
402
 *
 
403
 * @access public
 
404
 * @return void
 
405
 */
 
406
        function testStripAll() {
 
407
                $string = '<img """><script>alert("xss")</script>"/>';
 
408
                $expected ='"/>';
 
409
                $result = Sanitize::stripAll($string);
 
410
                $this->assertEqual($result, $expected);
 
411
 
 
412
                $string = '<IMG SRC=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041>';
 
413
                $expected = '';
 
414
                $result = Sanitize::stripAll($string);
 
415
                $this->assertEqual($result, $expected);
 
416
 
 
417
                $string = '<<script>alert("XSS");//<</script>';
 
418
                $expected = '<';
 
419
                $result = Sanitize::stripAll($string);
 
420
                $this->assertEqual($result, $expected);
 
421
 
 
422
                $string = '<img src="http://google.com/images/logo.gif" onload="window.location=\'http://sam.com/\'" />'."\n".
 
423
                                        "<p>This is ok      \t\n   text</p>\n".
 
424
                                        '<link rel="stylesheet" href="/css/master.css" type="text/css" media="screen" title="my sheet" charset="utf-8">'."\n".
 
425
                                        '<script src="xss.js" type="text/javascript" charset="utf-8"></script>';
 
426
                $expected = '<p>This is ok text</p>';
 
427
                $result = Sanitize::stripAll($string);
 
428
                $this->assertEqual($result, $expected);
 
429
 
 
430
        }
 
431
 
 
432
/**
 
433
 * testStripTags method
 
434
 *
 
435
 * @access public
 
436
 * @return void
 
437
 */
 
438
        function testStripTags() {
 
439
                $string = '<h2>Headline</h2><p><a href="http://example.com">My Link</a> could go to a bad site</p>';
 
440
                $expected = 'Headline<p>My Link could go to a bad site</p>';
 
441
                $result = Sanitize::stripTags($string, 'h2', 'a');
 
442
                $this->assertEqual($result, $expected);
 
443
 
 
444
                $string = '<script type="text/javascript" src="http://evildomain.com"> </script>';
 
445
                $expected = ' ';
 
446
                $result = Sanitize::stripTags($string, 'script');
 
447
                $this->assertEqual($result, $expected);
 
448
 
 
449
                $string = '<h2>Important</h2><p>Additional information here <a href="/about"><img src="/img/test.png" /></a>. Read even more here</p>';
 
450
                $expected = 'Important<p>Additional information here <img src="/img/test.png" />. Read even more here</p>';
 
451
                $result = Sanitize::stripTags($string, 'h2', 'a');
 
452
                $this->assertEqual($result, $expected);
 
453
 
 
454
                $string = '<h2>Important</h2><p>Additional information here <a href="/about"><img src="/img/test.png" /></a>. Read even more here</p>';
 
455
                $expected = 'Important<p>Additional information here . Read even more here</p>';
 
456
                $result = Sanitize::stripTags($string, 'h2', 'a', 'img');
 
457
                $this->assertEqual($result, $expected);
 
458
 
 
459
                $string = '<b>Important message!</b><br>This message will self destruct!';
 
460
                $expected = 'Important message!<br>This message will self destruct!';
 
461
                $result = Sanitize::stripTags($string, 'b');
 
462
                $this->assertEqual($result, $expected);
 
463
 
 
464
                $string = '<b>Important message!</b><br />This message will self destruct!';
 
465
                $expected = 'Important message!<br />This message will self destruct!';
 
466
                $result = Sanitize::stripTags($string, 'b');
 
467
                $this->assertEqual($result, $expected);
 
468
 
 
469
                $string = '<h2 onclick="alert(\'evil\'); onmouseover="badness()">Important</h2><p>Additional information here <a href="/about"><img src="/img/test.png" /></a>. Read even more here</p>';
 
470
                $expected = 'Important<p>Additional information here . Read even more here</p>';
 
471
                $result = Sanitize::stripTags($string, 'h2', 'a', 'img');
 
472
                $this->assertEqual($result, $expected);
 
473
        }
 
474
 
 
475
/**
 
476
 * testFormatColumns method
 
477
 *
 
478
 * @access public
 
479
 * @return void
 
480
 */
 
481
        function testFormatColumns() {
 
482
                $this->loadFixtures('DataTest', 'Article');
 
483
 
 
484
                $this->DataTest =& new SanitizeDataTest(array('alias' => 'DataTest'));
 
485
                $data = array('DataTest' => array(
 
486
                                                'id' => 'z',
 
487
                                                'count' => '12a',
 
488
                                                'float' => '2.31456',
 
489
                                                'updated' => '2008-01-01'
 
490
                                                )
 
491
                                        );
 
492
                $this->DataTest->set($data);
 
493
                $expected = array('DataTest' => array(
 
494
                        'id' => '0',
 
495
                        'count' => '12',
 
496
                        'float' => 2.31456,
 
497
                        'updated' => '2008-01-01 00:00:00',
 
498
                ));
 
499
                Sanitize::formatColumns($this->DataTest);
 
500
                $result = $this->DataTest->data;
 
501
                $this->assertEqual($result, $expected);
 
502
 
 
503
                $this->Article =& new SanitizeArticle(array('alias' => 'Article'));
 
504
                $data = array('Article' => array(
 
505
                        'id' => 'ZB',
 
506
                        'user_id' => '12',
 
507
                        'title' => 'title of article',
 
508
                        'body' => 'body text',
 
509
                        'published' => 'QQQQQQQ',
 
510
                ));
 
511
                $this->Article->set($data);
 
512
                $expected = array('Article' => array(
 
513
                        'id' => '0',
 
514
                        'user_id' => '12',
 
515
                        'title' => 'title of article',
 
516
                        'body' => 'body text',
 
517
                        'published' => 'QQQQQQQ',
 
518
                ));
 
519
                Sanitize::formatColumns($this->Article);
 
520
                $result = $this->Article->data;
 
521
                $this->assertEqual($result, $expected);
 
522
        }
 
523
}