Annotation of embedaddon/php/ext/standard/tests/file/fopen_variation9.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test fopen() function : variation: use include path and stream context create a file, relative path
        !             3: --CREDITS--
        !             4: Dave Kelsey <d_kelsey@uk.ibm.com>
        !             5: --FILE--
        !             6: <?php
        !             7: /* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
        !             8:  * Description: Open a file or a URL and return a file pointer 
        !             9:  * Source code: ext/standard/file.c
        !            10:  * Alias to functions: 
        !            11:  */
        !            12: 
        !            13: require_once('fopen_include_path.inc');
        !            14: 
        !            15: $thisTestDir =  basename(__FILE__, ".php") . ".dir";
        !            16: mkdir($thisTestDir);
        !            17: chdir($thisTestDir);
        !            18: 
        !            19: $newpath = relative_include_path();
        !            20: set_include_path($newpath);
        !            21: runtest();
        !            22: 
        !            23: $newpath = generate_next_rel_path();
        !            24: set_include_path($newpath);
        !            25: runtest();
        !            26: 
        !            27: teardown_relative_path();
        !            28: restore_include_path();
        !            29: chdir("..");
        !            30: rmdir($thisTestDir);
        !            31: 
        !            32: function runtest() {
        !            33:        $tmpfile =  basename(__FILE__, ".php") . ".tmp";
        !            34:        $h = fopen($tmpfile, "w", true);
        !            35:        fwrite($h, (binary) "This is the test file");
        !            36:        fclose($h);
        !            37:        
        !            38:        
        !            39:        $h = @fopen($tmpfile, "r");
        !            40:        if ($h === false) {
        !            41:           echo "Not created in working dir\n";
        !            42:        }
        !            43:        else {
        !            44:           echo "created in working dir\n";
        !            45:           fclose($h);
        !            46:           unlink($tmpfile);
        !            47:        }
        !            48:        
        !            49:        $h = @fopen('dir1/'.$tmpfile, "r");
        !            50:        if ($h === false) {
        !            51:           echo "Not created in dir1\n";
        !            52:        }
        !            53:        else {
        !            54:           echo "created in dir1\n";
        !            55:           fclose($h);
        !            56:           unlink('dir1/'.$tmpfile);   
        !            57:        }
        !            58: }
        !            59: ?>
        !            60: ===DONE===
        !            61: --EXPECT--
        !            62: created in working dir
        !            63: Not created in dir1
        !            64: created in working dir
        !            65: Not created in dir1
        !            66: ===DONE===

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