cvs: php-src(PHP_5_2) /ext/standard/tests/file 007_variation1.phpt 007_variation10.phpt 007_variation11-win32.phpt 007_variation11.phpt
007_variation12-win32.phpt 007_variation12.phpt 007_variation13-win32.phpt 007_variation13.phpt 007_variation14.phpt 007_variation15.phpt
007_variation16.phpt 007_variation17.phpt 007_variation18.phpt 007_variation19.phpt 007_variation2.phpt 007_variation20.phpt 007_variation21.phpt
007_variation22.phpt 007_variation23.phpt 007_variation24.phpt 007_variation3.phpt 007_variation4.phpt 007_variation5.phpt 007_variation6.phpt
007_variation7.phpt 007_variation8.phpt 007_variation9.phpt

From: Date: Sun, 12 Aug 2007 05:16:20 +0000
Subject: cvs: php-src(PHP_5_2) /ext/standard/tests/file 007_variation1.phpt 007_variation10.phpt 007_variation11-win32.phpt 007_variation11.phpt
007_variation12-win32.phpt 007_variation12.phpt 007_variation13-win32.phpt 007_variation13.phpt 007_variation14.phpt 007_variation15.phpt
007_variation16.phpt 007_variation17.phpt 007_variation18.phpt 007_variation19.phpt 007_variation2.phpt 007_variation20.phpt 007_variation21.phpt
007_variation22.phpt 007_variation23.phpt 007_variation24.phpt 007_variation3.phpt 007_variation4.phpt 007_variation5.phpt 007_variation6.phpt
007_variation7.phpt 007_variation8.phpt 007_variation9.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-45870@lists.php.net to get a copy of this message
kraghuba Sun Aug 12 05:16:20 2007 UTC Added files: (Branch: PHP_5_2) /php-src/ext/standard/tests/file 007_variation15.phpt 007_variation3.phpt 007_variation17.phpt 007_variation5.phpt 007_variation19.phpt 007_variation7.phpt 007_variation9.phpt 007_variation12-win32.phpt 007_variation20.phpt 007_variation10.phpt 007_variation22.phpt 007_variation12.phpt 007_variation24.phpt 007_variation14.phpt 007_variation2.phpt 007_variation16.phpt 007_variation4.phpt 007_variation18.phpt 007_variation6.phpt 007_variation8.phpt 007_variation11-win32.phpt 007_variation13-win32.phpt 007_variation21.phpt 007_variation11.phpt 007_variation23.phpt 007_variation13.phpt 007_variation1.phpt Log: More new testcases for fopen() & fclose() functions

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation15.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation15.phpt +++ php-src/ext/standard/tests/file/007_variation15.phpt --TEST-- Test fopen and fclose() functions - usage variations - "xt" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "xt" mode, checking for the file creation, write & read operations, checking for the file pointer position, checking for the warning msg when trying to open an existing file in "xt" mode, and fclose function */ $file_path = dirname(__FILE__); $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; $file = $file_path."/007_variation15.tmp"; echo "*** Test fopen() & fclose() functions: with 'xt' mode ***\n"; $file_handle = fopen($file, "xt"); //opening the non-existing file in "xt" mode, file will be created var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the begining of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation $file_handle = fopen($file, "xt"); //Opening the existing data file in 'xt' mode to check for the warning message echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation15.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'xt' mode *** resource(5) of type (stream) string(6) "stream" int(0) int(37) int(37) bool(false) int(0) bool(true) string(7) "Unknown" Warning: fopen(%s): failed to open stream: File exists in %s on line %d *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'xt' mode *** resource(5) of type (stream) unicode(6) "stream" int(0) Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(37) int(37) bool(false) int(0) bool(true) unicode(7) "Unknown" Warning: fopen(%s): failed to open stream: File exists in %s on line %d *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation3.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation3.phpt +++ php-src/ext/standard/tests/file/007_variation3.phpt --TEST-- Test fopen and fclose() functions - usage variations - "w" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "w" mode, checking for the file creation, write & read operations, checking for the file pointer position, checking for the file truncation when trying to open an existing file in "w" mode, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 3, "bytes"); $file = $file_path."/007_variation3.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'w' mode ***\n"; $file_handle = fopen($file, "w"); //opening the file "w" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: bool(false) var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the begining of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "w" mode again, expected: size of content clearstatcache(); fclose( fopen($file, "w") ); //Opening the existing data file again in "w" mode var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "w" mode again, expected: 0 bytes clearstatcache(); unlink($file); //Deleting the file fclose( fopen($file, "w") ); //Opening the non-existing file in "w" mode, which will be created var_dump( file_exists($file) ); //Check for the existance of file echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation3.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'w' mode *** resource(8) of type (stream) string(6) "stream" int(0) int(37) int(37) bool(false) int(0) bool(true) string(7) "Unknown" int(37) int(0) bool(true) *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'w' mode *** resource(8) of type (stream) unicode(6) "stream" int(0) Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(37) int(37) bool(false) int(0) bool(true) unicode(7) "Unknown" int(37) int(0) bool(true) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation17.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation17.phpt +++ php-src/ext/standard/tests/file/007_variation17.phpt --TEST-- Test fopen and fclose() functions - usage variations - "rb" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "rb" mode, checking for the file creation, write & read operations, checking for the file pointer position, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 17, "bytes"); $file = $file_path."/007_variation17.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'rb' mode ***\n"; $file_handle = fopen($file, "rb"); //opening the file in "rb" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial position of file pointer var_dump( fread($file_handle, 100) ); //Check for read operation var_dump( fwrite($file_handle, $string) ); //Check for write operation; fails; expected: 0 bytes var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation17.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'rb' mode *** resource(8) of type (stream) string(6) "stream" int(0) string(20) "line line of text li" int(0) bool(true) string(7) "Unknown" *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'rb' mode *** resource(8) of type (stream) unicode(6) "stream" int(0) string(20) "line line of text li" Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(0) bool(true) unicode(7) "Unknown" *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation5.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation5.phpt +++ php-src/ext/standard/tests/file/007_variation5.phpt --TEST-- Test fopen and fclose() functions - usage variations - "a" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "a" mode, checking for the file creation, write & read operations, checking for the file pointer position, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 5, "bytes"); $file = $file_path."/007_variation5.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'a' mode ***\n"; $file_handle = fopen($file, "a"); //opening the file "a" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation var_dump( filesize($file) ); //Check that data hasn't over written; Expected: Size of (initial data + newly added data) unlink($file); //Deleting the file fclose( fopen($file, "a") ); //Opening the non-existing file in "a" mode, which will be created var_dump( file_exists($file) ); //Check for the existance of file echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation5.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'a' mode *** resource(8) of type (stream) string(6) "stream" int(37) bool(false) int(0) bool(true) string(7) "Unknown" int(57) bool(true) *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'a' mode *** resource(8) of type (stream) unicode(6) "stream" Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(37) bool(false) int(0) bool(true) unicode(7) "Unknown" int(57) bool(true) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation19.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation19.phpt +++ php-src/ext/standard/tests/file/007_variation19.phpt --TEST-- Test fopen and fclose() functions - usage variations - "wb" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "wb" mode, checking for the file creation, write & read operations, checking for the file pointer position, checking for the file truncation when trying to open an existing file in "wb" mode, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "wb", "007_variation", 19, "bytes"); $file = $file_path."/007_variation19.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'wb' mode ***\n"; $file_handle = fopen($file, "wb"); //opening the file "wb" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the begining of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "wb" mode again, expected: size of content clearstatcache(); fclose( fopen($file, "wb") ); //Opening the existing data file again in "wb" mode var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "wb" mode again, expected: 0 bytes clearstatcache(); unlink($file); //Deleting the file fclose( fopen($file, "wb") ); //Opening the non-existing file in "wb" mode, which will be created var_dump( file_exists($file) ); //Check for the existance of file echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation19.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'wb' mode *** resource(8) of type (stream) string(6) "stream" int(0) int(37) int(37) bool(false) int(0) bool(true) string(7) "Unknown" int(37) int(0) bool(true) *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'wb' mode *** resource(8) of type (stream) unicode(6) "stream" int(0) Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(37) int(37) bool(false) int(0) bool(true) unicode(7) "Unknown" int(37) int(0) bool(true) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation7.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation7.phpt +++ php-src/ext/standard/tests/file/007_variation7.phpt --TEST-- Test fopen and fclose() functions - usage variations - "x" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "x" mode, checking for the file creation, write & read operations, checking for the file pointer position, checking for the warning msg when trying to open an existing file in "x" mode, and fclose function */ $file_path = dirname(__FILE__); $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; $file = $file_path."/007_variation7.tmp"; echo "*** Test fopen() & fclose() functions: with 'x' mode ***\n"; $file_handle = fopen($file, "x"); //opening the non-existing file in "x" mode, file will be created var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the begining of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation $file_handle = fopen($file, "x"); //Opening the existing data file in 'x' mode to check for the warning message echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation7.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'x' mode *** resource(5) of type (stream) string(6) "stream" int(0) int(37) int(37) bool(false) int(0) bool(true) string(7) "Unknown" Warning: fopen(%s): failed to open stream: File exists in %s on line %s *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'x' mode *** resource(5) of type (stream) unicode(6) "stream" int(0) Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(37) int(37) bool(false) int(0) bool(true) unicode(7) "Unknown" Warning: fopen(%s): failed to open stream: File exists in %s on line %d *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation9.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation9.phpt +++ php-src/ext/standard/tests/file/007_variation9.phpt --TEST-- Test fopen and fclose() functions - usage variations - "rt" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "rt" mode, checking for the file creation, write & read operations, checking for the file pointer position, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 9, "bytes"); $file = $file_path."/007_variation9.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'rt' mode ***\n"; $file_handle = fopen($file, "rt"); //opening the file in "rt" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial position of file pointer var_dump( fread($file_handle, 100) ); //Check for read operation var_dump( fwrite($file_handle, $string) ); //Check for write operation; fails; expected: 0 bytes var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation9.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'rt' mode *** resource(8) of type (stream) string(6) "stream" int(0) string(20) "line line of text li" int(0) bool(true) string(7) "Unknown" *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'rt' mode *** resource(8) of type (stream) unicode(6) "stream" int(0) unicode(20) "line line of text li" Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(0) bool(true) unicode(7) "Unknown" *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation12-win32.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation12-win32.phpt +++ php-src/ext/standard/tests/file/007_variation12-win32.phpt --TEST-- Test fopen and fclose() functions - usage variations - "w+t" mode --SKIPIF-- <?php if( substr(PHP_OS, 0, 3) != "WIN" ) die('skip Run only on Windows'); ?> --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "w+t" mode, checking for the file creation, write & read operations, checking for the file pointer position, checking for the file truncation when trying to open an existing file in "w+t" mode, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 12, "bytes"); $file = $file_path."/007_variation12.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'w+t' mode ***\n"; $file_handle = fopen($file, "w+t"); //opening the file "w+t" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of file var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "w+t" mode again, expected: size of content clearstatcache(); fclose( fopen($file, "w+t") ); //Opening the existing data file again in "w+t" mode var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "w+t" mode again, expected: 0 bytes clearstatcache(); unlink($file); //Deleting the file fclose( fopen($file, "w+t") ); //Opening the non-existing file in "w+t" mode, which will be created var_dump( file_exists($file) ); //Check for the existance of file echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation12.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'w+t' mode *** resource(8) of type (stream) string(6) "stream" int(0) int(37) int(37) string(37) "abcdefghij mnopqrst uvwxyz 0123456789" int(37) bool(true) string(7) "Unknown" int(39) int(0) bool(true) *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'w+t' mode *** resource(8) of type (stream) unicode(6) "stream" int(0) int(37) int(37) unicode(37) "abcdefghij mnopqrst uvwxyz 0123456789" int(37) bool(true) unicode(7) "Unknown" int(39) int(0) bool(true) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation20.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation20.phpt +++ php-src/ext/standard/tests/file/007_variation20.phpt --TEST-- Test fopen and fclose() functions - usage variations - "w+b" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "w+b" mode, checking for the file creation, write & read operations, checking for the file pointer position, checking for the file truncation when trying to open an existing file in "w+b" mode, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 20, "bytes"); $file = $file_path."/007_variation20.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'w+b' mode ***\n"; $file_handle = fopen($file, "w+b"); //opening the file "w+b" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of file var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "w+b" mode again, expected: size of content clearstatcache(); fclose( fopen($file, "w+b") ); //Opening the existing data file again in "w+b" mode var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "w+b" mode again, expected: 0 bytes clearstatcache(); unlink($file); //Deleting the file fclose( fopen($file, "w+b") ); //Opening the non-existing file in "w+b" mode, which will be created var_dump( file_exists($file) ); //Check for the existance of file echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation20.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'w+b' mode *** resource(8) of type (stream) string(6) "stream" int(0) int(37) int(37) string(37) "abcdefghij mnopqrst uvwxyz 0123456789" int(37) bool(true) string(7) "Unknown" int(37) int(0) bool(true) *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'w+b' mode *** resource(8) of type (stream) unicode(6) "stream" int(0) Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(37) int(37) string(37) "abcdefghij mnopqrst uvwxyz 0123456789" int(37) bool(true) unicode(7) "Unknown" int(37) int(0) bool(true) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation10.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation10.phpt +++ php-src/ext/standard/tests/file/007_variation10.phpt --TEST-- Test fopen and fclose() functions - usage variations - "r+t" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "r+t" mode, checking for the file creation, write & read operations, checking for the file pointer position, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 10, "bytes"); $file = $file_path."/007_variation10.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'r+t' mode ***\n"; $file_handle = fopen($file, "r+t"); //opening the file in "r+t" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fread($file_handle, 100) ); //Check for read operation var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation10.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'r+t' mode *** resource(8) of type (stream) string(6) "stream" int(0) string(20) "line line of text li" int(20) int(37) int(57) bool(true) string(7) "Unknown" *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'r+t' mode *** resource(8) of type (stream) unicode(6) "stream" int(0) unicode(20) "line line of text li" int(20) int(37) int(57) bool(true) unicode(7) "Unknown" *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation22.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation22.phpt +++ php-src/ext/standard/tests/file/007_variation22.phpt --TEST-- Test fopen and fclose() functions - usage variations - "a+b" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "a+b" mode, checking for the file creation, write & read operations, checking for the file pointer position, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 22, "bytes"); $file = $file_path."/007_variation22.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'a+b' mode ***\n"; $file_handle = fopen($file, "a+b"); //opening the file "a+b" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of file var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation unlink($file); //Deleting the file fclose( fopen($file, "a+b") ); //Opening the non-existing file in "a+b" mode, which will be created var_dump( file_exists($file) ); //Check for the existance of file echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation22.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'a+b' mode *** resource(8) of type (stream) string(6) "stream" int(37) string(57) "line line of text liabcdefghij mnopqrst uvwxyz 0123456789" int(57) bool(true) string(7) "Unknown" bool(true) *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'a+b' mode *** resource(8) of type (stream) unicode(6) "stream" Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(37) string(57) "line line of text liabcdefghij mnopqrst uvwxyz 0123456789" int(57) bool(true) unicode(7) "Unknown" bool(true) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation12.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation12.phpt +++ php-src/ext/standard/tests/file/007_variation12.phpt --TEST-- Test fopen and fclose() functions - usage variations - "w+t" mode --SKIPIF-- <?php if( substr(PHP_OS, 0, 3) == "WIN" ) die('skip Do not run on Windows'); ?> --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "w+t" mode, checking for the file creation, write & read operations, checking for the file pointer position, checking for the file truncation when trying to open an existing file in "w+t" mode, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 12, "bytes"); $file = $file_path."/007_variation12.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'w+t' mode ***\n"; $file_handle = fopen($file, "w+t"); //opening the file "w+t" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of file var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "w+t" mode again, expected: size of content clearstatcache(); fclose( fopen($file, "w+t") ); //Opening the existing data file again in "w+t" mode var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "w+t" mode again, expected: 0 bytes clearstatcache(); unlink($file); //Deleting the file fclose( fopen($file, "w+t") ); //Opening the non-existing file in "w+t" mode, which will be created var_dump( file_exists($file) ); //Check for the existance of file echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation12.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'w+t' mode *** resource(8) of type (stream) string(6) "stream" int(0) int(37) int(37) string(37) "abcdefghij mnopqrst uvwxyz 0123456789" int(37) bool(true) string(7) "Unknown" int(37) int(0) bool(true) *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'w+t' mode *** resource(8) of type (stream) unicode(6) "stream" int(0) int(37) int(37) unicode(37) "abcdefghij mnopqrst uvwxyz 0123456789" int(37) bool(true) unicode(7) "Unknown" int(37) int(0) bool(true) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation24.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation24.phpt +++ php-src/ext/standard/tests/file/007_variation24.phpt --TEST-- Test fopen and fclose() functions - usage variations - "x+b" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "x+b" mode, checking for the file creation, write & read operations, checking for the file pointer position, checking for the warning msg when trying to open an existing file in "x+b" mode, and fclose function */ $file_path = dirname(__FILE__); $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; $file = $file_path."/007_variation24.tmp"; echo "*** Test fopen() & fclose() functions: with 'x+b' mode ***\n"; $file_handle = fopen($file, "x+b"); //opening the non-existing file in "x+b" mode, file will be created var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of the file var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation $file_handle = fopen($file, "x+b"); //Opening the existing data file in "x+b" mode to check for the warning message echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation24.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'x+b' mode *** resource(5) of type (stream) string(6) "stream" int(0) int(37) int(37) string(37) "abcdefghij mnopqrst uvwxyz 0123456789" int(37) bool(true) string(7) "Unknown" Warning: fopen(%s): failed to open stream: File exists in %s on line %d *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'x+b' mode *** resource(5) of type (stream) unicode(6) "stream" int(0) Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(37) int(37) string(37) "abcdefghij mnopqrst uvwxyz 0123456789" int(37) bool(true) unicode(7) "Unknown" Warning: fopen(%s): failed to open stream: File exists in %s on line %d *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation14.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation14.phpt +++ php-src/ext/standard/tests/file/007_variation14.phpt --TEST-- Test fopen and fclose() functions - usage variations - "a+t" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "a+t" mode, checking for the file creation, write & read operations, checking for the file pointer position, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 14, "bytes"); $file = $file_path."/007_variation14.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'a+t' mode ***\n"; $file_handle = fopen($file, "a+t"); //opening the file "a+t" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of file var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation unlink($file); //Deleting the file fclose( fopen($file, "a+t") ); //Opening the non-existing file in "a+t" mode, which will be created var_dump( file_exists($file) ); //Check for the existance of file echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation14.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'a+t' mode *** resource(8) of type (stream) string(6) "stream" int(37) string(57) "line line of text liabcdefghij mnopqrst uvwxyz 0123456789" int(57) bool(true) string(7) "Unknown" bool(true) *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'a+t' mode *** resource(8) of type (stream) unicode(6) "stream" int(37) unicode(57) "line line of text liabcdefghij mnopqrst uvwxyz 0123456789" int(57) bool(true) unicode(7) "Unknown" bool(true) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation2.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation2.phpt +++ php-src/ext/standard/tests/file/007_variation2.phpt --TEST-- Test fopen and fclose() functions - usage variations - "r+" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "r+" mode, checking for the file creation, write & read operations, checking for the file pointer position, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 2, "bytes"); $file = $file_path."/007_variation2.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'r+' mode ***\n"; $file_handle = fopen($file, "r+"); //opening the file in "r+" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fread($file_handle, 100) ); //Check for read operation var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation2.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'r+' mode *** resource(8) of type (stream) string(6) "stream" int(0) string(20) "line line of text li" int(20) int(37) int(57) bool(true) string(7) "Unknown" *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'r+' mode *** resource(8) of type (stream) unicode(6) "stream" int(0) string(20) "line line of text li" int(20) Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(37) int(57) bool(true) unicode(7) "Unknown" *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation16.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation16.phpt +++ php-src/ext/standard/tests/file/007_variation16.phpt --TEST-- Test fopen and fclose() functions - usage variations - "x+t" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "x+t" mode, checking for the file creation, write & read operations, checking for the file pointer position, checking for the warning msg when trying to open an existing file in "x+t" mode, and fclose function */ $file_path = dirname(__FILE__); $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; $file = $file_path."/007_variation16.tmp"; echo "*** Test fopen() & fclose() functions: with 'x+t' mode ***\n"; $file_handle = fopen($file, "x+t"); //opening the non-existing file in "x+t" mode, file will be created var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of the file var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation $file_handle = fopen($file, "x+t"); //Opening the existing data file in "x+t" mode to check for the warning message echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation16.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'x+t' mode *** resource(5) of type (stream) string(6) "stream" int(0) int(37) int(37) string(37) "abcdefghij mnopqrst uvwxyz 0123456789" int(37) bool(true) string(7) "Unknown" Warning: fopen(%s): failed to open stream: File exists in %s on line %d *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'x+t' mode *** resource(5) of type (stream) unicode(6) "stream" int(0) int(37) int(37) unicode(37) "abcdefghij mnopqrst uvwxyz 0123456789" int(37) bool(true) unicode(7) "Unknown" Warning: fopen(%s): failed to open stream: File exists in %s on line %d *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation4.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation4.phpt +++ php-src/ext/standard/tests/file/007_variation4.phpt --TEST-- Test fopen and fclose() functions - usage variations - "w+" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "w+" mode, checking for the file creation, write & read operations, checking for the file pointer position, checking for the file truncation when trying to open an existing file in "w+" mode, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 4, "bytes"); $file = $file_path."/007_variation4.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'w+' mode ***\n"; $file_handle = fopen($file, "w+"); //opening the file "w+" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of file var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "w+" mode again, expected: size of content clearstatcache(); fclose( fopen($file, "w+") ); //Opening the existing data file again in "w+" mode var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "w+" mode again, expected: 0 bytes clearstatcache(); unlink($file); //Deleting the file fclose( fopen($file, "w+") ); //Opening the non-existing file in "w+" mode, which will be created var_dump( file_exists($file) ); //Check for the existance of file echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation4.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'w+' mode *** resource(8) of type (stream) string(6) "stream" int(0) int(37) int(37) string(37) "abcdefghij mnopqrst uvwxyz 0123456789" int(37) bool(true) string(7) "Unknown" int(37) int(0) bool(true) *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'w+' mode *** resource(8) of type (stream) unicode(6) "stream" int(0) Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(37) int(37) string(37) "abcdefghij mnopqrst uvwxyz 0123456789" int(37) bool(true) unicode(7) "Unknown" int(37) int(0) bool(true) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation18.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation18.phpt +++ php-src/ext/standard/tests/file/007_variation18.phpt --TEST-- Test fopen and fclose() functions - usage variations - "r+b" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "r+b" mode, checking for the file creation, write & read operations, checking for the file pointer position, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 18, "bytes"); $file = $file_path."/007_variation18.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'r+b' mode ***\n"; $file_handle = fopen($file, "r+b"); //opening the file in "r+b" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fread($file_handle, 100) ); //Check for read operation var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation18.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'r+b' mode *** resource(8) of type (stream) string(6) "stream" int(0) string(20) "line line of text li" int(20) int(37) int(57) bool(true) string(7) "Unknown" *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'r+b' mode *** resource(8) of type (stream) unicode(6) "stream" int(0) string(20) "line line of text li" int(20) Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(37) int(57) bool(true) unicode(7) "Unknown" *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation6.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation6.phpt +++ php-src/ext/standard/tests/file/007_variation6.phpt --TEST-- Test fopen and fclose() functions - usage variations - "a+" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "a+" mode, checking for the file creation, write & read operations, checking for the file pointer position, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 6, "bytes"); $file = $file_path."/007_variation6.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'a+' mode ***\n"; $file_handle = fopen($file, "a+"); //opening the file "a+" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of file var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation unlink($file); //Deleting the file fclose( fopen($file, "a+") ); //Opening the non-existing file in "a+" mode, which will be created var_dump( file_exists($file) ); //Check for the existance of file echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation6.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'a+' mode *** resource(8) of type (stream) string(6) "stream" int(37) string(57) "line line of text liabcdefghij mnopqrst uvwxyz 0123456789" int(57) bool(true) string(7) "Unknown" bool(true) *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'a+' mode *** resource(8) of type (stream) unicode(6) "stream" Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(37) string(57) "line line of text liabcdefghij mnopqrst uvwxyz 0123456789" int(57) bool(true) unicode(7) "Unknown" bool(true) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation8.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation8.phpt +++ php-src/ext/standard/tests/file/007_variation8.phpt --TEST-- Test fopen and fclose() functions - usage variations - "x+" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "x+" mode, checking for the file creation, write & read operations, checking for the file pointer position, checking for the warning msg when trying to open an existing file in "x+" mode, and fclose function */ $file_path = dirname(__FILE__); $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; $file = $file_path."/007_variation8.tmp"; echo "*** Test fopen() & fclose() functions: with 'x+' mode ***\n"; $file_handle = fopen($file, "x+"); //opening the non-existing file in "x+" mode, file will be created var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of the file var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation $file_handle = fopen($file, "x+"); //Opening the existing data file in "x+" mode to check for the warning message echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation8.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'x+' mode *** resource(5) of type (stream) string(6) "stream" int(0) int(37) int(37) string(37) "abcdefghij mnopqrst uvwxyz 0123456789" int(37) bool(true) string(7) "Unknown" Warning: fopen(%s): failed to open stream: File exists in %s on line %d *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'x+' mode *** resource(5) of type (stream) unicode(6) "stream" int(0) Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(37) int(37) string(37) "abcdefghij mnopqrst uvwxyz 0123456789" int(37) bool(true) unicode(7) "Unknown" Warning: fopen(%s): failed to open stream: File exists in %s on line %d *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation11-win32.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation11-win32.phpt +++ php-src/ext/standard/tests/file/007_variation11-win32.phpt --TEST-- Test fopen and fclose() functions - usage variations - "wt" mode --SKIPIF-- <?php if( substr(PHP_OS, 0, 3) != "WIN" ) die('skip Run only on Windows'); ?> --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "wt" mode, checking for the file creation, write & read operations, checking for the file pointer position, checking for the file truncation when trying to open an existing file in "wt" mode, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "wt", "007_variation", 11, "bytes"); $file = $file_path."/007_variation11.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'wt' mode ***\n"; $file_handle = fopen($file, "wt"); //opening the file "wt" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the begining of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "wt" mode again, expected: size of content clearstatcache(); fclose( fopen($file, "wt") ); //Opening the existing data file again in "wt" mode var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "wt" mode again, expected: 0 bytes clearstatcache(); unlink($file); //Deleting the file fclose( fopen($file, "wt") ); //Opening the non-existing file in "wt" mode, which will be created var_dump( file_exists($file) ); //Check for the existance of file echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation11.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'wt' mode *** resource(8) of type (stream) string(6) "stream" int(0) int(37) int(37) bool(false) int(0) bool(true) string(7) "Unknown" int(39) int(0) bool(true) *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'wt' mode *** resource(8) of type (stream) unicode(6) "stream" int(0) int(37) int(37) bool(false) int(0) bool(true) unicode(7) "Unknown" int(39) int(0) bool(true) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation13-win32.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation13-win32.phpt +++ php-src/ext/standard/tests/file/007_variation13-win32.phpt --TEST-- Test fopen and fclose() functions - usage variations - "at" mode --SKIPIF-- <?php if( substr(PHP_OS, 0, 3) != "WIN" ) die('skip Run only on Windows'); ?> --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "at" mode, checking for the file creation, write & read operations, checking for the file pointer position, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 13, "bytes"); $file = $file_path."/007_variation13.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'at' mode ***\n"; $file_handle = fopen($file, "at"); //opening the file "at" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation var_dump( filesize($file) ); //Check that data hasn't over written; Expected: Size of (initial data + newly added data) unlink($file); //Deleting the file fclose( fopen($file, "at") ); //Opening the non-existing file in "at" mode, which will be created var_dump( file_exists($file) ); //Check for the existance of file echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation13.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'at' mode *** resource(8) of type (stream) string(6) "stream" int(37) bool(false) int(0) bool(true) string(7) "Unknown" int(59) bool(true) *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'at' mode *** resource(8) of type (stream) unicode(6) "stream" int(37) bool(false) int(0) bool(true) unicode(7) "Unknown" int(59) bool(true) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation21.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation21.phpt +++ php-src/ext/standard/tests/file/007_variation21.phpt --TEST-- Test fopen and fclose() functions - usage variations - "ab" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "ab" mode, checking for the file creation, write & read operations, checking for the file pointer position, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 21, "bytes"); $file = $file_path."/007_variation21.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'ab' mode ***\n"; $file_handle = fopen($file, "ab"); //opening the file "ab" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation var_dump( filesize($file) ); //Check that data hasn't over written; Expected: Size of (initial data + newly added data) unlink($file); //Deleting the file fclose( fopen($file, "ab") ); //Opening the non-existing file in "ab" mode, which will be created var_dump( file_exists($file) ); //Check for the existance of file echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation21.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'ab' mode *** resource(8) of type (stream) string(6) "stream" int(37) bool(false) int(0) bool(true) string(7) "Unknown" int(57) bool(true) *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'ab' mode *** resource(8) of type (stream) unicode(6) "stream" Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(37) bool(false) int(0) bool(true) unicode(7) "Unknown" int(57) bool(true) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation11.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation11.phpt +++ php-src/ext/standard/tests/file/007_variation11.phpt --TEST-- Test fopen and fclose() functions - usage variations - "wt" mode --SKIPIF-- <?php if( substr(PHP_OS, 0, 3) == "WIN" ) die('skip Do not run on Windows'); ?> --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "wt" mode, checking for the file creation, write & read operations, checking for the file pointer position, checking for the file truncation when trying to open an existing file in "wt" mode, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "wt", "007_variation", 11, "bytes"); $file = $file_path."/007_variation11.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'wt' mode ***\n"; $file_handle = fopen($file, "wt"); //opening the file "wt" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the begining of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "wt" mode again, expected: size of content clearstatcache(); fclose( fopen($file, "wt") ); //Opening the existing data file again in "wt" mode var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "wt" mode again, expected: 0 bytes clearstatcache(); unlink($file); //Deleting the file fclose( fopen($file, "wt") ); //Opening the non-existing file in "wt" mode, which will be created var_dump( file_exists($file) ); //Check for the existance of file echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation11.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'wt' mode *** resource(8) of type (stream) string(6) "stream" int(0) int(37) int(37) bool(false) int(0) bool(true) string(7) "Unknown" int(37) int(0) bool(true) *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'wt' mode *** resource(8) of type (stream) unicode(6) "stream" int(0) int(37) int(37) bool(false) int(0) bool(true) unicode(7) "Unknown" int(37) int(0) bool(true) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation23.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation23.phpt +++ php-src/ext/standard/tests/file/007_variation23.phpt --TEST-- Test fopen and fclose() functions - usage variations - "xb" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "xb" mode, checking for the file creation, write & read operations, checking for the file pointer position, checking for the warning msg when trying to open an existing file in "xb" mode, and fclose function */ $file_path = dirname(__FILE__); $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; $file = $file_path."/007_variation23.tmp"; echo "*** Test fopen() & fclose() functions: with 'xb' mode ***\n"; $file_handle = fopen($file, "xb"); //opening the non-existing file in "xb" mode, file will be created var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the begining of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation $file_handle = fopen($file, "xb"); //Opening the existing data file in 'xb' mode to check for the warning message echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation23.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'xb' mode *** resource(5) of type (stream) string(6) "stream" int(0) int(37) int(37) bool(false) int(0) bool(true) string(7) "Unknown" Warning: fopen(%s): failed to open stream: File exists in %s on line %d *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'xb' mode *** resource(5) of type (stream) unicode(6) "stream" int(0) Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(37) int(37) bool(false) int(0) bool(true) unicode(7) "Unknown" Warning: fopen(%s): failed to open stream: File exists in %s on line %d *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation13.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation13.phpt +++ php-src/ext/standard/tests/file/007_variation13.phpt --TEST-- Test fopen and fclose() functions - usage variations - "at" mode --SKIPIF-- <?php if( substr(PHP_OS, 0, 3) == "WIN" ) die('skip Do not run on Windows'); ?> --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "at" mode, checking for the file creation, write & read operations, checking for the file pointer position, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 13, "bytes"); $file = $file_path."/007_variation13.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'at' mode ***\n"; $file_handle = fopen($file, "at"); //opening the file "at" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string rewind($file_handle); var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation var_dump( filesize($file) ); //Check that data hasn't over written; Expected: Size of (initial data + newly added data) unlink($file); //Deleting the file fclose( fopen($file, "at") ); //Opening the non-existing file in "at" mode, which will be created var_dump( file_exists($file) ); //Check for the existance of file echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation13.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'at' mode *** resource(8) of type (stream) string(6) "stream" int(37) bool(false) int(0) bool(true) string(7) "Unknown" int(57) bool(true) *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'at' mode *** resource(8) of type (stream) unicode(6) "stream" int(37) bool(false) int(0) bool(true) unicode(7) "Unknown" int(57) bool(true) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/007_variation1.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/file/007_variation1.phpt +++ php-src/ext/standard/tests/file/007_variation1.phpt --TEST-- Test fopen and fclose() functions - usage variations - "r" mode --FILE-- <?php /* fopen() function: Prototype: resource fopen(string $filename, string $mode [, bool $use_include_path [, resource $context]] ); Description: Opens file or URL. */ /* fclose() function: Prototype: bool fclose ( resource $handle ); Description: Closes an open file pointer */ /* Test fopen() and fclose(): Opening the file in "r" mode, checking for the file creation, write & read operations, checking for the file pointer position, and fclose function */ $file_path = dirname(__FILE__); require($file_path."/file.inc"); create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 1, "bytes"); $file = $file_path."/007_variation1.tmp"; $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789"; echo "*** Test fopen() & fclose() functions: with 'r' mode ***\n"; $file_handle = fopen($file, "r"); //opening the file in "r" mode var_dump($file_handle); //Check for the content of handle var_dump( get_resource_type($file_handle) ); //Check for the type of resource var_dump( ftell($file_handle) ); //Initial position of file pointer var_dump( fread($file_handle, 100) ); //Check for read operation var_dump( fwrite($file_handle, $string) ); //Check for write operation; fails; expected: 0 bytes var_dump( fclose($file_handle) ); //Check for close operation on the file handle var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation echo "*** Done ***\n"; --CLEAN-- <?php unlink(dirname(__FILE__)."/007_variation1.tmp"); ?> --EXPECTF-- *** Test fopen() & fclose() functions: with 'r' mode *** resource(8) of type (stream) string(6) "stream" int(0) string(20) "line line of text li" int(0) bool(true) string(7) "Unknown" *** Done *** --UEXPECTF-- *** Test fopen() & fclose() functions: with 'r' mode *** resource(8) of type (stream) unicode(6) "stream" int(0) string(20) "line line of text li" Notice: fwrite(): 37 character unicode buffer downcoded for binary stream runtime_encoding in %s on line %d int(0) bool(true) unicode(7) "Unknown" *** Done ***
« previous php.cvs (#45870) next »