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