xref: /PHP-7.0/ext/standard/tests/file/touch.phpt (revision f6897081)
1--TEST--
2touch() tests
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip.. only for Non Windows.');
7}
8?>
9--FILE--
10<?php
11
12// This doesn't work for windows, time, atime usage results in very different
13// output to linux. This could be a php.net bug on windows or a windows querk.
14$filename = dirname(__FILE__)."/touch.dat";
15
16var_dump(touch());
17var_dump(touch($filename));
18var_dump(filemtime($filename));
19@unlink($filename);
20var_dump(touch($filename, 101));
21var_dump(filemtime($filename));
22
23@unlink($filename);
24var_dump(touch($filename, -1));
25var_dump(filemtime($filename));
26
27@unlink($filename);
28var_dump(touch($filename, 100, 100));
29var_dump(filemtime($filename));
30
31@unlink($filename);
32var_dump(touch($filename, 100, -100));
33var_dump(filemtime($filename));
34
35var_dump(touch("/no/such/file/or/directory"));
36
37@unlink($filename);
38
39echo "Done\n";
40?>
41--EXPECTF--
42Warning: touch() expects at least 1 parameter, 0 given in %s on line %d
43NULL
44bool(true)
45int(%d)
46bool(true)
47int(101)
48bool(true)
49int(%i)
50bool(true)
51int(100)
52bool(true)
53int(100)
54
55Warning: touch(): Unable to create file /no/such/file/or/directory because %s in %s on line %d
56bool(false)
57Done
58
59