Annotation of embedaddon/php/ext/standard/tests/strings/htmlspecialchars_decode_variation3.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test htmlspecialchars_decode() function : usage variations - heredoc strings for 'string' argument
3: --FILE--
4: <?php
5: /* Prototype : string htmlspecialchars_decode(string $string [, int $quote_style])
6: * Description: Convert special HTML entities back to characters
7: * Source code: ext/standard/html.c
8: */
9:
10: /*
11: * testing htmlspecialchars_decode() with various heredoc strings as argument for $string
12: */
13:
14: echo "*** Testing htmlspecialchars_decode() : usage variations ***\n";
15:
16: // empty heredoc string
17: $empty_string = <<<EOT
18: EOT;
19:
20: // Heredoc string with blank line
21: $blank_line = <<<EOT
22:
23: EOT;
24:
25: // heredoc with multiline string
26: $multiline_string = <<<EOT
27: <html>Roy's height > Sam's height
28: 13 < 25
29: 1111 & 0000 = 0000
30: "This is a double quoted string"
31: EOT;
32:
1.1.1.2 ! misho 33: // heredoc with different whitespaces
1.1 misho 34: $diff_whitespaces = <<<EOT
35: <html>Roy's height\r > Sam\t's height
36: 1111\t\t & 0000\v\v = \f0000
37: " heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces"
38: EOT;
39:
40: // heredoc with numeric values
41: $numeric_string = <<<EOT
42: <html>11 < 12. 123 string 4567
43: "string" 1111\t & 0000\t = 0000\n;
44: EOT;
45:
46: // heredoc with quote chars & slash
47: $quote_char_string = <<<EOT
48: <html>< This's a string with quotes:
49: "strings in double quote" &
50: 'strings in single quote' "
51: this\line is 'single quoted' /with\slashes </html>
52: EOT;
53:
54: $res_heredoc_strings = array(
55: //heredoc strings
56: $empty_string,
57: $blank_line,
58: $multiline_string,
59: $diff_whitespaces,
60: $numeric_string,
61: $quote_char_string
62: );
63:
64: // loop through $res_heredoc_strings array and check the working on htmlspecialchars_decode()
65: $count = 1;
66: for($index =0; $index < count($res_heredoc_strings); $index ++) {
67: echo "-- Iteration $count --\n";
68: var_dump( htmlspecialchars_decode($res_heredoc_strings[$index]) );
69: $count++;
70: }
71:
72: echo "Done\n";
73: ?>
74: --EXPECTF--
75: *** Testing htmlspecialchars_decode() : usage variations ***
76: -- Iteration 1 --
77: string(0) ""
78: -- Iteration 2 --
79: string(0) ""
80: -- Iteration 3 --
81: string(103) "<html>Roy's height > Sam's height
82: 13 < 25
83: 1111 & 0000 = 0000
84: "This is a double quoted string""
85: -- Iteration 4 --
86: string(130) "<html>Roy's height
> Sam 's height
87: 1111 & 0000 = 0000
88: " heredoc
89: double quoted string. withdifferentwhitespaces""
90: -- Iteration 5 --
91: string(62) "<html>11 < 12. 123 string 4567
92: "string" 1111 & 0000 = 0000
93: ;"
94: -- Iteration 6 --
95: string(153) "<html>< This's a string with quotes:
96: "strings in double quote" &
97: 'strings in single quote' "
98: this\line is 'single quoted' /with\slashes </html>"
99: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>