Annotation of embedaddon/php/ext/standard/tests/file/fileinode_variation.phpt, revision 1.1.1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>