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

1.1       misho       1: --TEST--
                      2: Test fileatime(), filemtime(), filectime() & touch() functions : error conditions 
                      3: --FILE--
                      4: <?php
                      5: /*
                      6:    Prototype: int fileatime ( string $filename );
                      7:    Description: Returns the time the file was last accessed, or FALSE
                      8:      in case of an error. The time is returned as a Unix timestamp.
                      9: 
                     10:    Prototype: int filemtime ( string $filename );
                     11:    Description: Returns the time the file was last modified, or FALSE
                     12:      in case of an error.
                     13: 
                     14:    Prototype: int filectime ( string $filename );
                     15:    Description: Returns the time the file was last changed, or FALSE
                     16:      in case of an error. The time is returned as a Unix timestamp.
                     17: 
                     18:    Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
                     19:    Description: Attempts to set the access and modification times of the file
                     20:      named in the filename parameter to the value given in time.
                     21: */
                     22: 
                     23: echo "*** Testing error conditions ***\n";
                     24: 
                     25: echo "\n-- Testing with  Non-existing files --";
                     26: /* Both invalid argumetns */
                     27: var_dump( fileatime("/no/such/file/or/dir") );
                     28: var_dump( filemtime("/no/such/file/or/dir") );
                     29: var_dump( filectime("/no/such/file/or/dir") );
                     30: var_dump( touch("/no/such/file/or/dir", 10) );
                     31: 
                     32: /* Only one invalid argument */
                     33: var_dump( fileatime(__FILE__, "string") );
                     34: var_dump( filemtime(__FILE__, 100) );
                     35: var_dump( filectime(__FILE__, TRUE) );
                     36: var_dump( touch(__FILE__, 10, 100, 123) );
                     37: 
                     38: echo "\n-- Testing No.of arguments less than expected --";
                     39: var_dump( fileatime() );
                     40: var_dump( filemtime() );
                     41: var_dump( filectime() );
                     42: var_dump( touch() );
                     43: 
                     44: echo "\n-- Testing No.of arguments greater than expected --";
                     45: /* Both invalid arguments */
                     46: var_dump( fileatime("/no/such/file/or/dir", "string") );
                     47: var_dump( filemtime("/no/such/file/or/dir", 100) );
                     48: var_dump( filectime("/no/such/file/or/dir", TRUE) );
                     49: var_dump( touch("/no/such/file/or/dir", 10, 100, 123) );
                     50: 
                     51: /* Only one invalid argument */
                     52: var_dump( fileatime(__FILE__, "string") );
                     53: var_dump( filemtime(__FILE__, 100) );
                     54: var_dump( filectime(__FILE__, TRUE) );
                     55: var_dump( touch(__FILE__, 10, 100, 123) );
                     56: 
                     57: echo "\nDone";
                     58: ?>
                     59: --EXPECTF--    
                     60: *** Testing error conditions ***
                     61: 
                     62: -- Testing with  Non-existing files --
                     63: Warning: fileatime(): stat failed for /no/such/file/or/dir in %s on line %d
                     64: bool(false)
                     65: 
                     66: Warning: filemtime(): stat failed for /no/such/file/or/dir in %s on line %d
                     67: bool(false)
                     68: 
                     69: Warning: filectime(): stat failed for /no/such/file/or/dir in %s on line %d
                     70: bool(false)
                     71: 
                     72: Warning: touch(): Unable to create file /no/such/file/or/dir because No such file or directory in %s on line %d
                     73: bool(false)
                     74: 
                     75: Warning: fileatime() expects exactly 1 parameter, 2 given in %s on line %d
                     76: NULL
                     77: 
                     78: Warning: filemtime() expects exactly 1 parameter, 2 given in %s on line %d
                     79: NULL
                     80: 
                     81: Warning: filectime() expects exactly 1 parameter, 2 given in %s on line %d
                     82: NULL
                     83: 
                     84: Warning: touch() expects at most 3 parameters, 4 given in %s on line %d
                     85: NULL
                     86: 
                     87: -- Testing No.of arguments less than expected --
                     88: Warning: fileatime() expects exactly 1 parameter, 0 given in %s on line %d
                     89: NULL
                     90: 
                     91: Warning: filemtime() expects exactly 1 parameter, 0 given in %s on line %d
                     92: NULL
                     93: 
                     94: Warning: filectime() expects exactly 1 parameter, 0 given in %s on line %d
                     95: NULL
                     96: 
                     97: Warning: touch() expects at least 1 parameter, 0 given in %s on line %d
                     98: NULL
                     99: 
                    100: -- Testing No.of arguments greater than expected --
                    101: Warning: fileatime() expects exactly 1 parameter, 2 given in %s on line %d
                    102: NULL
                    103: 
                    104: Warning: filemtime() expects exactly 1 parameter, 2 given in %s on line %d
                    105: NULL
                    106: 
                    107: Warning: filectime() expects exactly 1 parameter, 2 given in %s on line %d
                    108: NULL
                    109: 
                    110: Warning: touch() expects at most 3 parameters, 4 given in %s on line %d
                    111: NULL
                    112: 
                    113: Warning: fileatime() expects exactly 1 parameter, 2 given in %s on line %d
                    114: NULL
                    115: 
                    116: Warning: filemtime() expects exactly 1 parameter, 2 given in %s on line %d
                    117: NULL
                    118: 
                    119: Warning: filectime() expects exactly 1 parameter, 2 given in %s on line %d
                    120: NULL
                    121: 
                    122: Warning: touch() expects at most 3 parameters, 4 given in %s on line %d
                    123: NULL
                    124: 
                    125: Done
                    126: 

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