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

1.1     ! misho       1: --TEST--
        !             2: Test fflush() function: basic functionality
        !             3: --FILE--
        !             4: <?php
        !             5: /*  Prototype: bool fflush ( resource $handle );
        !             6:     Description: Flushes the output to a file
        !             7: */
        !             8: 
        !             9: echo "*** Testing fflush(): writing to a file and reading the contents ***\n";
        !            10: $data = <<<EOD
        !            11: first line of string
        !            12: second line of string
        !            13: third line of string
        !            14: EOD;
        !            15: 
        !            16: $file_path = dirname(__FILE__);
        !            17: $filename = "$file_path/fflush_basic.tmp";
        !            18: 
        !            19: // opening a file
        !            20: $file_handle = fopen($filename, "w");
        !            21: if($file_handle == false)
        !            22:   exit("Error:failed to open file $filename");
        !            23: 
        !            24: if(substr(PHP_OS, 0, 3) == "WIN")  {
        !            25:        $data = str_replace("\r",'', $data);
        !            26: }
        !            27: 
        !            28: // writing data to the file
        !            29: var_dump( fwrite($file_handle, $data) );
        !            30: var_dump( fflush($file_handle) );
        !            31: var_dump( readfile($filename) );
        !            32: 
        !            33: echo "\n*** Testing fflush(): for return type ***\n";
        !            34: $return_value = fflush($file_handle);
        !            35: var_dump( is_bool($return_value) );
        !            36: fclose($file_handle);
        !            37: echo "\n*** Done ***";
        !            38: ?>
        !            39: 
        !            40: --CLEAN--
        !            41: <?php
        !            42: $file_path = dirname(__FILE__);
        !            43: $filename = "$file_path/fflush_basic.tmp";
        !            44: unlink($filename);
        !            45: ?>
        !            46: 
        !            47: --EXPECTF--
        !            48: *** Testing fflush(): writing to a file and reading the contents ***
        !            49: int(63)
        !            50: bool(true)
        !            51: first line of string
        !            52: second line of string
        !            53: third line of stringint(63)
        !            54: 
        !            55: *** Testing fflush(): for return type ***
        !            56: bool(true)
        !            57: 
        !            58: *** Done ***

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