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/* Prototype: array lstat ( string $filename );
22   Description: Gives information about a file or symbolic link
23
24   Prototype: array stat ( string $filename );
25   Description: Gives information about a file
26*/
27
28/* test the effects of touch() on stats of link */
29
30$file_path = __DIR__;
31require "$file_path/file.inc";
32
33
34/* create temp file, link and directory */
35
36$file_name = "$file_path/lstat_stat_variation6.tmp";
37$fp = fopen($file_name, "w");  // temp file
38fclose($fp);
39$link_name = "$file_path/lstat_stat_variation_link6.tmp";
40symlink($file_name, $link_name);  // temp link
41
42// touch a link, check stat, there should be difference in atime
43echo "*** Testing lstat() for link after using touch() on the link ***\n";
44$old_stat = lstat($link_name);
45sleep(2);
46
47// clear the cache
48clearstatcache();
49
50var_dump( touch($link_name) );
51
52$new_stat = stat($file_name);
53
54// compare self stats
55var_dump( compare_self_stat($old_stat) );
56var_dump( compare_self_stat($new_stat) );
57
58// compare the stat
59$affected_members = array(8, 'atime');
60var_dump( compare_stats($old_stat, $new_stat, $affected_members, "<") );
61// clear the stat
62clearstatcache();
63
64echo "\n--- Done ---";
65?>
66--CLEAN--
67<?php
68$file_path = __DIR__;
69unlink("$file_path/lstat_stat_variation6.tmp");
70unlink("$file_path/lstat_stat_variation_link6.tmp");
71?>
72--EXPECT--
73*** Testing lstat() for link after using touch() on the link ***
74bool(true)
75bool(true)
76bool(true)
77bool(true)
78
79--- Done ---
80