Annotation of embedaddon/php/ext/standard/tests/file/file_get_contents_variation8.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: Test file_get_contents() function : variation - obscure filenames
                      3: --CREDITS--
                      4: Dave Kelsey <d_kelsey@uk.ibm.com>
                      5: --SKIPIF--
                      6: <?php
1.1.1.2 ! misho       7: if (substr(PHP_OS, 0, 3) == 'WIN') {
        !             8:     die('skip.. Not valid for Windows');
        !             9: }
1.1       misho      10: ?>
                     11: --FILE--
                     12: <?php
                     13: /* Prototype  : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
                     14:  * Description: Read the entire file into a string 
                     15:  * Source code: ext/standard/file.c
                     16:  * Alias to functions: 
                     17:  */
                     18: 
                     19: echo "*** Testing file_get_contents() : variation ***\n";
                     20: /* An array of filenames */ 
                     21: $names_arr = array(
                     22:   /* Invalid args */ 
                     23:   -1,
                     24:   TRUE,
                     25:   FALSE,
                     26:   NULL,
                     27:   "",
                     28:   " ",
                     29:   "\0",
                     30:   array(),
                     31: 
                     32:   /* prefix with path separator of a non existing directory*/
                     33:   "/no/such/file/dir", 
                     34:   "php/php"
                     35: 
                     36: );
                     37: 
                     38: for( $i=0; $i<count($names_arr); $i++ ) {
                     39:   echo "-- Iteration $i --\n";
                     40:   var_dump(file_get_contents($names_arr[$i]));
                     41: }
                     42: 
                     43: echo "\n*** Done ***\n";
                     44: ?>
                     45: --EXPECTF--
                     46: *** Testing file_get_contents() : variation ***
                     47: -- Iteration 0 --
                     48: 
                     49: Warning: file_get_contents(-1): failed to open stream: No such file or directory in %s on line %d
                     50: bool(false)
                     51: -- Iteration 1 --
                     52: 
                     53: Warning: file_get_contents(1): failed to open stream: No such file or directory in %s on line %d
                     54: bool(false)
                     55: -- Iteration 2 --
                     56: 
                     57: Warning: file_get_contents(): Filename cannot be empty in %s on line %d
                     58: bool(false)
                     59: -- Iteration 3 --
                     60: 
                     61: Warning: file_get_contents(): Filename cannot be empty in %s on line %d
                     62: bool(false)
                     63: -- Iteration 4 --
                     64: 
                     65: Warning: file_get_contents(): Filename cannot be empty in %s on line %d
                     66: bool(false)
                     67: -- Iteration 5 --
                     68: 
                     69: Warning: file_get_contents( ): failed to open stream: No such file or directory in %s on line %d
                     70: bool(false)
                     71: -- Iteration 6 --
1.1.1.2 ! misho      72: 
        !            73: Warning: file_get_contents() expects parameter 1 to be a valid path, string given in %s on line %d
        !            74: NULL
1.1       misho      75: -- Iteration 7 --
                     76: 
1.1.1.2 ! misho      77: Warning: file_get_contents() expects parameter 1 to be a valid path, array given in %s on line %d
1.1       misho      78: NULL
                     79: -- Iteration 8 --
                     80: 
1.1.1.2 ! misho      81: Warning: file_get_contents(/no/such/file/dir): failed to open stream: No such file or directory in %s on line %d
1.1       misho      82: bool(false)
                     83: -- Iteration 9 --
                     84: 
                     85: Warning: file_get_contents(php/php): failed to open stream: No such file or directory in %s on line %d
                     86: bool(false)
                     87: 
                     88: *** Done ***

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