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

1.1       misho       1: --TEST--
                      2: Test fopen and fclose() functions - usage variations - "a+b" mode 
                      3: --FILE--
                      4: <?php
                      5: /*
                      6:  fopen() function:
                      7:  Prototype: resource fopen(string $filename, string $mode
                      8:                             [, bool $use_include_path [, resource $context]] );
                      9:  Description: Opens file or URL.
                     10: */
                     11: /*
                     12:  fclose() function:
                     13:  Prototype: bool fclose ( resource $handle );
                     14:  Description: Closes an open file pointer
                     15: */
                     16: 
                     17: /* Test fopen() and fclose(): Opening the file in "a+b" mode,
                     18:    checking for the file creation, write & read operations,
                     19:    checking for the file pointer position,
                     20:    and fclose function
                     21: */
                     22: $file_path = dirname(__FILE__);
                     23: require($file_path."/file.inc");
                     24: 
                     25: create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 22, "bytes");
                     26: $file = $file_path."/007_variation22.tmp";
                     27: $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
                     28: 
                     29: echo "*** Test fopen() & fclose() functions:  with 'a+b' mode ***\n";
                     30: $file_handle = fopen($file, "a+b");  //opening the file "a+b" mode
                     31: var_dump($file_handle);  //Check for the content of handle
                     32: var_dump( get_resource_type($file_handle) );  //Check for the type of resource
                     33: var_dump( fwrite($file_handle, $string) );  //Check for write operation; passes; expected:size of the $string
                     34: rewind($file_handle);
                     35: var_dump( fread($file_handle, 100) );  //Check for read operation; passes; expected: content of file
                     36: var_dump( ftell($file_handle) );  //File pointer position after read operation, expected at the end of the file
                     37: var_dump( fclose($file_handle) );  //Check for close operation on the file handle
                     38: var_dump( get_resource_type($file_handle) );  //Check whether resource is lost after close operation
                     39: 
                     40: unlink($file);  //Deleting the file
                     41: fclose( fopen($file, "a+b") );  //Opening the non-existing file in "a+b" mode, which will be created
                     42: var_dump( file_exists($file) );  //Check for the existance of file
                     43: echo "*** Done ***\n"; 
                     44: --CLEAN--
                     45: <?php
                     46: unlink(dirname(__FILE__)."/007_variation22.tmp");
                     47: ?>
                     48: --EXPECTF--
                     49: *** Test fopen() & fclose() functions:  with 'a+b' mode ***
                     50: resource(%d) of type (stream)
                     51: string(6) "stream"
                     52: int(37)
                     53: string(57) "line
                     54: line of text
                     55: liabcdefghij
                     56: mnopqrst       uvwxyz
                     57: 0123456789"
                     58: int(57)
                     59: bool(true)
                     60: string(7) "Unknown"
                     61: bool(true)
                     62: *** Done ***

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