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

1.1       misho       1: --TEST--
                      2: est file_put_contents() function : usage variation - 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 Do not run on Windows");
                      9: ?>
                     10: --FILE--
                     11: <?php
                     12: /* Prototype  : int file_put_contents(string file, mixed data [, int flags [, resource context]])
                     13:  * Description: Write/Create a file with contents data and return the number of bytes written 
                     14:  * Source code: ext/standard/file.c
                     15:  * Alias to functions: 
                     16:  */
                     17: 
                     18: echo "*** Testing file_put_contents() : usage variation ***\n";
                     19: 
                     20: $filename = dirname(__FILE__).'/fileGetContentsVar9.tmp';
                     21: $softlink = dirname(__FILE__).'/fileGetContentsVar9.SoftLink';
                     22: $hardlink = dirname(__FILE__).'/fileGetContentsVar9.HardLink';
                     23: $chainlink = dirname(__FILE__).'/fileGetContentsVar9.ChainLink';
                     24: 
                     25: 
                     26: // link files even though it original file doesn't exist yet
                     27: symlink($filename, $softlink);
                     28: symlink($softlink, $chainlink);
                     29: 
                     30: 
                     31: // perform tests
                     32: run_test($chainlink);
                     33: run_test($softlink);
                     34: 
                     35: //can only create a hardlink if the file exists.
                     36: file_put_contents($filename,"");
                     37: link($filename, $hardlink); 
                     38: run_test($hardlink);
                     39: 
                     40: unlink($chainlink);
                     41: unlink($softlink);
                     42: unlink($hardlink);
                     43: unlink($filename);
                     44: 
                     45: 
                     46: function run_test($file) {
                     47:     $data = "Here is some data";
                     48:     $extra = ", more data";
                     49:     var_dump(file_put_contents($file, $data));
                     50:     var_dump(file_put_contents($file, $extra, FILE_APPEND));
                     51:     readfile($file);
                     52:     echo "\n";
                     53: }
                     54: 
                     55: 
                     56: echo "\n*** Done ***\n";
                     57: ?>
                     58: --EXPECT--
                     59: *** Testing file_put_contents() : usage variation ***
                     60: int(17)
                     61: int(11)
                     62: Here is some data, more data
                     63: int(17)
                     64: int(11)
                     65: Here is some data, more data
                     66: int(17)
                     67: int(11)
                     68: Here is some data, more data
                     69: 
                     70: *** Done ***

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