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
12/*
13Prototype: int fileinode ( string $filename );
14Description: Returns the inode number of the file, or FALSE in case of an error.
15*/
16
17echo "*** Testing fileinode() with files, links and directories ***\n";
18$file_path = __DIR__;
19$file1 = $file_path."/fileinode1_variation.tmp";
20$file2 = $file_path."/fileinode2_variation.tmp";
21$link1 = $file_path."/fileinode1_variation_link.tmp";
22$link2 = $file_path."/fileinode2_variation_link.tmp";
23
24
25echo "-- Testing with files --\n";
26//creating the files
27fclose( fopen( $file1, "w" ) );
28fclose( fopen( $file2, "w" ) );
29
30print( fileinode( $file1) )."\n";
31print( fileinode( $file2) )."\n";
32clearstatcache();
33
34echo "-- Testing with links: hard link --\n";
35link( $file1, $link1);  // Creating an hard link
36print( fileinode( $file1) )."\n";
37clearstatcache();
38print( fileinode( $link1) )."\n";
39clearstatcache();
40
41echo "-- Testing with links: soft link --\n";
42symlink( $file2, $link2);  // Creating a soft link
43print( fileinode( $file2) )."\n";
44clearstatcache();
45print( fileinode( $link2) )."\n";
46
47unlink( $link1 );
48unlink( $link2 );
49
50echo "-- Testing after copying a file --\n";
51copy( $file1, $file_path."/fileinode1_variation_new.tmp");
52print( fileinode( $file1) )."\n";
53clearstatcache();
54print( fileinode( $file_path."/fileinode1_variation_new.tmp") )."\n";
55
56unlink( $file_path."/fileinode1_variation_new.tmp");
57unlink( $file1);
58unlink( $file2);
59
60
61echo "-- Testing after renaming the file --\n";
62fclose( fopen("$file_path/old.txt", "w") );
63print( fileinode("$file_path/old.txt") )."\n";
64clearstatcache();
65
66rename("$file_path/old.txt", "$file_path/new.txt");
67print( fileinode("$file_path/new.txt") )."\n";
68
69unlink("$file_path/new.txt");
70
71echo "-- Testing with directories --\n";
72mkdir("$file_path/dir");
73print( fileinode("$file_path/dir") )."\n";
74clearstatcache();
75
76mkdir("$file_path/dir/subdir");
77print( fileinode("$file_path/dir/subdir") )."\n";
78clearstatcache();
79
80echo "-- Testing with binary input --\n";
81print( fileinode(b"$file_path/dir") )."\n";
82clearstatcache();
83print( fileinode(b"$file_path/dir/subdir") );
84
85rmdir("$file_path/dir/subdir");
86rmdir("$file_path/dir");
87
88echo "\n*** Done ***";
89--EXPECTF--
90*** Testing fileinode() with files, links and directories ***
91-- Testing with files --
92%i
93%i
94-- Testing with links: hard link --
95%i
96%i
97-- Testing with links: soft link --
98%i
99%i
100-- Testing after copying a file --
101%i
102%i
103-- Testing after renaming the file --
104%i
105%i
106-- Testing with directories --
107%i
108%i
109-- Testing with binary input --
110%i
111%i
112*** Done ***
113