kraghuba                Sat Sep 29 09:03:22 2007 UTC

  Modified files:              
    /php-src/ext/standard/tests/strings 
                                        htmlspecialchars_decode_variation1.phpt 
                                        htmlspecialchars_decode_variation2.phpt 
                                        htmlspecialchars_decode_variation3.phpt 
                                        htmlspecialchars_decode_variation4.phpt 
                                        htmlspecialchars_decode_variation5.phpt 
                                        htmlspecialchars_decode_basic.phpt 
                                        htmlspecialchars_decode_variation6.phpt 
                                        htmlspecialchars_decode_error.phpt 
  Log:
  New testcases for htmlspecialchars_decode() function
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: 
php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation1.phpt
diff -u /dev/null 
php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation1.phpt:1.2
--- /dev/null   Sat Sep 29 09:03:22 2007
+++ php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation1.phpt  
Sat Sep 29 09:03:22 2007
@@ -0,0 +1,227 @@
+--TEST--
+Test htmlspecialchars_decode() function : usage variations - unexpected values 
for 'string' argument
+--FILE--
+<?php
+/* Prototype  : string htmlspecialchars_decode(string $string [, int 
$quote_style])
+ * Description: Convert special HTML entities back to characters 
+ * Source code: ext/standard/html.c
+*/
+
+/*
+ * testing htmlspecialchars_decode() with unexpected input values for $string 
argument
+*/
+
+echo "*** Testing htmlspecialchars_decode() : usage variations ***\n";
+
+//get a class
+class classA 
+{
+  function __toString() {
+    return "ClassAObject";
+  }
+}
+
+//get a resource variable
+$file_handle=fopen(__FILE__, "r");
+
+//get an unset variable
+$unset_var = 10;
+unset($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+      // int data
+      0,
+      1,
+      12345,
+      -2345,
+
+      // float data
+      10.5,
+      -10.5,
+      10.5e10,
+      10.6E-10,
+      .5,
+
+      // array data
+      array(),
+      array(0),
+      array(1),
+      array(1, 2),
+      array('color' => 'red', 'item' => 'pen'),
+
+      // null data
+      NULL,
+      null,
+
+      // boolean data
+      true,
+      false,
+      TRUE,
+      FALSE,
+
+      // empty data
+      "",
+      '',
+
+      // object data
+      new classA(),
+
+      // undefined data
+      @$undefined_var,
+
+      // unset data
+      @$unset_var,
+
+      //resource
+      $file_handle
+);
+
+// loop through each element of the array for string
+$iterator = 1;
+foreach($values as $value) {
+      echo "-- Iterator $iterator --\n";
+      var_dump( htmlspecialchars_decode($value) );
+      $iterator++;
+};
+
+// close the file resource used
+fclose($file_handle);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing htmlspecialchars_decode() : usage variations ***
+-- Iterator 1 --
+string(1) "0"
+-- Iterator 2 --
+string(1) "1"
+-- Iterator 3 --
+string(5) "12345"
+-- Iterator 4 --
+string(5) "-2345"
+-- Iterator 5 --
+string(4) "10.5"
+-- Iterator 6 --
+string(5) "-10.5"
+-- Iterator 7 --
+string(12) "105000000000"
+-- Iterator 8 --
+string(7) "1.06E-9"
+-- Iterator 9 --
+string(3) "0.5"
+-- Iterator 10 --
+
+Warning: htmlspecialchars_decode() expects parameter 1 to be string (Unicode 
or binary), array given in %s on line %d
+NULL
+-- Iterator 11 --
+
+Warning: htmlspecialchars_decode() expects parameter 1 to be string (Unicode 
or binary), array given in %s on line %d
+NULL
+-- Iterator 12 --
+
+Warning: htmlspecialchars_decode() expects parameter 1 to be string (Unicode 
or binary), array given in %s on line %d
+NULL
+-- Iterator 13 --
+
+Warning: htmlspecialchars_decode() expects parameter 1 to be string (Unicode 
or binary), array given in %s on line %d
+NULL
+-- Iterator 14 --
+
+Warning: htmlspecialchars_decode() expects parameter 1 to be string (Unicode 
or binary), array given in %s on line %d
+NULL
+-- Iterator 15 --
+string(0) ""
+-- Iterator 16 --
+string(0) ""
+-- Iterator 17 --
+string(1) "1"
+-- Iterator 18 --
+string(0) ""
+-- Iterator 19 --
+string(1) "1"
+-- Iterator 20 --
+string(0) ""
+-- Iterator 21 --
+string(0) ""
+-- Iterator 22 --
+string(0) ""
+-- Iterator 23 --
+string(12) "ClassAObject"
+-- Iterator 24 --
+string(0) ""
+-- Iterator 25 --
+string(0) ""
+-- Iterator 26 --
+
+Warning: htmlspecialchars_decode() expects parameter 1 to be string (Unicode 
or binary), resource given in %s on line %d
+NULL
+Done
+--UEXPECTF--
+*** Testing htmlspecialchars_decode() : usage variations ***
+-- Iterator 1 --
+unicode(1) "0"
+-- Iterator 2 --
+unicode(1) "1"
+-- Iterator 3 --
+unicode(5) "12345"
+-- Iterator 4 --
+unicode(5) "-2345"
+-- Iterator 5 --
+unicode(4) "10.5"
+-- Iterator 6 --
+unicode(5) "-10.5"
+-- Iterator 7 --
+unicode(12) "105000000000"
+-- Iterator 8 --
+unicode(7) "1.06E-9"
+-- Iterator 9 --
+unicode(3) "0.5"
+-- Iterator 10 --
+
+Warning: htmlspecialchars_decode() expects parameter 1 to be string (Unicode 
or binary), array given in %s on line %d
+NULL
+-- Iterator 11 --
+
+Warning: htmlspecialchars_decode() expects parameter 1 to be string (Unicode 
or binary), array given in %s on line %d
+NULL
+-- Iterator 12 --
+
+Warning: htmlspecialchars_decode() expects parameter 1 to be string (Unicode 
or binary), array given in %s on line %d
+NULL
+-- Iterator 13 --
+
+Warning: htmlspecialchars_decode() expects parameter 1 to be string (Unicode 
or binary), array given in %s on line %d
+NULL
+-- Iterator 14 --
+
+Warning: htmlspecialchars_decode() expects parameter 1 to be string (Unicode 
or binary), array given in %s on line %d
+NULL
+-- Iterator 15 --
+unicode(0) ""
+-- Iterator 16 --
+unicode(0) ""
+-- Iterator 17 --
+unicode(1) "1"
+-- Iterator 18 --
+unicode(0) ""
+-- Iterator 19 --
+unicode(1) "1"
+-- Iterator 20 --
+unicode(0) ""
+-- Iterator 21 --
+unicode(0) ""
+-- Iterator 22 --
+unicode(0) ""
+-- Iterator 23 --
+unicode(12) "ClassAObject"
+-- Iterator 24 --
+unicode(0) ""
+-- Iterator 25 --
+unicode(0) ""
+-- Iterator 26 --
+
+Warning: htmlspecialchars_decode() expects parameter 1 to be string (Unicode 
or binary), resource given in %s on line %d
+NULL
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: 
php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation2.phpt
diff -u /dev/null 
php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation2.phpt:1.2
--- /dev/null   Sat Sep 29 09:03:22 2007
+++ php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation2.phpt  
Sat Sep 29 09:03:22 2007
@@ -0,0 +1,288 @@
+--TEST--
+Test htmlspecialchars_decode() function : usage variations - unexpected values 
for 'quote_style' argument
+--FILE--
+<?php
+/* Prototype  : string htmlspecialchars_decode(string $string [, int 
$quote_style])
+ * Description: Convert special HTML entities back to characters 
+ * Source code: ext/standard/html.c
+*/
+
+/*
+ * testing htmlspecialchars_decode() by giving unexpected input values for 
$quote_style argument
+*/
+
+echo "*** Testing htmlspecialchars_decode() : usage variations ***\n";
+
+// Initialise function arguments
+// value initialized = Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 
0000. " double quote string " 
+$string = "<html>Roy&#039;s height &gt; Sam&#039;s height. 13 &lt; 15. 1111 
&amp; 0000 = 0000. &quot; double quote string &quot;</html>";
+
+//get a class
+class classA {
+  function __toString() {
+    return "Class A Object";
+  }
+}
+
+//get a resource variable
+$file_handle = fopen(__FILE__, "r");
+
+//get an unset variable
+$unset_var = 10;
+unset($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+      // float data
+      10.5,
+      -10.5,
+      10.5e10,
+      10.6E-10,
+      .5,
+
+      // array data
+      array(),
+      array(0),
+      array(1),
+      array(1, 2),
+      array('color' => 'red', 'item' => 'pen'),
+
+      // null data
+      NULL,
+      null,
+
+      // boolean data
+      true,
+      false,
+      TRUE,
+      FALSE,
+
+      // empty data
+      "",
+      '',
+
+      // string data
+      "string",
+      'string',
+
+      // object data
+      new classA(),
+
+      // undefined data
+      @$undefined_var,
+
+      // unset data
+      @$unset_var,
+
+      //resource
+      $file_handle
+);
+
+// loop through each element of the array for quote_style
+$iterator = 1;
+foreach($values as $value) {
+      echo "\n-- Iteration $iterator --\n";
+      var_dump( htmlspecialchars_decode($string, $value) );
+      $iterator++;
+}
+
+// close the file resource used
+fclose($file_handle);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing htmlspecialchars_decode() : usage variations ***
+
+-- Iteration 1 --
+string(104) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 
= 0000. " double quote string "</html>"
+
+-- Iteration 2 --
+string(104) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 
= 0000. " double quote string "</html>"
+
+-- Iteration 3 --
+string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 
= 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 4 --
+string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 
= 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 5 --
+string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 
= 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 6 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given 
in %s on line %d
+NULL
+
+-- Iteration 7 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given 
in %s on line %d
+NULL
+
+-- Iteration 8 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given 
in %s on line %d
+NULL
+
+-- Iteration 9 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given 
in %s on line %d
+NULL
+
+-- Iteration 10 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given 
in %s on line %d
+NULL
+
+-- Iteration 11 --
+string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 
= 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 12 --
+string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 
= 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 13 --
+string(104) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. 
&quot; double quote string &quot;</html>"
+
+-- Iteration 14 --
+string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 
= 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 15 --
+string(104) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. 
&quot; double quote string &quot;</html>"
+
+-- Iteration 16 --
+string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 
= 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 17 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, string 
given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, string 
given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, string 
given in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, string 
given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, object 
given in %s on line %d
+NULL
+
+-- Iteration 22 --
+string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 
= 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 23 --
+string(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 0000 
= 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 24 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, resource 
given in %s on line %d
+NULL
+Done
+--UEXPECTF--
+*** Testing htmlspecialchars_decode() : usage variations ***
+
+-- Iteration 1 --
+unicode(104) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 
0000 = 0000. " double quote string "</html>"
+
+-- Iteration 2 --
+unicode(104) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 
0000 = 0000. " double quote string "</html>"
+
+-- Iteration 3 --
+unicode(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 
0000 = 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 4 --
+unicode(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 
0000 = 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 5 --
+unicode(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 
0000 = 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 6 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given 
in %s on line %d
+NULL
+
+-- Iteration 7 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given 
in %s on line %d
+NULL
+
+-- Iteration 8 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given 
in %s on line %d
+NULL
+
+-- Iteration 9 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given 
in %s on line %d
+NULL
+
+-- Iteration 10 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given 
in %s on line %d
+NULL
+
+-- Iteration 11 --
+unicode(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 
0000 = 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 12 --
+unicode(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 
0000 = 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 13 --
+unicode(104) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. 
&quot; double quote string &quot;</html>"
+
+-- Iteration 14 --
+unicode(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 
0000 = 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 15 --
+unicode(104) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. 
&quot; double quote string &quot;</html>"
+
+-- Iteration 16 --
+unicode(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 
0000 = 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 17 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, Unicode 
string given in %s on line %d
+NULL
+
+-- Iteration 18 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, Unicode 
string given in %s on line %d
+NULL
+
+-- Iteration 19 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, Unicode 
string given in %s on line %d
+NULL
+
+-- Iteration 20 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, Unicode 
string given in %s on line %d
+NULL
+
+-- Iteration 21 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, object 
given in %s on line %d
+NULL
+
+-- Iteration 22 --
+unicode(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 
0000 = 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 23 --
+unicode(114) "<html>Roy&#039;s height > Sam&#039;s height. 13 < 15. 1111 & 
0000 = 0000. &quot; double quote string &quot;</html>"
+
+-- Iteration 24 --
+
+Warning: htmlspecialchars_decode() expects parameter 2 to be long, resource 
given in %s on line %d
+NULL
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: 
php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation3.phpt
diff -u /dev/null 
php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation3.phpt:1.2
--- /dev/null   Sat Sep 29 09:03:22 2007
+++ php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation3.phpt  
Sat Sep 29 09:03:22 2007
@@ -0,0 +1,125 @@
+--TEST--
+Test htmlspecialchars_decode() function : usage variations - heredoc strings 
for 'string' argument
+--FILE--
+<?php
+/* Prototype  : string htmlspecialchars_decode(string $string [, int 
$quote_style])
+ * Description: Convert special HTML entities back to characters
+ * Source code: ext/standard/html.c
+*/
+
+/* 
+ * testing htmlspecialchars_decode() with various heredoc strings as argument 
for $string
+*/
+
+echo "*** Testing htmlspecialchars_decode() : usage variations ***\n";
+
+// empty heredoc string
+$empty_string = <<<EOT
+EOT;
+
+// Heredoc string with blank line
+$blank_line = <<<EOT
+
+EOT;
+
+// heredoc with multiline string
+$multiline_string = <<<EOT
+<html>Roy&#039;s height &gt; Sam&#039;s height
+13 &lt; 25
+1111 &amp; 0000 = 0000
+&quot;This is a double quoted string&quot;
+EOT;
+
+// heredoc with diferent whitespaces
+$diff_whitespaces = <<<EOT
+<html>Roy&#039;s height\r &gt; Sam\t&#039;s height
+1111\t\t &amp; 0000\v\v = \f0000
+&quot; heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces&quot;
+EOT;
+
+// heredoc with numeric values
+$numeric_string = <<<EOT
+<html>11 &lt; 12. 123 string 4567
+&quot;string&quot; 1111\t &amp; 0000\t = 0000\n;
+EOT;
+
+// heredoc with quote chars & slash
+$quote_char_string = <<<EOT
+<html>&lt; This's a string with quotes:
+"strings in double quote" &amp;
+'strings in single quote' &quot;
+this\line is &#039;single quoted&#039; /with\slashes </html>
+EOT;
+
+$res_heredoc_strings = array(
+  //heredoc strings
+  $empty_string,
+  $blank_line,
+  $multiline_string,
+  $diff_whitespaces,
+  $numeric_string,
+  $quote_char_string
+);
+
+// loop through $res_heredoc_strings array and check the working on 
htmlspecialchars_decode()
+$count = 1;
+for($index =0; $index < count($res_heredoc_strings); $index ++) {
+  echo "-- Iteration $count --\n";
+  var_dump( htmlspecialchars_decode($res_heredoc_strings[$index]) );
+  $count++;
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing htmlspecialchars_decode() : usage variations ***
+-- Iteration 1 --
+string(0) ""
+-- Iteration 2 --
+string(0) ""
+-- Iteration 3 --
+string(103) "<html>Roy&#039;s height > Sam&#039;s height
+13 < 25
+1111 & 0000 = 0000
+"This is a double quoted string""
+-- Iteration 4 --
+string(130) "<html>Roy&#039;s height > Sam     &#039;s height
+1111            & 0000 = 0000
+" heredoc
+double quoted string. withdifferentwhitespaces""
+-- Iteration 5 --
+string(62) "<html>11 < 12. 123 string 4567
+"string" 1111   & 0000  = 0000
+;"
+-- Iteration 6 --
+string(153) "<html>< This's a string with quotes:
+"strings in double quote" &
+'strings in single quote' "
+this\line is &#039;single quoted&#039; /with\slashes </html>"
+Done
+--UEXPECTF--
+*** Testing htmlspecialchars_decode() : usage variations ***
+-- Iteration 1 --
+unicode(0) ""
+-- Iteration 2 --
+unicode(0) ""
+-- Iteration 3 --
+unicode(103) "<html>Roy&#039;s height > Sam&#039;s height
+13 < 25
+1111 & 0000 = 0000
+"This is a double quoted string""
+-- Iteration 4 --
+unicode(130) "<html>Roy&#039;s height > Sam    &#039;s height
+1111            & 0000 = 0000
+" heredoc
+double quoted string. withdifferentwhitespaces""
+-- Iteration 5 --
+unicode(62) "<html>11 < 12. 123 string 4567
+"string" 1111   & 0000  = 0000
+;"
+-- Iteration 6 --
+unicode(153) "<html>< This's a string with quotes:
+"strings in double quote" &
+'strings in single quote' "
+this\line is &#039;single quoted&#039; /with\slashes </html>"
+Done
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation4.phpt?r1=1.1&r2=1.2&diff_format=u
Index: 
php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation4.phpt
diff -u /dev/null 
php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation4.phpt:1.2
--- /dev/null   Sat Sep 29 09:03:22 2007
+++ php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation4.phpt  
Sat Sep 29 09:03:22 2007
@@ -0,0 +1,93 @@
+--TEST--
+Test htmlspecialchars_decode() function : usage variations - single quoted 
strings for 'string' argument
+--FILE--
+<?php
+/* Prototype  : string htmlspecialchars_decode(string $string [, int 
$quote_style])
+ * Description: Convert special HTML entities back to characters
+ * Source code: ext/standard/html.c
+*/
+
+/*
+ * Testing htmlspecialchars_decode() with various single quoted strings as 
argument for $string
+*/
+
+echo "*** Testing htmlspecialchars_decode() : usage variations ***\n";
+
+//single quoted strings
+$values = array (
+  'Roy&#039s height &gt; Sam&#039;s \$height... 1111 &ap; 0000 = 0000... 
&quot; double quote string &quot;',
+  'Roy&#039;s height &gt; Sam&#039;s height... \t\t 13 &lt; 15...\n\r &quot; 
double quote\f\v string &quot;',
+  '\nRoy&#039;s height &gt\t; Sam&#039;s\v height\f',
+  '\r\tRoy&#039;s height &gt\r; Sam\t&#039;s height',
+  '\n 1\t3 &\tgt; 11 but 11 &\tlt; 12',
+);
+  
+// loop through each element of the values array to check 
htmlspecialchars_decode() function with all possible arguments
+$iterator = 1;
+foreach($values as $value) {
+      echo "-- Iteration $iterator --\n";
+      var_dump( htmlspecialchars_decode($value) );
+      var_dump( htmlspecialchars_decode($value, ENT_COMPAT) );
+      var_dump( htmlspecialchars_decode($value, ENT_NOQUOTES) );
+      var_dump( htmlspecialchars_decode($value, ENT_QUOTES) );
+      $iterator++;
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing htmlspecialchars_decode() : usage variations ***
+-- Iteration 1 --
+string(90) "Roy&#039s height > Sam&#039;s \$height... 1111 &ap; 0000 = 0000... 
" double quote string ""
+string(90) "Roy&#039s height > Sam&#039;s \$height... 1111 &ap; 0000 = 0000... 
" double quote string ""
+string(100) "Roy&#039s height > Sam&#039;s \$height... 1111 &ap; 0000 = 
0000... &quot; double quote string &quot;"
+string(85) "Roy&#039s height > Sam's \$height... 1111 &ap; 0000 = 0000... " 
double quote string ""
+-- Iteration 2 --
+string(88) "Roy&#039;s height > Sam&#039;s height... \t\t 13 < 15...\n\r " 
double quote\f\v string ""
+string(88) "Roy&#039;s height > Sam&#039;s height... \t\t 13 < 15...\n\r " 
double quote\f\v string ""
+string(98) "Roy&#039;s height > Sam&#039;s height... \t\t 13 < 15...\n\r 
&quot; double quote\f\v string &quot;"
+string(78) "Roy's height > Sam's height... \t\t 13 < 15...\n\r " double 
quote\f\v string ""
+-- Iteration 3 --
+string(48) "\nRoy&#039;s height &gt\t; Sam&#039;s\v height\f"
+string(48) "\nRoy&#039;s height &gt\t; Sam&#039;s\v height\f"
+string(48) "\nRoy&#039;s height &gt\t; Sam&#039;s\v height\f"
+string(38) "\nRoy's height &gt\t; Sam's\v height\f"
+-- Iteration 4 --
+string(48) "\r\tRoy&#039;s height &gt\r; Sam\t&#039;s height"
+string(48) "\r\tRoy&#039;s height &gt\r; Sam\t&#039;s height"
+string(48) "\r\tRoy&#039;s height &gt\r; Sam\t&#039;s height"
+string(38) "\r\tRoy's height &gt\r; Sam\t's height"
+-- Iteration 5 --
+string(34) "\n 1\t3 &\tgt; 11 but 11 &\tlt; 12"
+string(34) "\n 1\t3 &\tgt; 11 but 11 &\tlt; 12"
+string(34) "\n 1\t3 &\tgt; 11 but 11 &\tlt; 12"
+string(34) "\n 1\t3 &\tgt; 11 but 11 &\tlt; 12"
+Done
+--UEXPECTF--
+*** Testing htmlspecialchars_decode() : usage variations ***
+-- Iteration 1 --
+unicode(90) "Roy&#039s height > Sam&#039;s \$height... 1111 &ap; 0000 = 
0000... " double quote string ""
+unicode(90) "Roy&#039s height > Sam&#039;s \$height... 1111 &ap; 0000 = 
0000... " double quote string ""
+unicode(100) "Roy&#039s height > Sam&#039;s \$height... 1111 &ap; 0000 = 
0000... &quot; double quote string &quot;"
+unicode(85) "Roy&#039s height > Sam's \$height... 1111 &ap; 0000 = 0000... " 
double quote string ""
+-- Iteration 2 --
+unicode(88) "Roy&#039;s height > Sam&#039;s height... \t\t 13 < 15...\n\r " 
double quote\f\v string ""
+unicode(88) "Roy&#039;s height > Sam&#039;s height... \t\t 13 < 15...\n\r " 
double quote\f\v string ""
+unicode(98) "Roy&#039;s height > Sam&#039;s height... \t\t 13 < 15...\n\r 
&quot; double quote\f\v string &quot;"
+unicode(78) "Roy's height > Sam's height... \t\t 13 < 15...\n\r " double 
quote\f\v string ""
+-- Iteration 3 --
+unicode(48) "\nRoy&#039;s height &gt\t; Sam&#039;s\v height\f"
+unicode(48) "\nRoy&#039;s height &gt\t; Sam&#039;s\v height\f"
+unicode(48) "\nRoy&#039;s height &gt\t; Sam&#039;s\v height\f"
+unicode(38) "\nRoy's height &gt\t; Sam's\v height\f"
+-- Iteration 4 --
+unicode(48) "\r\tRoy&#039;s height &gt\r; Sam\t&#039;s height"
+unicode(48) "\r\tRoy&#039;s height &gt\r; Sam\t&#039;s height"
+unicode(48) "\r\tRoy&#039;s height &gt\r; Sam\t&#039;s height"
+unicode(38) "\r\tRoy's height &gt\r; Sam\t's height"
+-- Iteration 5 --
+unicode(34) "\n 1\t3 &\tgt; 11 but 11 &\tlt; 12"
+unicode(34) "\n 1\t3 &\tgt; 11 but 11 &\tlt; 12"
+unicode(34) "\n 1\t3 &\tgt; 11 but 11 &\tlt; 12"
+unicode(34) "\n 1\t3 &\tgt; 11 but 11 &\tlt; 12"
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation5.phpt?r1=1.1&r2=1.2&diff_format=u
Index: 
php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation5.phpt
diff -u /dev/null 
php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation5.phpt:1.2
--- /dev/null   Sat Sep 29 09:03:22 2007
+++ php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation5.phpt  
Sat Sep 29 09:03:22 2007
@@ -0,0 +1,116 @@
+--TEST--
+Test htmlspecialchars_decode() function : usage variations - double quoted 
strings for 'string' argument
+--FILE--
+<?php
+/* Prototype  : string htmlspecialchars_decode(string $string [, int 
$quote_style])
+ * Description: Convert special HTML entities back to characters
+ * Source code: ext/standard/html.c
+*/
+
+/*
+ * testing htmlspecialchars_decode() for various double quoted strings as 
argument for $string 
+*/
+echo "*** Testing htmlspecialchars_decode() : usage variations ***\n";
+
+//double quoted strings
+$strings = array (
+  "Roy&#039s height &gt; Sam&#039;s \$height... 1111 &ap; 0000 = 0000... 
&quot; double quote string &quot;",
+  "Roy&#039;s height &gt; Sam&#039;s height... \t\t 13 &lt; 15...\n\r &quot; 
double quote\f\v string &quot;",
+  "\nRoy&#039;s height &gt\t; Sam&#039;s\v height\f",
+  "\r\tRoy&#039;s height &gt\r; Sam\t&#039;s height",
+  "\n 1\t3 &\tgt; 11 but 11 &\tlt; 12",
+);
+  
+// loop through each element of the array to check htmlspecialchars_decode() 
function with all possible arguments
+$iterator = 1;
+foreach($strings as $value) {
+      echo "-- Iteration $iterator --\n";
+      var_dump( htmlspecialchars_decode($value) );
+      var_dump( htmlspecialchars_decode($value, ENT_COMPAT) );
+      var_dump( htmlspecialchars_decode($value, ENT_NOQUOTES) );
+      var_dump( htmlspecialchars_decode($value, ENT_QUOTES) );
+      $iterator++;
+}
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing htmlspecialchars_decode() : usage variations ***
+-- Iteration 1 --
+string(89) "Roy&#039s height > Sam&#039;s $height... 1111 &ap; 0000 = 0000... 
" double quote string ""
+string(89) "Roy&#039s height > Sam&#039;s $height... 1111 &ap; 0000 = 0000... 
" double quote string ""
+string(99) "Roy&#039s height > Sam&#039;s $height... 1111 &ap; 0000 = 0000... 
&quot; double quote string &quot;"
+string(84) "Roy&#039s height > Sam's $height... 1111 &ap; 0000 = 0000... " 
double quote string ""
+-- Iteration 2 --
+string(82) "Roy&#039;s height > Sam&#039;s height...            13 < 15...
+ " double quote string ""
+string(82) "Roy&#039;s height > Sam&#039;s height...            13 < 15...
+ " double quote string ""
+string(92) "Roy&#039;s height > Sam&#039;s height...            13 < 15...
+ &quot; double quote string &quot;"
+string(72) "Roy's height > Sam's height...              13 < 15...
+ " double quote string ""
+-- Iteration 3 --
+string(44) "
+Roy&#039;s height &gt  ; Sam&#039;s height"
+string(44) "
+Roy&#039;s height &gt  ; Sam&#039;s height"
+string(44) "
+Roy&#039;s height &gt  ; Sam&#039;s height"
+string(34) "
+Roy's height &gt       ; Sam's height"
+-- Iteration 4 --
+string(44) "   Roy&#039;s height &gt; Sam      &#039;s height"
+string(44) "   Roy&#039;s height &gt; Sam      &#039;s height"
+string(44) "   Roy&#039;s height &gt; Sam      &#039;s height"
+string(34) "   Roy's height &gt; Sam   's height"
+-- Iteration 5 --
+string(30) "
+ 1     3 &     gt; 11 but 11 & lt; 12"
+string(30) "
+ 1     3 &     gt; 11 but 11 & lt; 12"
+string(30) "
+ 1     3 &     gt; 11 but 11 & lt; 12"
+string(30) "
+ 1     3 &     gt; 11 but 11 & lt; 12"
+Done
+--UEXPECTF--
+*** Testing htmlspecialchars_decode() : usage variations ***
+-- Iteration 1 --
+unicode(89) "Roy&#039s height > Sam&#039;s $height... 1111 &ap; 0000 = 0000... 
" double quote string ""
+unicode(89) "Roy&#039s height > Sam&#039;s $height... 1111 &ap; 0000 = 0000... 
" double quote string ""
+unicode(99) "Roy&#039s height > Sam&#039;s $height... 1111 &ap; 0000 = 0000... 
&quot; double quote string &quot;"
+unicode(84) "Roy&#039s height > Sam's $height... 1111 &ap; 0000 = 0000... " 
double quote string ""
+-- Iteration 2 --
+unicode(82) "Roy&#039;s height > Sam&#039;s height...           13 < 15...
+ " double quote string ""
+unicode(82) "Roy&#039;s height > Sam&#039;s height...           13 < 15...
+ " double quote string ""
+unicode(92) "Roy&#039;s height > Sam&#039;s height...           13 < 15...
+ &quot; double quote string &quot;"
+unicode(72) "Roy's height > Sam's height...             13 < 15...
+ " double quote string ""
+-- Iteration 3 --
+unicode(44) "
+Roy&#039;s height &gt  ; Sam&#039;s height"
+unicode(44) "
+Roy&#039;s height &gt  ; Sam&#039;s height"
+unicode(44) "
+Roy&#039;s height &gt  ; Sam&#039;s height"
+unicode(34) "
+Roy's height &gt       ; Sam's height"
+-- Iteration 4 --
+unicode(44) "  Roy&#039;s height &gt; Sam      &#039;s height"
+unicode(44) "  Roy&#039;s height &gt; Sam      &#039;s height"
+unicode(44) "  Roy&#039;s height &gt; Sam      &#039;s height"
+unicode(34) "  Roy's height &gt; Sam   's height"
+-- Iteration 5 --
+unicode(30) "
+ 1     3 &     gt; 11 but 11 & lt; 12"
+unicode(30) "
+ 1     3 &     gt; 11 but 11 & lt; 12"
+unicode(30) "
+ 1     3 &     gt; 11 but 11 & lt; 12"
+unicode(30) "
+ 1     3 &     gt; 11 but 11 & lt; 12"
+Done
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/htmlspecialchars_decode_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/htmlspecialchars_decode_basic.phpt
diff -u /dev/null 
php-src/ext/standard/tests/strings/htmlspecialchars_decode_basic.phpt:1.2
--- /dev/null   Sat Sep 29 09:03:22 2007
+++ php-src/ext/standard/tests/strings/htmlspecialchars_decode_basic.phpt       
Sat Sep 29 09:03:22 2007
@@ -0,0 +1,53 @@
+--TEST--
+Test htmlspecialchars_decode() function : basic functionality 
+--FILE--
+<?php
+/* Prototype  : string htmlspecialchars_decode(string $string [, int 
$quote_style])
+ * Description: Convert special HTML entities back to characters 
+ * Source code: ext/standard/html.c
+*/
+
+echo "*** Testing htmlspecialchars_decode() : basic functionality ***\n";
+
+
+// Initialise arguments 
+//value initialized = Roy's height > Sam's height. 13 < 25. 1111 & 0000 = 
0000. "double quoted string"
+$single_quote_string = "Roy&#039;s height &gt; Sam&#039;s height. 13 &lt; 25. 
1111 &amp; 0000 = 0000. &quot; double quoted string &quot;";
+$double_quote_string = "Roy&#039;s height &gt; Sam&#039;s height. 13 &lt; 25. 
1111 &amp; 0000 = 0000. &quot; double quoted string &quot;";
+
+// Calling htmlspecialchars_decode() with default arguments
+var_dump( htmlspecialchars_decode($single_quote_string) );
+var_dump( htmlspecialchars_decode($double_quote_string) );
+
+// Calling htmlspecialchars_decode() with optional 'quote_style' argument
+var_dump( htmlspecialchars_decode($single_quote_string, ENT_COMPAT) );
+var_dump( htmlspecialchars_decode($double_quote_string, ENT_COMPAT) );   
+var_dump( htmlspecialchars_decode($single_quote_string, ENT_NOQUOTES) );
+var_dump( htmlspecialchars_decode($double_quote_string, ENT_NOQUOTES) );
+var_dump( htmlspecialchars_decode($single_quote_string, ENT_QUOTES) );
+var_dump( htmlspecialchars_decode($double_quote_string, ENT_QUOTES) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing htmlspecialchars_decode() : basic functionality ***
+string(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 
0000. " double quoted string ""
+string(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 
0000. " double quoted string ""
+string(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 
0000. " double quoted string ""
+string(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 
0000. " double quoted string ""
+string(102) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 
0000. &quot; double quoted string &quot;"
+string(102) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 
0000. &quot; double quoted string &quot;"
+string(82) "Roy's height > Sam's height. 13 < 25. 1111 & 0000 = 0000. " double 
quoted string ""
+string(82) "Roy's height > Sam's height. 13 < 25. 1111 & 0000 = 0000. " double 
quoted string ""
+Done
+--UEXPECTF--
+*** Testing htmlspecialchars_decode() : basic functionality ***
+unicode(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 
0000. " double quoted string ""
+unicode(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 
0000. " double quoted string ""
+unicode(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 
0000. " double quoted string ""
+unicode(92) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 
0000. " double quoted string ""
+unicode(102) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 
0000. &quot; double quoted string &quot;"
+unicode(102) "Roy&#039;s height > Sam&#039;s height. 13 < 25. 1111 & 0000 = 
0000. &quot; double quoted string &quot;"
+unicode(82) "Roy's height > Sam's height. 13 < 25. 1111 & 0000 = 0000. " 
double quoted string ""
+unicode(82) "Roy's height > Sam's height. 13 < 25. 1111 & 0000 = 0000. " 
double quoted string ""
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation6.phpt?r1=1.1&r2=1.2&diff_format=u
Index: 
php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation6.phpt
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/htmlspecialchars_decode_error.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/htmlspecialchars_decode_error.phpt
diff -u /dev/null 
php-src/ext/standard/tests/strings/htmlspecialchars_decode_error.phpt:1.2
--- /dev/null   Sat Sep 29 09:03:22 2007
+++ php-src/ext/standard/tests/strings/htmlspecialchars_decode_error.phpt       
Sat Sep 29 09:03:22 2007
@@ -0,0 +1,37 @@
+--TEST--
+Test htmlspecialchars_decode() function : error conditions 
+--FILE--
+<?php
+/* Prototype  : string htmlspecialchars_decode(string $string [, int 
$quote_style])
+ * Description: Convert special HTML entities back to characters 
+ * Source code: ext/standard/html.c
+*/
+
+echo "*** Testing htmlspecialchars_decode() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing htmlspecialchars_decode() function with Zero arguments 
--\n";
+var_dump( htmlspecialchars_decode() );
+
+//Test htmlspecialchars_decode with one more than the expected number of 
arguments
+echo "\n-- Testing htmlspecialchars_decode() function with more than expected 
no. of arguments --\n";
+$string = "<html>hello &amp; &gt; &lt; &quot; &#039; world</html>";
+$quote_style = ENT_COMPAT;
+$extra_arg = 10;
+var_dump( htmlspecialchars_decode($string, $quote_style, $extra_arg) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing htmlspecialchars_decode() : error conditions ***
+
+-- Testing htmlspecialchars_decode() function with Zero arguments --
+
+Warning: htmlspecialchars_decode() expects at least 1 parameter, 0 given in %s 
on line %d
+NULL
+
+-- Testing htmlspecialchars_decode() function with more than expected no. of 
arguments --
+
+Warning: htmlspecialchars_decode() expects at most 2 parameters, 3 given in %s 
on line %d
+NULL
+Done

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to