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

1.1       misho       1: --TEST--
                      2: Test file_put_contents() function : variation - include path testing
                      3: --CREDITS--
                      4: Dave Kelsey <d_kelsey@uk.ibm.com>
                      5: --FILE--
                      6: <?php
                      7: /* Prototype  : int file_put_contents(string file, mixed data [, int flags [, resource context]])
                      8:  * Description: Write/Create a file with contents data and return the number of bytes written 
                      9:  * Source code: ext/standard/file.c
                     10:  * Alias to functions: 
                     11:  */
                     12: 
                     13: echo "*** Testing file_put_contents() : variation ***\n";
                     14: 
                     15: require_once('fopen_include_path.inc');
                     16: 
                     17: $thisTestDir = basename(__FILE__, ".php") . ".dir";
                     18: mkdir($thisTestDir);
                     19: chdir($thisTestDir);
                     20: 
                     21: $filename = basename(__FILE__, ".php") . ".tmp";
                     22: 
                     23: $newpath = create_include_path();
                     24: set_include_path($newpath);
                     25: runtest();
                     26: 
                     27: $newpath = generate_next_path();
                     28: set_include_path($newpath);
                     29: runtest();
                     30: 
                     31: teardown_include_path();
                     32: restore_include_path();
                     33: chdir("..");
                     34: rmdir($thisTestDir);
                     35: 
                     36: 
                     37: function runtest() {
                     38:    global $filename;
                     39: 
                     40:    //correct php53 behaviour is to ignore the FILE_USE_INCLUDE_PATH unless the file already exists 
                     41:    // in the include path. In this case it doesn't so the file should be written in the current dir.
                     42: 
                     43:    file_put_contents($filename, (binary) "File in include path", FILE_USE_INCLUDE_PATH);
                     44:    file_put_contents($filename, (binary) ". This was appended", FILE_USE_INCLUDE_PATH | FILE_APPEND);  
                     45:    $line = file_get_contents($filename);
                     46:    echo "$line\n";
                     47:    unlink($filename); 
                     48: }
                     49: 
                     50: ?>
                     51: ===DONE===
                     52: --EXPECT--
                     53: *** Testing file_put_contents() : variation ***
                     54: File in include path. This was appended
                     55: File in include path. This was appended
                     56: ===DONE===

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