1--TEST--
2Test touch() function : usage variation - different types for time
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--SKIPIF--
6<?php
7if (substr(PHP_OS, 0, 3) != 'WIN') {
8    die('skip.. only 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
19echo "*** Testing touch() : usage variation ***\n";
20
21// Define error handler
22function 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}
28set_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;
36unset ($unset_var);
37
38// define some classes
39class classWithToString
40{
41	public function __toString() {
42		return "Class A object";
43	}
44}
45
46class classWithoutToString
47{
48}
49
50// heredoc string
51$heredoc = <<<EOT
52hello world
53EOT;
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
106foreach($inputs as $key =>$value) {
107      echo "\n--$key--\n";
108      var_dump( touch($filename, $value, $atime) );
109};
110
111unlink($filename);
112
113?>
114===DONE===
115--EXPECTF--
116*** Testing touch() : usage variation ***
117
118--float 10.5--
119bool(true)
120
121--float 12.3456789000e10--
122bool(true)
123
124--float .5--
125bool(true)
126
127--empty array--
128Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
129NULL
130
131--int indexed array--
132Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
133NULL
134
135--associative array--
136Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
137NULL
138
139--nested arrays--
140Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
141NULL
142
143--uppercase NULL--
144bool(true)
145
146--lowercase null--
147bool(true)
148
149--lowercase true--
150bool(true)
151
152--lowercase false--
153bool(true)
154
155--uppercase TRUE--
156bool(true)
157
158--uppercase FALSE--
159bool(true)
160
161--empty string DQ--
162Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
163NULL
164
165--empty string SQ--
166Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
167NULL
168
169--string DQ--
170Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
171NULL
172
173--string SQ--
174Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
175NULL
176
177--mixed case string--
178Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
179NULL
180
181--heredoc--
182Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
183NULL
184
185--instance of classWithToString--
186Error: 2 - touch() expects parameter 2 to be long, object given, %s(%d)
187NULL
188
189--instance of classWithoutToString--
190Error: 2 - touch() expects parameter 2 to be long, object given, %s(%d)
191NULL
192
193--undefined var--
194bool(true)
195
196--unset var--
197bool(true)
198===DONE===
199
200