]> granicus.if.org Git - php/commitdiff
Big filter test - note that a number of these currently fail
authorRasmus Lerdorf <rasmus@php.net>
Thu, 25 May 2006 08:06:34 +0000 (08:06 +0000)
committerRasmus Lerdorf <rasmus@php.net>
Thu, 25 May 2006 08:06:34 +0000 (08:06 +0000)
ext/filter/tests/033.php [new file with mode: 0644]
ext/filter/tests/033.phpt [new file with mode: 0644]

diff --git a/ext/filter/tests/033.php b/ext/filter/tests/033.php
new file mode 100644 (file)
index 0000000..229e7ba
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+function test($data) {
+  return strtoupper($data);
+}
+$data = array("PHP","1","foo@bar.com","http://a.b.c","1.2.3.4","123","123abc<>()","O'Henry", "하퍼");
+foreach(input_filters_list() as $filter) {
+  if($filter=="validate_regexp") {
+    foreach($data as $k=>$d) $result[$k] = filter_data($d,input_name_to_filter($filter),array("regexp"=>'/^O.*/'));
+  } else {
+    foreach($data as $k=>$d) $result[$k] = filter_data($d,input_name_to_filter($filter),"test");
+  }
+  printf("%-20s",$filter);
+  printf("%-5s",$result[0]);
+  printf("%-3s",$result[1]);
+  printf("%-15s",$result[2]);
+  printf("%-20s",$result[3]);
+  printf("%-10s",$result[4]);
+  printf("%-5s",$result[5]);
+  printf("%-20s",$result[6]);
+  printf("%-15s",$result[7]);
+  printf("%-10s\n",$result[8]);
+}
+?>
diff --git a/ext/filter/tests/033.phpt b/ext/filter/tests/033.phpt
new file mode 100644 (file)
index 0000000..6162407
--- /dev/null
@@ -0,0 +1,25 @@
+--TEST--
+Test all filters returned by input_filters_list()
+--FILE--
+<?php
+include './033.php';
+?>
+--EXPECT--     
+int                      1                                               123                                               
+boolean                  1                                                                                                 
+float                    1                                                                                                 
+validate_regexp                                                                                   O'Henry                  
+validate_url                               http://a.b.c
+validate_email              foo@bar.com                                                                                    
+validate_ip                                                    1.2.3.4                                                     
+string              PHP  1  foo@bar.com    http://a.b.c        1.2.3.4   123  123abc()            O&#39;Henry    하퍼    
+stripped            PHP  1  foo@bar.com    http://a.b.c        1.2.3.4   123  123abc()            OHenry         하퍼    
+encoded             PHP  1  foo%40bar.com  http%3A%2F%2Fa.b.c  1.2.3.4   123  123abc%3C%3E%28%29  O%27Henry      %ED%95%98%ED%8D%BC
+special_chars       PHP  1  foo@bar.com    http://a.b.c        1.2.3.4   123  123abc&#60;&#62;()  O&#39;Henry    하퍼    
+unsafe_raw          PHP  1  foo@bar.com    http://a.b.c        1.2.3.4   123  123abc<>()          O'Henry        하퍼    
+email               PHP  1  foo@bar.com    http//a.b.c         1.2.3.4   123  123abc              O'Henry                  
+url                 PHP  1  foo@bar.com    http://a.b.c        1.2.3.4   123  123abc<>()          O'Henry                  
+number_int               1                                               123  123                                          
+number_float             1                                               123  123                                          
+magic_quotes        PHP  1  foo@bar.com    http://a.b.c        1.2.3.4   123  123abc<>()          O\'Henry       하퍼    
+callback            PHP  1  FOO@BAR.COM    HTTP://A.B.C        1.2.3.4   123  123ABC<>()          O'HENRY        하퍼