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

1.1       misho       1: --TEST--
                      2: Test fopen() function : variation: test opening linked files
                      3: --CREDITS--
                      4: Dave Kelsey <d_kelsey@uk.ibm.com>
                      5: --SKIPIF--
                      6: <?php
                      7: if(substr(PHP_OS, 0, 3) == "WIN")
                      8:   die("skip Not for Windows");
                      9: ?>
                     10: --FILE--
                     11: <?php
                     12: /* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
                     13:  * Description: Open a file or a URL and return a file pointer 
                     14:  * Source code: ext/standard/file.c
                     15:  * Alias to functions: 
                     16:  */
                     17: 
                     18: $tmpDir = 'fopenVar19.Dir';
                     19: $realFilename = __FILE__.'.real';
                     20: $sortFilename = __FILE__.'.soft';
                     21: $hardFilename = __FILE__.'.hard';
                     22: $linkOfLink = __FILE__.'.soft2';
                     23: 
                     24: echo "*** Testing fopen() : variation ***\n";
                     25: // start the test
                     26: mkdir($tmpDir);
                     27: chdir($tmpDir);
                     28: 
                     29: $h = fopen($realFilename, "w");
                     30: fwrite($h, "Hello World");
                     31: fclose($h);
                     32: 
                     33: symlink($realFilename, $sortFilename);
                     34: symlink($sortFilename, $linkOfLink);
                     35: link($realFilename, $hardFilename);
                     36: 
                     37: 
                     38: 
                     39: echo "*** testing reading of links ***\n";
                     40: echo "soft link:";
                     41: readFile2($sortFilename);
                     42: echo "hard link:";
                     43: readFile2($hardFilename);
                     44: echo "link of link:";
                     45: readFile2($linkOfLink);
                     46: 
                     47: echo "*** test appending to links ***\n";
                     48: echo "soft link:";
                     49: appendFile($sortFilename);
                     50: echo "hard link:";
                     51: appendFile($hardFilename);
                     52: echo "link of link:";
                     53: appendFile($linkOfLink);
                     54: 
                     55: echo "*** test overwriting links ***\n";
                     56: echo "soft link:";
                     57: writeFile($sortFilename);
                     58: echo "hard link:";
                     59: writeFile($hardFilename);
                     60: echo "link of link:";
                     61: writeFile($linkOfLink);
                     62: 
                     63: unlink($linkOfLink);
                     64: unlink($sortFilename);
                     65: unlink($hardFilename);
                     66: unlink($realFilename);
                     67: chdir("..");
                     68: rmdir($tmpDir);
                     69: 
                     70: function readFile2($file) {
                     71:    $h = fopen($file, 'r');
                     72:    fpassthru($h);
                     73:    fclose($h);
                     74:    echo "\n";
                     75: }
                     76: 
                     77: function appendFile($file) {
                     78:    $h = fopen($file, 'a+');
                     79:    fwrite($h, ' again!');
                     80:    fseek($h, 0);
                     81:    fpassthru($h);
                     82:    fclose($h);
                     83:    echo "\n";
                     84: }
                     85: 
                     86: function writeFile($file) {
                     87:    $h = fopen($file, 'w');
                     88:    fwrite($h, 'Goodbye World');
                     89:    fclose($h);
                     90:    readFile2($file);
                     91: }
                     92: 
                     93: 
                     94: ?>
                     95: ===DONE===
                     96: --EXPECT--
                     97: *** Testing fopen() : variation ***
                     98: *** testing reading of links ***
                     99: soft link:Hello World
                    100: hard link:Hello World
                    101: link of link:Hello World
                    102: *** test appending to links ***
                    103: soft link:Hello World again!
                    104: hard link:Hello World again! again!
                    105: link of link:Hello World again! again! again!
                    106: *** test overwriting links ***
                    107: soft link:Goodbye World
                    108: hard link:Goodbye World
                    109: link of link:Goodbye World
                    110: ===DONE===

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