1--TEST--
2Test fileinode() function: Variations
3--SKIPIF--
4<?php
5if (PHP_OS_FAMILY === 'Windows') {
6    require_once __DIR__ . '/windows_links/common.inc';
7    skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
8}
9?>
10--FILE--
11<?php
12echo "*** Testing fileinode() with files, links and directories ***\n";
13$file_path = __DIR__;
14$file1 = $file_path."/fileinode1_variation.tmp";
15$file2 = $file_path."/fileinode2_variation.tmp";
16$link1 = $file_path."/fileinode1_variation_link.tmp";
17$link2 = $file_path."/fileinode2_variation_link.tmp";
18
19
20echo "-- Testing with files --\n";
21//creating the files
22fclose( fopen( $file1, "w" ) );
23fclose( fopen( $file2, "w" ) );
24
25print( fileinode( $file1) )."\n";
26print( fileinode( $file2) )."\n";
27clearstatcache();
28
29echo "-- Testing with links: hard link --\n";
30link( $file1, $link1);  // Creating an hard link
31print( fileinode( $file1) )."\n";
32clearstatcache();
33print( fileinode( $link1) )."\n";
34clearstatcache();
35
36echo "-- Testing with links: soft link --\n";
37symlink( $file2, $link2);  // Creating a soft link
38print( fileinode( $file2) )."\n";
39clearstatcache();
40print( fileinode( $link2) )."\n";
41
42unlink( $link1 );
43unlink( $link2 );
44
45echo "-- Testing after copying a file --\n";
46copy( $file1, $file_path."/fileinode1_variation_new.tmp");
47print( fileinode( $file1) )."\n";
48clearstatcache();
49print( fileinode( $file_path."/fileinode1_variation_new.tmp") )."\n";
50
51unlink( $file_path."/fileinode1_variation_new.tmp");
52unlink( $file1);
53unlink( $file2);
54
55
56echo "-- Testing after renaming the file --\n";
57fclose( fopen("$file_path/old.txt", "w") );
58print( fileinode("$file_path/old.txt") )."\n";
59clearstatcache();
60
61rename("$file_path/old.txt", "$file_path/new.txt");
62print( fileinode("$file_path/new.txt") )."\n";
63
64unlink("$file_path/new.txt");
65
66echo "-- Testing with directories --\n";
67mkdir("$file_path/dir");
68print( fileinode("$file_path/dir") )."\n";
69clearstatcache();
70
71mkdir("$file_path/dir/subdir");
72print( fileinode("$file_path/dir/subdir") )."\n";
73clearstatcache();
74
75echo "-- Testing with binary input --\n";
76print( fileinode(b"$file_path/dir") )."\n";
77clearstatcache();
78print( fileinode(b"$file_path/dir/subdir") );
79
80rmdir("$file_path/dir/subdir");
81rmdir("$file_path/dir");
82
83echo "\n*** Done ***";
84?>
85--EXPECTF--
86*** Testing fileinode() with files, links and directories ***
87-- Testing with files --
88%i
89%i
90-- Testing with links: hard link --
91%i
92%i
93-- Testing with links: soft link --
94%i
95%i
96-- Testing after copying a file --
97%i
98%i
99-- Testing after renaming the file --
100%i
101%i
102-- Testing with directories --
103%i
104%i
105-- Testing with binary input --
106%i
107%i
108*** Done ***
109