cvs: php-src /ext/standard/tests/file fflush_basic.phpt fflush_error.phpt fflush_variation1-win32.phpt fflush_variation1.phpt fflush_variation2.phpt
fflush_variation3.phpt fflush_variation4.phpt

From: Date: Sat, 21 Jul 2007 17:19:27 +0000
Subject: cvs: php-src /ext/standard/tests/file fflush_basic.phpt fflush_error.phpt fflush_variation1-win32.phpt fflush_variation1.phpt fflush_variation2.phpt
fflush_variation3.phpt fflush_variation4.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-45488@lists.php.net to get a copy of this message
kraghuba Sat Jul 21 17:19:27 2007 UTC Modified files: /php-src/ext/standard/tests/file fflush_variation3.phpt fflush_variation4.phpt fflush_variation1-win32.phpt fflush_basic.phpt fflush_error.phpt fflush_variation1.phpt fflush_variation2.phpt Log: New testcases for fflush() function

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fflush_variation3.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fflush_variation3.phpt diff -u /dev/null php-src/ext/standard/tests/file/fflush_variation3.phpt:1.2 --- /dev/null Sat Jul 21 17:19:27 2007 +++ php-src/ext/standard/tests/file/fflush_variation3.phpt Sat Jul 21 17:19:27 2007 @@ -0,0 +1,698 @@ +--TEST-- +Test fflush() function: usage variations - hard links as resource +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) == 'WIN') + die("skip Links not valid on Windows"); +?> +--FILE-- +<?php +/* Prototype: bool fflush ( resource $handle ); + Description: Flushes the output to a file +*/ + +/* test fflush() with handle to hard links as resource */ + +$file_path = dirname(__FILE__); +require $file_path.'/file.inc'; + +echo "*** Testing fflush(): with hard links to files opened in diff modes ***\n"; +$file_types = array("empty", "numeric", "text", "text_with_new_line", "alphanumeric"); +$file_modes = array("w", "wb", "wt", "w+", "w+b","w+t", + "a", "ab", "at", "a+","a+b", "a+t"); + +$file_name = "$file_path/fflush_variation3.tmp"; +$link_name = "$file_path/lnk_fflush_variation3.tmp"; + +$count = 1; + +foreach( $file_types as $type ) { + echo "-- Iteration $count with file containing $type data --\n"; + foreach( $file_modes as $mode ) { + + // creating the file + $file_handle = fopen($file_name, "w"); + if($file_handle == false) + exit("Error:failed to open file $file_name"); + + // fill the fill with some data if mode is append mode + if( substr($mode, 0, 1) == "a" ) + fill_file($file_handle, $type, 10); + + // fclose($file_handle); + + // creating hard link to the file + var_dump( link($file_name, $link_name) ); + + // opening the file in different modes + $file_handle = fopen($link_name, $mode); + if($file_handle == false) + exit("Error:failed to open link $link_name"); + + // writing data to the file + var_dump( fill_file($file_handle, $type, 50) ); + var_dump( fflush($file_handle) ); + fclose($file_handle); + + // reading data from the file after flushing + var_dump( readfile($link_name) ); + + unlink($link_name); + unlink($file_name); + } + $count++; +} + +echo "\n*** Done ***"; +?> +--EXPECTF-- +*** Testing fflush(): with hard links to files opened in diff modes *** +-- Iteration 1 with file containing empty data -- +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +-- Iteration 2 with file containing numeric data -- +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- Iteration 3 with file containing text data -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- Iteration 4 with file containing text_with_new_line data -- +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- Iteration 5 with file containing alphanumeric data -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) + +*** Done *** + +--UEXPECTF-- +*** Testing fflush(): with hard links to files opened in diff modes *** +-- Iteration 1 with file containing empty data -- +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +bool(true) +bool(true) +bool(true) +int(0) +-- Iteration 2 with file containing numeric data -- +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- Iteration 3 with file containing text data -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- Iteration 4 with file containing text_with_new_line data -- +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- Iteration 5 with file containing alphanumeric data -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) + +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fflush_variation4.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fflush_variation4.phpt diff -u /dev/null php-src/ext/standard/tests/file/fflush_variation4.phpt:1.2 --- /dev/null Sat Jul 21 17:19:27 2007 +++ php-src/ext/standard/tests/file/fflush_variation4.phpt Sat Jul 21 17:19:27 2007 @@ -0,0 +1,63 @@ +--TEST-- +Test fflush() function: usage variations - file opened in read-only mode +--FILE-- +<?php +/* Prototype: bool fflush ( resource $handle ); + Description: Flushes the output to a file +*/ + +/* test fflush() with handle to a file opened in read-only mode as resource */ + +$file_path = dirname(__FILE__); +require $file_path.'/file.inc'; + +echo "*** Testing fflush(): with file handles of files opened in various read modes ***\n"; +$file_modes = array("r", "rb", "rt"); + +$file_name = "$file_path/fflush_variation4.tmp"; + +$count = 1; + +foreach( $file_modes as $mode ) { + echo "-- Iteration $count with file opened in $mode mode --\n"; + + // creating a file + $file_handle = fopen($file_name, "w"); + if($file_handle == false) + exit("Error:failed to open file $file_name"); + fclose($file_handle); + + // opening the file in different read modes + $file_handle = fopen($file_name, $mode); + if($file_handle == false) + exit("Error:failed to open file $file_name"); + var_dump( fflush($file_handle) ); + fclose($file_handle); + + unlink($file_name); + $count++; +} + +echo "\n*** Done ***"; +?> +--EXPECTF-- +*** Testing fflush(): with file handles of files opened in various read modes *** +-- Iteration 1 with file opened in r mode -- +bool(true) +-- Iteration 2 with file opened in rb mode -- +bool(true) +-- Iteration 3 with file opened in rt mode -- +bool(true) + +*** Done *** + +--UEXPECTF-- +*** Testing fflush(): with file handles of files opened in various read modes *** +-- Iteration 1 with file opened in r mode -- +bool(true) +-- Iteration 2 with file opened in rb mode -- +bool(true) +-- Iteration 3 with file opened in rt mode -- +bool(true) + +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fflush_variation1-win32.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fflush_variation1-win32.phpt diff -u /dev/null php-src/ext/standard/tests/file/fflush_variation1-win32.phpt:1.2 --- /dev/null Sat Jul 21 17:19:27 2007 +++ php-src/ext/standard/tests/file/fflush_variation1-win32.phpt Sat Jul 21 17:19:27 2007 @@ -0,0 +1,996 @@ +--TEST-- +Test fflush() function: usage variations - files in different modes +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) != "WIN" ) + die("skip.. only for Windows"); +?> + +--FILE-- +<?php +/* Prototype: bool fflush ( resource $handle ); + Description: Flushes the output to a file +*/ + +/* test fflush() with handle to the files opened in different modes */ + +$file_path = dirname(__FILE__); +require $file_path.'/file.inc'; + +echo "*** Testing fflush(): with various types of files ***\n"; +$file_types = array("empty", "numeric", "text", "text_with_new_line", "alphanumeric"); +$file_modes = array("w", "wb", "wt", "w+", "w+b", "w+t", + "a", "ab", "at", "a+","a+b", "a+t", + "x", "xb", "xt", "x+", "x+b", "x+t"); + +$file_name = "$file_path/fflush_variation1.tmp"; + +$count = 1; + +foreach( $file_types as $type ) { + echo "-- Iteration $count with file containing $type Data--\n"; + foreach( $file_modes as $mode ) { + echo "-- File opened in $mode mode --\n"; + + // creating the file except for x mode + if( substr($mode, 0, 1) != "x" ) { + $file_handle = fopen($file_name, "w"); + if($file_handle == false) + exit("Error:failed to open file $file_name"); + + // filling the file some data if mode is append mode + if( substr($mode, 0, 1) == "a") + fill_file($file_handle, $type, 10); + fclose($file_handle); + } + + // opening the file in different modes + $file_handle = fopen($file_name, $mode); + if($file_handle == false) + exit("Error:failed to open file $file_name"); + + // writing data to the file + var_dump( fill_file($file_handle, $type, 50) ); + var_dump( fflush($file_handle) ); + fclose($file_handle); + + // reading the contents of the file after flushing + var_dump( readfile($file_name) ); + unlink($file_name); + } + $count++; +} + +echo "\n*** Done ***"; +?> +--EXPECTF-- +*** Testing fflush(): with various types of files *** +-- Iteration 1 with file containing empty Data-- +-- File opened in w mode -- +bool(true) +bool(true) +int(0) +-- File opened in wb mode -- +bool(true) +bool(true) +int(0) +-- File opened in wt mode -- +bool(true) +bool(true) +int(0) +-- File opened in w+ mode -- +bool(true) +bool(true) +int(0) +-- File opened in w+b mode -- +bool(true) +bool(true) +int(0) +-- File opened in w+t mode -- +bool(true) +bool(true) +int(0) +-- File opened in a mode -- +bool(true) +bool(true) +int(0) +-- File opened in ab mode -- +bool(true) +bool(true) +int(0) +-- File opened in at mode -- +bool(true) +bool(true) +int(0) +-- File opened in a+ mode -- +bool(true) +bool(true) +int(0) +-- File opened in a+b mode -- +bool(true) +bool(true) +int(0) +-- File opened in a+t mode -- +bool(true) +bool(true) +int(0) +-- File opened in x mode -- +bool(true) +bool(true) +int(0) +-- File opened in xb mode -- +bool(true) +bool(true) +int(0) +-- File opened in xt mode -- +bool(true) +bool(true) +int(0) +-- File opened in x+ mode -- +bool(true) +bool(true) +int(0) +-- File opened in x+b mode -- +bool(true) +bool(true) +int(0) +-- File opened in x+t mode -- +bool(true) +bool(true) +int(0) +-- Iteration 2 with file containing numeric Data-- +-- File opened in w mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in wb mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in wt mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in w+ mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in a mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in ab mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in at mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in a+ mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in x mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in xb mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in xt mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in x+ mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- Iteration 3 with file containing text Data-- +-- File opened in w mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in wb mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in wt mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in w+ mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in a mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in ab mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in at mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in a+ mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in x mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in xb mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in xt mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in x+ mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- Iteration 4 with file containing text_with_new_line Data-- +-- File opened in w mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in wb mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in wt mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(55) +-- File opened in w+ mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(55) +-- File opened in a mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in ab mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in at mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(65) +-- File opened in a+ mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(65) +-- File opened in x mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in xb mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in xt mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(55) +-- File opened in x+ mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(55) +-- Iteration 5 with file containing alphanumeric Data-- +-- File opened in w mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in wb mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in wt mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in w+ mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in a mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in ab mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in at mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in a+ mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in x mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in xb mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in xt mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in x+ mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) + +*** Done *** + +--UEXPECTF-- +*** Testing fflush(): with various types of files *** +-- Iteration 1 with file containing empty Data-- +-- File opened in w mode -- +bool(true) +bool(true) +int(0) +-- File opened in wb mode -- +bool(true) +bool(true) +int(0) +-- File opened in wt mode -- +bool(true) +bool(true) +int(0) +-- File opened in w+ mode -- +bool(true) +bool(true) +int(0) +-- File opened in w+b mode -- +bool(true) +bool(true) +int(0) +-- File opened in w+t mode -- +bool(true) +bool(true) +int(0) +-- File opened in a mode -- +bool(true) +bool(true) +int(0) +-- File opened in ab mode -- +bool(true) +bool(true) +int(0) +-- File opened in at mode -- +bool(true) +bool(true) +int(0) +-- File opened in a+ mode -- +bool(true) +bool(true) +int(0) +-- File opened in a+b mode -- +bool(true) +bool(true) +int(0) +-- File opened in a+t mode -- +bool(true) +bool(true) +int(0) +-- File opened in x mode -- +bool(true) +bool(true) +int(0) +-- File opened in xb mode -- +bool(true) +bool(true) +int(0) +-- File opened in xt mode -- +bool(true) +bool(true) +int(0) +-- File opened in x+ mode -- +bool(true) +bool(true) +int(0) +-- File opened in x+b mode -- +bool(true) +bool(true) +int(0) +-- File opened in x+t mode -- +bool(true) +bool(true) +int(0) +-- Iteration 2 with file containing numeric Data-- +-- File opened in w mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in wb mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in wt mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in w+ mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in a mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in ab mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in at mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in a+ mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in x mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in xb mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in xt mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in x+ mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- Iteration 3 with file containing text Data-- +-- File opened in w mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in wb mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in wt mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in w+ mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in a mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in ab mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in at mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in a+ mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in x mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in xb mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in xt mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in x+ mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- Iteration 4 with file containing text_with_new_line Data-- +-- File opened in w mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in wb mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in wt mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(55) +-- File opened in w+ mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(55) +-- File opened in a mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in ab mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in at mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(65) +-- File opened in a+ mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(65) +-- File opened in x mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in xb mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in xt mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(55) +-- File opened in x+ mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(55) +-- Iteration 5 with file containing alphanumeric Data-- +-- File opened in w mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in wb mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in wt mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in w+ mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in a mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in ab mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in at mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in a+ mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in x mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in xb mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in xt mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in x+ mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) + +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fflush_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fflush_basic.phpt diff -u /dev/null php-src/ext/standard/tests/file/fflush_basic.phpt:1.2 --- /dev/null Sat Jul 21 17:19:27 2007 +++ php-src/ext/standard/tests/file/fflush_basic.phpt Sat Jul 21 17:19:27 2007 @@ -0,0 +1,68 @@ +--TEST-- +Test fflush() function: basic functionality +--FILE-- +<?php +/* Prototype: bool fflush ( resource $handle ); + Description: Flushes the output to a file +*/ + +echo "*** Testing fflush(): writing to a file and reading the contents ***\n"; +$data = <<<EOD +first line of string +second line of string +third line of string +EOD; + +$file_path = dirname(__FILE__); +$filename = "$file_path/fflush_basic.tmp"; + +// opening a file +$file_handle = fopen($filename, "w"); +if($file_handle == false) + exit("Error:failed to open file $filename"); + +// writing data to the file +var_dump( fwrite($file_handle, $data) ); +var_dump( fflush($file_handle) ); +var_dump( readfile($filename) ); + +echo "\n*** Testing fflush(): for return type ***\n"; +$return_value = fflush($file_handle); +var_dump( is_bool($return_value) ); +fclose($file_handle); +echo "\n*** Done ***"; +?> + +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +$filename = "$file_path/fflush_basic.tmp"; +unlink($filename); +?> + +--EXPECTF-- +*** Testing fflush(): writing to a file and reading the contents *** +int(63) +bool(true) +first line of string +second line of string +third line of stringint(63) + +*** Testing fflush(): for return type *** +bool(true) + +*** Done *** +--UEXPECTF-- +*** Testing fflush(): writing to a file and reading the contents *** + +Notice: fwrite(): 63 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d +int(63) +bool(true) +first line of string +second line of string +third line of stringint(63) + +*** Testing fflush(): for return type *** +bool(true) + +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fflush_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fflush_error.phpt diff -u /dev/null php-src/ext/standard/tests/file/fflush_error.phpt:1.2 --- /dev/null Sat Jul 21 17:19:27 2007 +++ php-src/ext/standard/tests/file/fflush_error.phpt Sat Jul 21 17:19:27 2007 @@ -0,0 +1,127 @@ +--TEST-- +Test fflush() function: error conditions +--FILE-- +<?php +/* + Prototype: bool fflush ( resource $handle ); + Description: Flushes the output to a file +*/ + +echo "*** Testing error conditions ***\n"; +$file_path = dirname(__FILE__); + +// zero argument +echo "-- Testing fflush(): with zero argument --\n"; +var_dump( fflush() ); + +// more than expected no. of args +echo "-- Testing fflush(): with more than expected number of arguments --\n"; + +$filename = "$file_path/fflush_error.tmp"; +$file_handle = fopen($filename, "w"); +if($file_handle == false) + exit("Error:failed to open file $filename"); + +var_dump( fflush($file_handle, $file_handle) ); +fclose($file_handle); + +// test invalid arguments : non-resources +echo "-- Testing fflush(): with invalid arguments --\n"; +$invalid_args = array ( + "string", + 10, + 10.5, + true, + array(1,2,3), + new stdclass +); + +/* loop to test fflush() with different invalid type of args */ +for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) { + echo "-- Iteration $loop_counter --\n"; + var_dump( fflush($invalid_args[$loop_counter - 1]) ); +} +echo "\n*** Done ***"; +?> + +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +unlink("$file_path/fflush_error.tmp"); +?> + +--EXPECTF-- +*** Testing error conditions *** +-- Testing fflush(): with zero argument -- + +Warning: Wrong parameter count for fflush() in %s on line %d +NULL +-- Testing fflush(): with more than expected number of arguments -- + +Warning: Wrong parameter count for fflush() in %s on line %d +NULL +-- Testing fflush(): with invalid arguments -- +-- Iteration 1 -- + +Warning: fflush(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: fflush(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: fflush(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: fflush(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: fflush(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: fflush(): supplied argument is not a valid stream resource in %s on line %d +bool(false) + +*** Done *** + +--UEXPECTF-- +*** Testing error conditions *** +-- Testing fflush(): with zero argument -- + +Warning: Wrong parameter count for fflush() in %s on line %d +NULL +-- Testing fflush(): with more than expected number of arguments -- + +Warning: Wrong parameter count for fflush() in %s on line %d +NULL +-- Testing fflush(): with invalid arguments -- +-- Iteration 1 -- + +Warning: fflush(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: fflush(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: fflush(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: fflush(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: fflush(): supplied argument is not a valid stream resource in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: fflush(): supplied argument is not a valid stream resource in %s on line %d +bool(false) + +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fflush_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fflush_variation1.phpt diff -u /dev/null php-src/ext/standard/tests/file/fflush_variation1.phpt:1.2 --- /dev/null Sat Jul 21 17:19:27 2007 +++ php-src/ext/standard/tests/file/fflush_variation1.phpt Sat Jul 21 17:19:27 2007 @@ -0,0 +1,997 @@ +--TEST-- +Test fflush() function: usage variations - files in different modes +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) == "WIN" ) + die("skip.. only for linux"); +?> + +--FILE-- +<?php +/* Prototype: bool fflush ( resource $handle ); + Description: Flushes the output to a file +*/ + +/* test fflush() with handle of files opened in different modes */ + +$file_path = dirname(__FILE__); +require $file_path.'/file.inc'; + +echo "*** Testing fflush(): with various types of files ***\n"; +$file_types = array("empty", "numeric", "text", "text_with_new_line", "alphanumeric"); +$file_modes = array("w", "wb", "wt", "w+", "w+b", "w+t", + "a", "ab", "at", "a+","a+b", "a+t", + "x", "xb", "xt", "x+", "x+b", "x+t"); + +$file_name = "$file_path/fflush_variation1.tmp"; + +$count = 1; + +foreach( $file_types as $type ) { + echo "-- Iteration $count with file containing $type Data--\n"; + foreach( $file_modes as $mode ) { + echo "-- File opened in $mode mode --\n"; + + // creating the file except for x mode + if( substr($mode, 0, 1) != "x" ) { + $file_handle = fopen($file_name, "w"); + if($file_handle == false) + exit("Error:failed to open file $file_name"); + + // filling the file with some data if mode is append mode + if( substr($mode, 0, 1) == "a") + fill_file($file_handle, $type, 10); + fclose($file_handle); + + } + + // opening the file in different modes + $file_handle = fopen($file_name, $mode); + if($file_handle == false) + exit("Error:failed to open file $file_name"); + + // writing data to the file + var_dump( fill_file($file_handle, $type, 50) ); + var_dump( fflush($file_handle) ); + fclose($file_handle); + + // reading the contents of the file after flushing + var_dump( readfile($file_name) ); + unlink($file_name); + } + $count++; +} + +echo "\n*** Done ***"; +?> +--EXPECTF-- +*** Testing fflush(): with various types of files *** +-- Iteration 1 with file containing empty Data-- +-- File opened in w mode -- +bool(true) +bool(true) +int(0) +-- File opened in wb mode -- +bool(true) +bool(true) +int(0) +-- File opened in wt mode -- +bool(true) +bool(true) +int(0) +-- File opened in w+ mode -- +bool(true) +bool(true) +int(0) +-- File opened in w+b mode -- +bool(true) +bool(true) +int(0) +-- File opened in w+t mode -- +bool(true) +bool(true) +int(0) +-- File opened in a mode -- +bool(true) +bool(true) +int(0) +-- File opened in ab mode -- +bool(true) +bool(true) +int(0) +-- File opened in at mode -- +bool(true) +bool(true) +int(0) +-- File opened in a+ mode -- +bool(true) +bool(true) +int(0) +-- File opened in a+b mode -- +bool(true) +bool(true) +int(0) +-- File opened in a+t mode -- +bool(true) +bool(true) +int(0) +-- File opened in x mode -- +bool(true) +bool(true) +int(0) +-- File opened in xb mode -- +bool(true) +bool(true) +int(0) +-- File opened in xt mode -- +bool(true) +bool(true) +int(0) +-- File opened in x+ mode -- +bool(true) +bool(true) +int(0) +-- File opened in x+b mode -- +bool(true) +bool(true) +int(0) +-- File opened in x+t mode -- +bool(true) +bool(true) +int(0) +-- Iteration 2 with file containing numeric Data-- +-- File opened in w mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in wb mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in wt mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in w+ mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in a mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in ab mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in at mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in a+ mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in x mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in xb mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in xt mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in x+ mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- Iteration 3 with file containing text Data-- +-- File opened in w mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in wb mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in wt mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in w+ mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in a mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in ab mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in at mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in a+ mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in x mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in xb mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in xt mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in x+ mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- Iteration 4 with file containing text_with_new_line Data-- +-- File opened in w mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in wb mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in wt mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in w+ mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in a mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in ab mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in at mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in a+ mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in x mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in xb mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in xt mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in x+ mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- Iteration 5 with file containing alphanumeric Data-- +-- File opened in w mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in wb mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in wt mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in w+ mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in a mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in ab mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in at mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in a+ mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in x mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in xb mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in xt mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in x+ mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) + +*** Done *** + +--UEXPECTF-- +*** Testing fflush(): with various types of files *** +-- Iteration 1 with file containing empty Data-- +-- File opened in w mode -- +bool(true) +bool(true) +int(0) +-- File opened in wb mode -- +bool(true) +bool(true) +int(0) +-- File opened in wt mode -- +bool(true) +bool(true) +int(0) +-- File opened in w+ mode -- +bool(true) +bool(true) +int(0) +-- File opened in w+b mode -- +bool(true) +bool(true) +int(0) +-- File opened in w+t mode -- +bool(true) +bool(true) +int(0) +-- File opened in a mode -- +bool(true) +bool(true) +int(0) +-- File opened in ab mode -- +bool(true) +bool(true) +int(0) +-- File opened in at mode -- +bool(true) +bool(true) +int(0) +-- File opened in a+ mode -- +bool(true) +bool(true) +int(0) +-- File opened in a+b mode -- +bool(true) +bool(true) +int(0) +-- File opened in a+t mode -- +bool(true) +bool(true) +int(0) +-- File opened in x mode -- +bool(true) +bool(true) +int(0) +-- File opened in xb mode -- +bool(true) +bool(true) +int(0) +-- File opened in xt mode -- +bool(true) +bool(true) +int(0) +-- File opened in x+ mode -- +bool(true) +bool(true) +int(0) +-- File opened in x+b mode -- +bool(true) +bool(true) +int(0) +-- File opened in x+t mode -- +bool(true) +bool(true) +int(0) +-- Iteration 2 with file containing numeric Data-- +-- File opened in w mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in wb mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in wt mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in w+ mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in a mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in ab mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in at mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in a+ mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- File opened in x mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in xb mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in xt mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in x+ mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- Iteration 3 with file containing text Data-- +-- File opened in w mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in wb mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in wt mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in w+ mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in a mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in ab mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in at mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in a+ mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- File opened in x mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in xb mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in xt mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in x+ mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- Iteration 4 with file containing text_with_new_line Data-- +-- File opened in w mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in wb mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in wt mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in w+ mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in a mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in ab mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in at mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in a+ mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- File opened in x mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in xb mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in xt mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in x+ mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- Iteration 5 with file containing alphanumeric Data-- +-- File opened in w mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in wb mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in wt mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in w+ mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in w+b mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in w+t mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in a mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in ab mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in at mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in a+ mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in a+b mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in a+t mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- File opened in x mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in xb mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in xt mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in x+ mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in x+b mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- File opened in x+t mode -- +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) + +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/fflush_variation2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/fflush_variation2.phpt diff -u /dev/null php-src/ext/standard/tests/file/fflush_variation2.phpt:1.2 --- /dev/null Sat Jul 21 17:19:27 2007 +++ php-src/ext/standard/tests/file/fflush_variation2.phpt Sat Jul 21 17:19:27 2007 @@ -0,0 +1,818 @@ +--TEST-- +Test fflush() function: usage variations - links as resource +--SKIPIF-- +<?php +if( substr(PHP_OS, 0, 3) == 'WIN') + die("skip Links not valid on Windows"); +?> +--FILE-- +<?php +/* Prototype: bool fflush ( resource $handle ); + Description: Flushes the output to a file +*/ + +/* test fflush() with handle to symbollic link */ + +$file_path = dirname(__FILE__); +require $file_path.'/file.inc'; + +echo "*** Testing fflush(): with soft links to files opened in diff modes ***\n"; +$file_types = array("empty", "numeric", "text", "text_with_new_line", "alphanumeric"); +$file_modes = array("w", "wb", "wt", "w+", "w+b", "w+t", + "a", "ab", "at", "a+","a+b", "a+t"); + +$file_name = "$file_path/fflush_variation2.tmp"; +$symlink_name = "$file_path/symlnk_fflush_variation2.tmp"; + +$count = 1; + +foreach( $file_types as $type ) { + echo "-- Iteration $count with file containing $type data --\n"; + foreach( $file_modes as $mode ) { + echo "-- link opened in $mode mode --\n"; + + //creating the file + $file_handle = fopen($file_name, "w"); + if($file_handle == false) + exit("Error:failed to open file $file_name"); + + //fill the file with some data if mode is append mode + if( substr($mode, 0, 1) == "a" ) + fill_file($file_handle, $type, 10); + + //close the file + fclose($file_handle); + + // creating the sym link + var_dump( symlink($file_name, $symlink_name) ); + $file_handle = fopen($symlink_name, $mode); + if($file_handle == false) + exit("Error:failed to open link $symlink_name"); + + // filling data into the file + var_dump( fill_file($file_handle, $type, 50) ); + var_dump( fflush($file_handle) ); + fclose($file_handle); + + // reading the data from the file + var_dump( readfile($symlink_name) ); + + unlink($symlink_name); + unlink($file_name); + } + $count++; +} + +echo "\n*** Done ***"; +?> +--EXPECTF-- +*** Testing fflush(): with soft links to files opened in diff modes *** +-- Iteration 1 with file containing empty data -- +-- link opened in w mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in wb mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in wt mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in w+ mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in w+b mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in w+t mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in a mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in ab mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in at mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in a+ mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in a+b mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in a+t mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- Iteration 2 with file containing numeric data -- +-- link opened in w mode -- +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- link opened in wb mode -- +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- link opened in wt mode -- +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- link opened in w+ mode -- +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- link opened in w+b mode -- +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- link opened in w+t mode -- +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- link opened in a mode -- +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- link opened in ab mode -- +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- link opened in at mode -- +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- link opened in a+ mode -- +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- link opened in a+b mode -- +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- link opened in a+t mode -- +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- Iteration 3 with file containing text data -- +-- link opened in w mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- link opened in wb mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- link opened in wt mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- link opened in w+ mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- link opened in w+b mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- link opened in w+t mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- link opened in a mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- link opened in ab mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- link opened in at mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- link opened in a+ mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- link opened in a+b mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- link opened in a+t mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- Iteration 4 with file containing text_with_new_line data -- +-- link opened in w mode -- +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- link opened in wb mode -- +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- link opened in wt mode -- +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- link opened in w+ mode -- +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- link opened in w+b mode -- +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- link opened in w+t mode -- +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- link opened in a mode -- +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- link opened in ab mode -- +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- link opened in at mode -- +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- link opened in a+ mode -- +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- link opened in a+b mode -- +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- link opened in a+t mode -- +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- Iteration 5 with file containing alphanumeric data -- +-- link opened in w mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- link opened in wb mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- link opened in wt mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- link opened in w+ mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- link opened in w+b mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- link opened in w+t mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- link opened in a mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- link opened in ab mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- link opened in at mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- link opened in a+ mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- link opened in a+b mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- link opened in a+t mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) + +*** Done *** + +--UEXPECTF-- +*** Testing fflush(): with soft links to files opened in diff modes *** +-- Iteration 1 with file containing empty data -- +-- link opened in w mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in wb mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in wt mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in w+ mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in w+b mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in w+t mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in a mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in ab mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in at mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in a+ mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in a+b mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- link opened in a+t mode -- +bool(true) +bool(true) +bool(true) +int(0) +-- Iteration 2 with file containing numeric data -- +-- link opened in w mode -- +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- link opened in wb mode -- +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- link opened in wt mode -- +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- link opened in w+ mode -- +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- link opened in w+b mode -- +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- link opened in w+t mode -- +bool(true) +bool(true) +bool(true) +22222222222222222222222222222222222222222222222222int(50) +-- link opened in a mode -- +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- link opened in ab mode -- +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- link opened in at mode -- +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- link opened in a+ mode -- +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- link opened in a+b mode -- +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- link opened in a+t mode -- +bool(true) +bool(true) +bool(true) +222222222222222222222222222222222222222222222222222222222222int(60) +-- Iteration 3 with file containing text data -- +-- link opened in w mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- link opened in wb mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- link opened in wt mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- link opened in w+ mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- link opened in w+b mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- link opened in w+t mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text int(50) +-- link opened in a mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- link opened in ab mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- link opened in at mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- link opened in a+ mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- link opened in a+b mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- link opened in a+t mode -- +bool(true) +bool(true) +bool(true) +text text text text text text text text text text text text int(60) +-- Iteration 4 with file containing text_with_new_line data -- +-- link opened in w mode -- +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- link opened in wb mode -- +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- link opened in wt mode -- +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- link opened in w+ mode -- +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- link opened in w+b mode -- +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- link opened in w+t mode -- +bool(true) +bool(true) +bool(true) +line +line of text +line +line of text +line +line of tint(50) +-- link opened in a mode -- +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- link opened in ab mode -- +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- link opened in at mode -- +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- link opened in a+ mode -- +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- link opened in a+b mode -- +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- link opened in a+t mode -- +bool(true) +bool(true) +bool(true) +line +line line +line of text +line +line of text +line +line of tint(60) +-- Iteration 5 with file containing alphanumeric data -- +-- link opened in w mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- link opened in wb mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- link opened in wt mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- link opened in w+ mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- link opened in w+b mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- link opened in w+t mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50) +-- link opened in a mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- link opened in ab mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- link opened in at mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- link opened in a+ mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- link opened in a+b mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) +-- link opened in a+t mode -- +bool(true) +bool(true) +bool(true) +ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60) + +*** Done ***
« previous php.cvs (#45488) next »