Annotation of embedaddon/php/ext/standard/tests/file/fgetss_variation1-win32.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test fgetss() function : usage variations - write only modes
3: --SKIPIF--
4: <?php
5: if (substr(PHP_OS, 0, 3) != 'WIN') {
6: die('skip.. only on Windows');
7: }
8: ?>
9: --FILE--
10: <?php
11: /*
12: Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
13: Description: Gets line from file pointer and strip HTML tags
14: */
15:
16: /* try fgets on files which are opened in non readable modes
17: w, wb, wt,
18: a, ab, at,
19: x, xb, xt
20: */
21:
22: // include the common file related test functions
23: include ("file.inc");
24:
25: echo "*** Testing fgetss() : usage variations ***\n";
26:
27: /* string with html and php tags */
28: $string_with_tags = <<<EOT
29: <test>Testing fgetss() functions</test>
30: <?php echo "this string is within php tag"; ?> {;}<{> this
31: is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
32: <html> html </html> <?php echo "php"; ?>
33: this line is without any html and php tags
34: this is a line with more than eighty character,want to check line splitting correctly after 80 characters
35: this text contains some html tags <body> body </body> <br> br </br>
36: this is the line with \n character.
37: EOT;
38:
39: if(substr(PHP_OS, 0, 3) == "WIN") {
40: $string_with_tags = str_replace("\r",'', $string_with_tags);
41: }
42:
43: $filename = dirname(__FILE__)."/fgetss_variation1.tmp";
44:
45: /* try reading the file opened in different modes of reading */
46: $file_modes = array("w","wb", "wt","a", "ab", "at","x","xb","xt");
47:
48: for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
49: echo "\n-- Testing fgetss() with file opened using $file_modes[$mode_counter] mode --\n";
50:
51: /* create an empty file and write the strings with tags */
52: $file_handle = fopen($filename, $file_modes[$mode_counter]);
53: fwrite($file_handle,$string_with_tags);
54: if(!$file_handle) {
55: echo "Error: failed to open file $filename!\n";
56: exit();
57: }
58:
1.1.1.2 ! misho 59: // rewind the file pointer to beginning of the file
1.1 misho 60: var_dump( filesize($filename) );
61: var_dump( rewind($file_handle) );
62: var_dump( ftell($file_handle) );
63: var_dump( feof($file_handle) );
64:
65: /* read entire file and strip tags */
66: echo "-- fgetss() with default length, file pointer at 0 , expected : no character should be read --\n";
67: var_dump( fgetss($file_handle) ); // expected : no character should be read
68: var_dump( ftell($file_handle) ); //ensure that file pointer position is not changed
69: var_dump( feof($file_handle) ); // check if end of file pointer is set
70:
71: // close the file
72: fclose($file_handle);
73:
74: // delete the file
75: delete_file($filename);
76: } // end of for - mode_counter
77:
78: echo "Done\n";
79: ?>
80: --EXPECT--
81: *** Testing fgetss() : usage variations ***
82:
83: -- Testing fgetss() with file opened using w mode --
84: int(445)
85: bool(true)
86: int(0)
87: bool(false)
88: -- fgetss() with default length, file pointer at 0 , expected : no character should be read --
89: bool(false)
90: int(0)
91: bool(false)
92:
93: -- Testing fgetss() with file opened using wb mode --
94: int(445)
95: bool(true)
96: int(0)
97: bool(false)
98: -- fgetss() with default length, file pointer at 0 , expected : no character should be read --
99: bool(false)
100: int(0)
101: bool(false)
102:
103: -- Testing fgetss() with file opened using wt mode --
104: int(453)
105: bool(true)
106: int(0)
107: bool(false)
108: -- fgetss() with default length, file pointer at 0 , expected : no character should be read --
109: bool(false)
110: int(0)
111: bool(false)
112:
113: -- Testing fgetss() with file opened using a mode --
114: int(445)
115: bool(true)
116: int(0)
117: bool(false)
118: -- fgetss() with default length, file pointer at 0 , expected : no character should be read --
119: bool(false)
120: int(0)
121: bool(false)
122:
123: -- Testing fgetss() with file opened using ab mode --
124: int(445)
125: bool(true)
126: int(0)
127: bool(false)
128: -- fgetss() with default length, file pointer at 0 , expected : no character should be read --
129: bool(false)
130: int(0)
131: bool(false)
132:
133: -- Testing fgetss() with file opened using at mode --
134: int(453)
135: bool(true)
136: int(0)
137: bool(false)
138: -- fgetss() with default length, file pointer at 0 , expected : no character should be read --
139: bool(false)
140: int(0)
141: bool(false)
142:
143: -- Testing fgetss() with file opened using x mode --
144: int(445)
145: bool(true)
146: int(0)
147: bool(false)
148: -- fgetss() with default length, file pointer at 0 , expected : no character should be read --
149: bool(false)
150: int(0)
151: bool(false)
152:
153: -- Testing fgetss() with file opened using xb mode --
154: int(445)
155: bool(true)
156: int(0)
157: bool(false)
158: -- fgetss() with default length, file pointer at 0 , expected : no character should be read --
159: bool(false)
160: int(0)
161: bool(false)
162:
163: -- Testing fgetss() with file opened using xt mode --
164: int(453)
165: bool(true)
166: int(0)
167: bool(false)
168: -- fgetss() with default length, file pointer at 0 , expected : no character should be read --
169: bool(false)
170: int(0)
171: bool(false)
172: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>