OSDN Git Service

uri_pickup(): underscore
[pukiwiki/pukiwiki_sandbox.git] / spam / SpamTest.php
1 <?php
2 // $Id: SpamTest.php,v 1.16 2007/06/23 14:11:10 henoheno Exp $
3 // Copyright (C) 2007 heno
4 //
5 // Design test case for spam.php (called from runner.php)
6
7 if (! defined('SPAM_INI_FILE')) define('SPAM_INI_FILE', 'spam.ini.php');
8
9 require_once('spam.php');
10 require_once('PHPUnit/PHPUnit.php');
11
12 class SpamTest extends PHPUnit_TestCase
13 {
14         function setup_string_null()
15         {
16                 return array(
17                         '[NULL]'        => NULL,
18                         '[TRUE]'        => TRUE,
19                         '[FALSE]'       => FALSE,
20                         '[array(foobar)]' => array('foobar'),
21                         '[]'            => '',
22                         '[0]'           => 0,
23                         '[1]'           => 1
24                 );
25         }
26
27         function testFunc_strings()
28         {
29                 // 1st argument: Null
30                 $this->assertEquals('',  strings(NULL,  0));
31                 $this->assertEquals('',  strings(TRUE,  0));
32                 $this->assertEquals('',  strings(FALSE, 0));
33                 $this->assertEquals('',  strings('',    0));
34                 $this->assertEquals('0', strings(0,     0));
35                 $this->assertEquals('1', strings(1,     0));
36
37                 // Setup
38                 $t1 = '1'    . "\n";
39                 $t2 = '12'   . "\n";
40                 $t3 = '123'  . "\n";
41                 $t4 = '1234' . "\n";
42                 $t5 = '12345';
43                 $test = $t1 . $t2 . $t3 . $t4 . $t5;
44
45                 // Minimum length
46                 $this->assertEquals($t1 . $t2 . $t3 . $t4 . $t5, strings($test, -1));
47                 $this->assertEquals($t1 . $t2 . $t3 . $t4 . $t5, strings($test,  0));
48                 $this->assertEquals($t1 . $t2 . $t3 . $t4 . $t5, strings($test,  1));
49                 $this->assertEquals(      $t2 . $t3 . $t4 . $t5, strings($test,  2));
50                 $this->assertEquals(            $t3 . $t4 . $t5, strings($test,  3));
51                 $this->assertEquals(                  $t4 . $t5, strings($test,  4));
52                 $this->assertEquals(                  $t4 . $t5, strings($test)); // Default
53                 $this->assertEquals(                        $t5, strings($test,  5));
54
55                 // Preserve the last newline
56                 $this->assertEquals($t4 . $t5,        strings($test       , 4));
57                 $this->assertEquals($t4 . $t5 . "\n", strings($test . "\n", 4));
58
59                 // Ignore sequential spaces, and spaces at the beginning/end of lines
60                 $test = '   A' . '      ' . '   ' . 'B  ';
61                 $this->assertEquals($test, strings($test, 0, FALSE));
62                 $this->assertEquals('A B', strings($test, 0, TRUE ));
63         }
64
65         function testFunc_array_count_leaves()
66         {
67                 // Empty array = 0, if option is not set
68                 $array = array();
69                 $this->assertEquals(0, array_count_leaves($array, FALSE));
70                 $this->assertEquals(1, array_count_leaves($array, TRUE));
71                 $array = array(
72                         array(
73                                 array()
74                         )
75                 );
76                 $this->assertEquals(0, array_count_leaves($array, FALSE));
77                 $this->assertEquals(1, array_count_leaves($array, TRUE));
78
79                 // One leaf = 1
80                 foreach(array(NULL, TRUE, FALSE, -1, 0, 1, '', 'foobar') as $value) {
81                         $this->assertEquals(1, array_count_leaves($value, FALSE));
82                         $this->assertEquals(1, array_count_leaves($value, TRUE));
83                 }
84
85                 // Compisite
86                 $array = array(
87                         1,
88                         'v1',
89                         array(),        // Empty array
90                         array(
91                                 2,
92                                 'v2',
93                                 'k1' => TRUE,
94                                 'k2' => FALSE,
95                                 'k3' => array(),        // Empty array
96                                 'k4' => array(
97                                         3,
98                                         'v3',
99                                         'k5' => NULL,
100                                         'k6' => array(),        // Empty array
101                                 ),
102                         ),
103                         'k7'  => 4,
104                         'k8'  => 'v4',
105                         'k9'  => array(),       // Empty array
106                         'k10' => array(
107                                 5,
108                                 'v5',
109                                 'k11' => NULL,
110                                 'k12' => array(),       // Empty array
111                         ),
112                 );
113                 $this->assertEquals(14, array_count_leaves($array, FALSE));
114                 $this->assertEquals(19, array_count_leaves($array, TRUE));
115         }
116
117         function testPhpFunc_array_unique()
118         {
119                 $this->assertEquals(array(1), array_unique(array(1, 1)));
120
121                 // Keys are preserved, array()s inside are preserved
122                 $this->assertEquals(
123                         array(0, 2 => array(1, 1), 3 => 2),
124                         array_unique(
125                                 array(0, 0, array(1, 1), 2, 2)
126                         )
127                 );
128
129                 // Keys are preserved
130                 $this->assertEquals(
131                         array(0, 2 => array(1, 1), 3 => 2),
132                         array_unique(array(0, 0, array(1, 1), 2, 2))
133                 );
134
135                 // ONLY the first array() is preserved
136                 $this->assertEquals(
137                         array(0 => array(1, 1)),
138                         array_unique(array_unique(array(0 => array(1, 1), 'a' => array(2,2), 'b' => array(3, 3))))
139                 );
140         }
141
142         // And array_unique_recursive()
143         function testPhPFunc_array_merge_recursive()
144         {
145                 $array1 = array(1);
146                 $array2 = array(1);
147                 $result = array_merge_recursive($array1, $array2);
148                 $this->assertEquals(array(1, 1), $result);
149                 $result = array_unique_recursive($result);
150                 $this->assertEquals(array(1),    $result);
151
152                 $array1 = array(2);
153                 $array2 = array(1);
154                 $result = array(2, 1);
155                 $this->assertEquals($result, array_merge_recursive($array1, $array2));
156
157                 // All NUMERIC keys are always renumbered from 0
158                 $array1 = array('10' => 'f3');
159                 $array2 = array('10' => 'f4');
160                 $result = array('f3', 'f4');
161                 $this->assertEquals($result, array_merge_recursive($array1, $array2));
162
163                 // One more thing ...
164                 $array1 = array('20' => 'f5');
165                 $array2 = array();
166                 $result = array('f5');
167                 $this->assertEquals($result, array_merge_recursive($array1, $array2));
168
169                 // Non-numeric keys and values will be marged as you think
170                 $array1 = array('a' => 'f1');
171                 $array2 = array('a' => 'f2');
172                 $result = array('a' => array('f1', 'f2'));
173                 $this->assertEquals($result, array_merge_recursive($array1, $array2));
174
175                 // Non-numeric keys: An array and a value will be marged
176                 $array1 = array('b' => array('k1'));
177                 $array2 = array('b' => 'k2');
178                 $result = array('b' => array('k1', 'k2'));
179                 $this->assertEquals($result, array_merge_recursive($array1, $array2));
180
181                 // Combination
182                 $array1 = array(
183                         2,
184                         'a' => 'f1',
185                         '10' => 'f3',
186                         '20' => 'f5',
187                         'b' => array('k1'),
188                 );
189                 $array2 = array(
190                         1,
191                         'a' => 'f2',
192                         '10' => 'f4',
193                         'b' => 'k2',
194                 );
195                 $result = array (
196                         2,
197                         'a' => array (
198                                 'f1',
199                                 'f2',
200                         ),
201                         'f3',
202                         'f5',
203                         'b' => array (
204                                 'k1',
205                                 'k2',
206                         ),
207                         1,
208                         'f4',
209                 );
210                 $this->assertEquals($result, array_merge_recursive($array1, $array2));
211
212                 // Values will not be unique
213                 $array1 = array(5, 4);
214                 $array2 = array(4, 5);
215                 $result = array_merge_recursive($array1, $array2);
216                 $this->assertEquals(array(5, 4, 4, 5), $result);
217                 $result = array_unique_recursive($result);
218                 $this->assertEquals(array(5, 4),       $result);
219
220                 // One more thing ...
221                 $array1 = array('b' => array('k3'));
222                 $array2 = array('b' => 'k3');
223                 $result = array_merge_recursive($array1, $array2);
224                 $this->assertEquals(array('b' => array('k3', 'k3')), $result);
225                 $result = array_unique_recursive($result);
226                 $this->assertEquals(array('b' => array('k3')),       $result);
227         }
228
229         function testFunc_uri_pickup()
230         {
231                 // 1st argument: Null
232                 foreach($this->setup_string_null() as $key => $value){
233                         $this->assertEquals(0, count(uri_pickup($value)), $key);
234                 }
235
236                 // 1st argument: Some
237                 $test_string = <<<EOF
238                         TTP://wwW.Example.Org#TTP_and_www
239                         https://nasty.example.org:443/foo/xxx#port443/slash
240                         sftp://foobar.example.org:80/dfsdfs#ftp_bat_port80
241                         ftp://cnn.example.com&story=breaking_news@10.0.0.1/top_story.htm
242                         http://192.168.1.4:443#IPv4
243 EOF;
244                 $results = uri_pickup_normalize(uri_pickup($test_string));
245                 $this->assertEquals(5, count($results));
246
247                 // ttp://wwW.Example.Org:80#TTP_and_www
248                 $this->assertEquals('http',           $results[0]['scheme']);
249                 $this->assertEquals('',               $results[0]['userinfo']);
250                 $this->assertEquals('example.org',    $results[0]['host']);
251                 $this->assertEquals('',               $results[0]['port']);
252                 $this->assertEquals('/',              $results[0]['path']);
253                 $this->assertEquals('',               $results[0]['file']);
254                 $this->assertEquals('',               $results[0]['query']);
255                 $this->assertEquals('ttp_and_www',    $results[0]['fragment']);
256
257                 // https://nasty.example.org:443/foo/xxx#port443/slash
258                 $this->assertEquals('https',          $results[1]['scheme']);
259                 $this->assertEquals('',               $results[1]['userinfo']);
260                 $this->assertEquals('nasty.example.org', $results[1]['host']);
261                 $this->assertEquals('',               $results[1]['port']);
262                 $this->assertEquals('/foo/',          $results[1]['path']);
263                 $this->assertEquals('xxx',            $results[1]['file']);
264                 $this->assertEquals('',               $results[1]['query']);
265                 $this->assertEquals('port443',        $results[1]['fragment']);
266
267                 // sftp://foobar.example.org:80/dfsdfs#sftp_bat_port80
268                 $this->assertEquals('sftp',           $results[2]['scheme']);
269                 $this->assertEquals('',               $results[2]['userinfo']);
270                 $this->assertEquals('foobar.example.org', $results[2]['host']);
271                 $this->assertEquals('80',             $results[2]['port']);
272                 $this->assertEquals('/',              $results[2]['path']);
273                 $this->assertEquals('dfsdfs',         $results[2]['file']);
274                 $this->assertEquals('',               $results[2]['query']);
275                 $this->assertEquals('ftp_bat_port80', $results[2]['fragment']);
276
277                 // ftp://cnn.example.com&story=breaking_news@10.0.0.1/top_story.htm
278                 $this->assertEquals('ftp',            $results[3]['scheme']);
279                 $this->assertEquals('cnn.example.com&story=breaking_news', $results[3]['userinfo']);
280                 $this->assertEquals('10.0.0.1',       $results[3]['host']);
281                 $this->assertEquals('',               $results[3]['port']);
282                 $this->assertEquals('/',              $results[3]['path']);
283                 $this->assertEquals('top_story.htm',  $results[3]['file']);
284                 $this->assertEquals('',               $results[3]['query']);
285                 $this->assertEquals('',               $results[3]['fragment']);
286
287
288                 // Specific tests ----
289
290                 // Divider: Back-slash
291                 $test_string = ' http:\\backslash.org\fobar.html ';
292                 $results = uri_pickup_normalize(uri_pickup($test_string));
293                 $this->assertEquals('backslash.org',  $results[0]['host']);
294
295                 // Host: Underscore
296                 $test_string = ' http://under_score.org/fobar.html ';
297                 $results = uri_pickup_normalize(uri_pickup($test_string));
298                 $this->assertEquals('under_score.org',$results[0]['host']);     // Not 'under'
299
300                 // Host: IPv4
301                 $test_string = ' http://192.168.0.1/fobar.html ';
302                 $results = uri_pickup_normalize(uri_pickup($test_string));
303                 $this->assertEquals('192.168.0.1',    $results[0]['host']);
304         }
305
306         function testFunc_scheme_normalize()
307         {
308                 // Null
309                 foreach($this->setup_string_null() as $key => $value){
310                         $this->assertEquals('', scheme_normalize($value), $key);
311                 }
312
313                 // CASE
314                 $this->assertEquals('http', scheme_normalize('HTTP'));
315
316                 // Aliases
317                 $this->assertEquals('pop3',  scheme_normalize('pop'));
318                 $this->assertEquals('nntp',  scheme_normalize('news'));
319                 $this->assertEquals('imap',  scheme_normalize('imap4'));
320                 $this->assertEquals('nntps', scheme_normalize('snntp'));
321                 $this->assertEquals('nntps', scheme_normalize('snews'));
322                 $this->assertEquals('pop3s', scheme_normalize('spop3'));
323                 $this->assertEquals('pop3s', scheme_normalize('pops'));
324                 
325                 // Abbrevs
326                 $this->assertEquals('http',  scheme_normalize('ttp'));
327                 $this->assertEquals('https', scheme_normalize('ttps'));
328
329                 // Abbrevs considererd harmless
330                 $this->assertEquals('', scheme_normalize('ttp',  FALSE));
331                 $this->assertEquals('', scheme_normalize('ttps', FALSE));
332         }
333
334         function testFunc_host_normalize()
335         {
336                 // Null
337                 foreach($this->setup_string_null() as $key => $value){
338                         $this->assertEquals('', host_normalize($value), $key);
339                 }
340
341                 // Hostname is case-insensitive
342                 $this->assertEquals('example.org', host_normalize('ExAMPle.ORG'));
343
344                 // Cut 'www' (destructive)
345                 $this->assertEquals('example.org', host_normalize('WWW.example.org'));
346         }
347
348         function testFunc_port_normalize()
349         {
350                 $scheme = 'dont_care';
351
352                 // 1st argument: Null
353                 $this->assertEquals('', port_normalize(NULL, $scheme));
354                 $this->assertEquals('', port_normalize(TRUE, $scheme));
355                 $this->assertEquals('', port_normalize(FALSE, $scheme));
356                 $this->assertEquals('', port_normalize(array('foobar'), $scheme));
357                 $this->assertEquals('', port_normalize('',   $scheme));
358
359                 // 1st argument: Known port
360                 $this->assertEquals('',    port_normalize(   -1, $scheme));
361                 $this->assertEquals(0,     port_normalize(    0, $scheme));
362                 $this->assertEquals(1,     port_normalize(    1, $scheme));
363                 $this->assertEquals('',    port_normalize(   21, 'ftp'));
364                 $this->assertEquals('',    port_normalize(   22, 'ssh'));
365                 $this->assertEquals('',    port_normalize(   23, 'telnet'));
366                 $this->assertEquals('',    port_normalize(   25, 'smtp'));
367                 $this->assertEquals('',    port_normalize(   69, 'tftp'));
368                 $this->assertEquals('',    port_normalize(   70, 'gopher'));
369                 $this->assertEquals('',    port_normalize(   79, 'finger'));
370                 $this->assertEquals('',    port_normalize(   80, 'http'));
371                 $this->assertEquals('',    port_normalize(  110, 'pop3'));
372                 $this->assertEquals('',    port_normalize(  115, 'sftp'));
373                 $this->assertEquals('',    port_normalize(  119, 'nntp'));
374                 $this->assertEquals('',    port_normalize(  143, 'imap'));
375                 $this->assertEquals('',    port_normalize(  194, 'irc'));
376                 $this->assertEquals('',    port_normalize(  210, 'wais'));
377                 $this->assertEquals('',    port_normalize(  443, 'https'));
378                 $this->assertEquals('',    port_normalize(  563, 'nntps'));
379                 $this->assertEquals('',    port_normalize(  873, 'rsync'));
380                 $this->assertEquals('',    port_normalize(  990, 'ftps'));
381                 $this->assertEquals('',    port_normalize(  992, 'telnets'));
382                 $this->assertEquals('',    port_normalize(  993, 'imaps'));
383                 $this->assertEquals('',    port_normalize(  994, 'ircs'));
384                 $this->assertEquals('',    port_normalize(  995, 'pop3s'));
385                 $this->assertEquals('',    port_normalize( 3306, 'mysql'));
386                 $this->assertEquals(8080,  port_normalize( 8080, $scheme));
387                 $this->assertEquals(65535, port_normalize(65535, $scheme));
388                 $this->assertEquals(65536, port_normalize(65536, $scheme)); // Seems not invalid in RFC
389
390                 // 1st argument: Invalid type
391                 $this->assertEquals('1x',  port_normalize('001', $scheme) . 'x');
392                 $this->assertEquals('',    port_normalize('+0',  $scheme));
393                 $this->assertEquals('',    port_normalize('0-1', $scheme)); // intval() says '0'
394                 $this->assertEquals('',    port_normalize('str', $scheme));
395
396                 // 2nd and 3rd argument: Null
397                 $this->assertEquals(80,    port_normalize(80, NULL,  TRUE));
398                 $this->assertEquals(80,    port_normalize(80, TRUE,  TRUE));
399                 $this->assertEquals(80,    port_normalize(80, FALSE, TRUE));
400                 $this->assertEquals(80,    port_normalize(80, array('foobar'), TRUE));
401                 $this->assertEquals(80,    port_normalize(80, '', TRUE));
402
403                 // 2nd and 3rd argument: Do $scheme_normalize
404                 $this->assertEquals('',    port_normalize(80,  'TTP',  TRUE));
405                 $this->assertEquals('',    port_normalize(110, 'POP',  TRUE));
406                 $this->assertEquals(80,    port_normalize(80,  'HTTP', FALSE));
407         }
408
409         function testFunc_path_normalize()
410         {
411                 // 1st argument: Null
412                 foreach($this->setup_string_null() as $key => $value){
413                         $this->assertEquals('/', path_normalize($value), $key);
414                 }
415
416                 // 1st argument: CASE sensitive
417                 $this->assertEquals('/ExAMPle', path_normalize('ExAMPle'));
418                 $this->assertEquals('/#hoge',   path_normalize('#hoge'));
419                 $this->assertEquals('/a/b/c/d', path_normalize('/a/b/./c////./d'));
420                 $this->assertEquals('/b/',      path_normalize('/a/../../../b/'));
421
422                 // 2nd argument
423                 $this->assertEquals('\\b\\c\\d\\', path_normalize('\\a\\..\\b\\.\\c\\\\.\\d\\', '\\'));
424                 $this->assertEquals('str1str3str', path_normalize('str1strstr2str..str3str', 'str'));
425                 $this->assertEquals('/do/../nothing/', path_normalize('/do/../nothing/', TRUE));
426                 $this->assertEquals('/do/../nothing/', path_normalize('/do/../nothing/', array('a')));
427                 $this->assertEquals('',            path_normalize(array('a'), array('b')));
428         }
429
430         function testFunc_file_normalize()
431         {
432                 // 1st argument: Null
433                 foreach($this->setup_string_null() as $key => $value){
434                         $this->assertEquals('', file_normalize($value), $key);
435                 }
436
437                 // 1st argument: Cut DirectoryIndexes (Destructive)
438                 foreach(array(
439                         'default.htm',
440                         'default.html',
441                         'default.asp',
442                         'default.aspx',
443 \r                       'index',
444                         'index.htm',
445                         'index.html',
446                         'index.shtml',
447                         'index.jsp',
448                         'index.php',
449                         'index.php',
450                         'index.php3',
451                         'index.php4',
452                         'index.pl',
453                         'index.py',
454                         'index.rb',
455                         'index.cgi',
456
457                         // Apache 2.0.59 default 'index.html' variants
458                         'index.html.ca',
459                         'index.html.cz.iso8859-2',
460                         'index.html.de',
461                         'index.html.dk',
462                         'index.html.ee',
463                         'index.html.el',
464                         'index.html.en',
465                         'index.html.es',
466                         'index.html.et',
467                         'index.html.fr',
468                         'index.html.he.iso8859-8',
469                         'index.html.hr.iso8859-2',
470                         'index.html.it',
471                         'index.html.ja.iso2022-jp',
472                         'index.html.ko.euc-kr',
473                         'index.html.lb.utf8',
474                         'index.html.nl',
475                         'index.html.nn',
476                         'index.html.no',
477                         'index.html.po.iso8859-2',
478                         'index.html.pt',
479                         'index.html.pt-br',
480                         'index.html.ru.cp866',
481                         'index.html.ru.cp-1251',
482                         'index.html.ru.iso-ru',
483                         'index.html.ru.koi8-r',
484                         'index.html.ru.utf8',
485                         'index.html.sv',
486                         'index.html.var',       // default
487                         'index.html.zh-cn.gb2312',
488                         'index.html.zh-tw.big5',
489
490                         'index.html.po.iso8859-2',
491                         'index.html.zh-tw.big5',
492
493                         'index.ja.en.de.html',
494                 
495                         // .gz
496                         'index.html.ca.gz',
497                         'index.html.en.ja.ca.z',
498                 ) as $arg){
499                         $this->assertEquals('', file_normalize($arg));
500                 }
501
502                 //$this->assertEquals('foo/', file_normalize('foo/index.html'));
503
504                 //$this->assertEquals('ExAMPle', file_normalize('ExAMPle'));
505                 //$this->assertEquals('exe.exe', file_normalize('exe.exe'));
506                 //$this->assertEquals('sample.html', file_normalize('sample.html.en'));
507                 //$this->assertEquals('sample.html', file_normalize('sample.html.pt-br'));
508                 //$this->assertEquals('sample.html', file_normalize('sample.html.po.iso8859-2'));
509                 //$this->assertEquals('sample.html', file_normalize('sample.html.zh-tw.big5'));
510         }
511
512         function testFunc_query_normalize()
513         {
514                 // 1st argument: Null
515                 foreach($this->setup_string_null() as $key => $value){
516                         $this->assertEquals('', query_normalize($value), $key);
517                 }
518
519                 $this->assertEquals('a=0dd&b&c&d&f=d', query_normalize('&&&&f=d&b&d&c&a=0dd'));
520                 $this->assertEquals('eg=foobar',       query_normalize('nothing==&eg=dummy&eg=padding&eg=foobar'));
521         }
522
523         function testFunc_generate_glob_regex()
524         {
525                 // 1st argument: Null
526                 foreach($this->setup_string_null() as $key => $value){
527                         $this->assertEquals('', generate_glob_regex($value), $key);
528                 }
529
530                 $this->assertEquals('.*\.txt', generate_glob_regex('*.txt'));
531                 $this->assertEquals('A.A',     generate_glob_regex('A?A'));
532         }
533
534         function testFunc_generate_host_regex()
535         {
536                 // 1st argument: Null
537                 foreach($this->setup_string_null() as $key => $value){
538                         $this->assertEquals('', generate_host_regex($value), $key);
539                 }
540
541                 $this->assertEquals('localhost',             generate_host_regex('localhost'));
542                 $this->assertEquals('example\.org',          generate_host_regex('example.org'));
543                 $this->assertEquals('(?:.*\.)?example\.org', generate_host_regex('.example.org'));
544                 $this->assertEquals('.*\.example\.org',      generate_host_regex('*.example.org'));
545                 $this->assertEquals('.*\..*\.example\.org',  generate_host_regex('*.*.example.org'));
546                 $this->assertEquals('10\.20\.30\.40',        generate_host_regex('10.20.30.40'));
547
548                 // Should match with 192.168.0.0/16
549                 //$this->assertEquals('192\.168\.',       generate_host_regex('192.168.'));
550         }
551
552         function testFunc_get_blocklist()
553         {
554                 if (! defined('SPAM_INI_FILE') || ! file_exists(SPAM_INI_FILE)) {
555                         $this->fail('SPAM_INI_FILE not defined or not found');
556                         return;
557                 }
558
559                 // get_blocklist_add()
560                 $array = array();
561
562                 get_blocklist_add($array,   'foo', 'bar');
563                 $this->assertEquals(1,      count($array));
564                 $this->assertEquals('bar',  $array['foo']);
565
566                 get_blocklist_add($array,   'hoge', 'fuga');
567                 $this->assertEquals(2,      count($array));
568                 $this->assertEquals('bar',  $array['foo']);
569                 $this->assertEquals('fuga', $array['hoge']);
570
571                 get_blocklist_add($array,   -1, '*.txt');
572                 $this->assertEquals(3,      count($array));
573                 $this->assertEquals('bar',  $array['foo']);
574                 $this->assertEquals('fuga', $array['hoge']);
575                 $this->assertEquals('/^.*\.txt$/i', $array['*.txt']);
576
577                 // get_blocklist()
578                 // ALL
579                 $array = get_blocklist();
580                 $this->assertTrue(isset($array['C']));
581                 $this->assertTrue(isset($array['goodhost']));
582                 // badhost
583                 $array = get_blocklist('B-1');
584                 $this->assertTrue(isset($array['*.blogspot.com']));
585                 // goodhost
586                 $array = get_blocklist('goodhost');
587                 $this->assertTrue(isset($array['IANA-examples']));
588         }
589 }
590
591 ?>