1--TEST--
2Test lstat() and stat() functions: usage variations - effects of touch() on link
3--SKIPIF--
4<?php
5if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
6
7if (PHP_OS_FAMILY === 'Windows') {
8    include_once __DIR__ . '/windows_links/common.inc';
9    skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
10} else {
11// checking for atime update whether it is enabled or disabled
12    exec("mount", $mount_output);
13    foreach( $mount_output as $out )  {
14    if( stristr($out, "noatime") )
15        die('skip.. atime update is disabled, hence skip the test');
16    }
17}
18?>
19--FILE--
20<?php
21/* test the effects of touch() on stats of link */
22
23$file_path = __DIR__;
24require "$file_path/file.inc";
25
26
27/* create temp file, link and directory */
28
29$file_name = "$file_path/lstat_stat_variation6.tmp";
30$fp = fopen($file_name, "w");  // temp file
31fclose($fp);
32$link_name = "$file_path/lstat_stat_variation_link6.tmp";
33symlink($file_name, $link_name);  // temp link
34
35// touch a link, check stat, there should be difference in atime
36echo "*** Testing lstat() for link after using touch() on the link ***\n";
37$old_stat = lstat($link_name);
38sleep(2);
39
40// clear the cache
41clearstatcache();
42
43var_dump( touch($link_name) );
44
45$new_stat = stat($file_name);
46
47// compare self stats
48var_dump( compare_self_stat($old_stat) );
49var_dump( compare_self_stat($new_stat) );
50
51// compare the stat
52$affected_members = array(8, 'atime');
53var_dump( compare_stats($old_stat, $new_stat, $affected_members, "<") );
54// clear the stat
55clearstatcache();
56
57echo "\n--- Done ---";
58?>
59--CLEAN--
60<?php
61$file_path = __DIR__;
62unlink("$file_path/lstat_stat_variation6.tmp");
63unlink("$file_path/lstat_stat_variation_link6.tmp");
64?>
65--EXPECT--
66*** Testing lstat() for link after using touch() on the link ***
67bool(true)
68bool(true)
69bool(true)
70bool(true)
71
72--- Done ---
73