Annotation of embedaddon/php/ext/standard/tests/file/touch_variation3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test touch() function : usage variation - different types for time
3: --CREDITS--
4: Dave Kelsey <d_kelsey@uk.ibm.com>
5: --SKIPIF--
6: <?php
7: if (substr(PHP_OS, 0, 3) == 'WIN') {
8: die('skip.. Not for Windows');
9: }
10: ?>
11: --FILE--
12: <?php
13: /* Prototype : bool touch(string filename [, int time [, int atime]])
14: * Description: Set modification time of file
15: * Source code: ext/standard/filestat.c
16: * Alias to functions:
17: */
18:
19: echo "*** Testing touch() : usage variation ***\n";
20:
21: // Define error handler
22: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
23: if (error_reporting() != 0) {
24: // report non-silenced errors
25: echo "Error: $err_no - $err_msg, $filename($linenum)\n";
26: }
27: }
28: set_error_handler('test_error_handler');
29:
30: // Initialise function arguments not being substituted (if any)
31: $filename = 'touchVar2.tmp';
32: $atime = 10;
33:
34: //get an unset variable
35: $unset_var = 10;
36: unset ($unset_var);
37:
38: // define some classes
39: class classWithToString
40: {
41: public function __toString() {
42: return "Class A object";
43: }
44: }
45:
46: class classWithoutToString
47: {
48: }
49:
50: // heredoc string
51: $heredoc = <<<EOT
52: hello world
53: EOT;
54:
55: // add arrays
56: $index_array = array (1, 2, 3);
57: $assoc_array = array ('one' => 1, 'two' => 2);
58:
59: //array of values to iterate over
60: $inputs = array(
61:
62: // float data
63: 'float 10.5' => 10.5,
64: 'float 12.3456789000e10' => 12.3456789000e10,
65: 'float .5' => .5,
66:
67: // array data
68: 'empty array' => array(),
69: 'int indexed array' => $index_array,
70: 'associative array' => $assoc_array,
71: 'nested arrays' => array('foo', $index_array, $assoc_array),
72:
73: // null data
74: 'uppercase NULL' => NULL,
75: 'lowercase null' => null,
76:
77: // boolean data
78: 'lowercase true' => true,
79: 'lowercase false' =>false,
80: 'uppercase TRUE' =>TRUE,
81: 'uppercase FALSE' =>FALSE,
82:
83: // empty data
84: 'empty string DQ' => "",
85: 'empty string SQ' => '',
86:
87: // string data
88: 'string DQ' => "string",
89: 'string SQ' => 'string',
90: 'mixed case string' => "sTrInG",
91: 'heredoc' => $heredoc,
92:
93: // object data
94: 'instance of classWithToString' => new classWithToString(),
95: 'instance of classWithoutToString' => new classWithoutToString(),
96:
97: // undefined data
98: 'undefined var' => @$undefined_var,
99:
100: // unset data
101: 'unset var' => @$unset_var,
102: );
103:
104: // loop through each element of the array for time
105:
106: foreach($inputs as $key =>$value) {
107: echo "\n--$key--\n";
108: var_dump( touch($filename, $value, $atime) );
109: };
110:
111: unlink($filename);
112:
113: ?>
114: ===DONE===
115: --EXPECTF--
116: *** Testing touch() : usage variation ***
117:
118: --float 10.5--
119: bool(true)
120:
121: --float 12.3456789000e10--
122: bool(true)
123:
124: --float .5--
125: bool(true)
126:
127: --empty array--
128: Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
129: NULL
130:
131: --int indexed array--
132: Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
133: NULL
134:
135: --associative array--
136: Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
137: NULL
138:
139: --nested arrays--
140: Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
141: NULL
142:
143: --uppercase NULL--
144: bool(true)
145:
146: --lowercase null--
147: bool(true)
148:
149: --lowercase true--
150: bool(true)
151:
152: --lowercase false--
153: bool(true)
154:
155: --uppercase TRUE--
156: bool(true)
157:
158: --uppercase FALSE--
159: bool(true)
160:
161: --empty string DQ--
162: Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
163: NULL
164:
165: --empty string SQ--
166: Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
167: NULL
168:
169: --string DQ--
170: Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
171: NULL
172:
173: --string SQ--
174: Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
175: NULL
176:
177: --mixed case string--
178: Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
179: NULL
180:
181: --heredoc--
182: Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
183: NULL
184:
185: --instance of classWithToString--
186: Error: 2 - touch() expects parameter 2 to be long, object given, %s(%d)
187: NULL
188:
189: --instance of classWithoutToString--
190: Error: 2 - touch() expects parameter 2 to be long, object given, %s(%d)
191: NULL
192:
193: --undefined var--
194: bool(true)
195:
196: --unset var--
197: bool(true)
198: ===DONE===
199:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>