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

1.1       misho       1: --TEST--
                      2: Test file function : variation - test various endings of a file
                      3: --CREDITS--
                      4: Dave Kelsey <d_kelsey@uk.ibm.com>
                      5: --FILE--
                      6: <?php
                      7: /* Prototype  : array file(string filename [, int flags[, resource context]])
                      8:  * Description: Read entire file into an array 
                      9:  * Source code: ext/standard/file.c
                     10:  * Alias to functions: 
                     11:  */
                     12: 
                     13: echo "*** Testing file() : variation ***\n";
                     14: $testfile = dirname(__FILE__)."/fileVar9.txt";
                     15: 
                     16: $contents = array(
                     17:    "File ends on a single character\na",
                     18:    "File ends on a new line\n",
                     19:    "File ends on multiple newlines\n\n\n\n",
                     20:    "File has\n\nmultiple lines and newlines\n\n",
                     21:    "File has\r\nmultiple crlfs\n\r\n"
                     22:    );
                     23: 
                     24: @unlink($testfile);   
                     25: foreach ($contents as $content) {
                     26:     $h = fopen($testfile, "w");
                     27:     fwrite($h, $content);
                     28:     fclose($h);
                     29:     var_dump(file($testfile));
                     30:        unlink($testfile);
                     31: }
                     32: 
                     33: echo "\n*** Done ***\n";
                     34: ?>
                     35: --EXPECTF--
                     36: *** Testing file() : variation ***
                     37: array(2) {
                     38:   [0]=>
                     39:   string(32) "File ends on a single character
                     40: "
                     41:   [1]=>
                     42:   string(1) "a"
                     43: }
                     44: array(1) {
                     45:   [0]=>
                     46:   string(24) "File ends on a new line
                     47: "
                     48: }
                     49: array(4) {
                     50:   [0]=>
                     51:   string(31) "File ends on multiple newlines
                     52: "
                     53:   [1]=>
                     54:   string(1) "
                     55: "
                     56:   [2]=>
                     57:   string(1) "
                     58: "
                     59:   [3]=>
                     60:   string(1) "
                     61: "
                     62: }
                     63: array(4) {
                     64:   [0]=>
                     65:   string(9) "File has
                     66: "
                     67:   [1]=>
                     68:   string(1) "
                     69: "
                     70:   [2]=>
                     71:   string(28) "multiple lines and newlines
                     72: "
                     73:   [3]=>
                     74:   string(1) "
                     75: "
                     76: }
                     77: array(3) {
                     78:   [0]=>
                     79:   string(10) "File has
                     80: "
                     81:   [1]=>
                     82:   string(15) "multiple crlfs
                     83: "
                     84:   [2]=>
                     85:   string(2) "
                     86: "
                     87: }
                     88: 
                     89: *** Done ***

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