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

1.1       misho       1: --TEST--
                      2: Test fileatime(), filemtime(), filectime() & touch() functions : usage variation
                      3: --CREDITS--
                      4: Dave Kelsey <d_kelsey@uk.ibm.com>
                      5: --SKIPIF--
                      6: <?php
                      7: if (substr(PHP_OS, 0, 3) == 'WIN') {
                      8:     die('skip.. only for Non Windows Systems');
                      9: }
                     10: ?>
                     11: --FILE--
                     12: <?php
                     13: /*
                     14:    Prototype: int fileatime ( string $filename );
                     15:    Description: Returns the time the file was last accessed, or FALSE 
                     16:      in case of an error. The time is returned as a Unix timestamp.
                     17: 
                     18:    Prototype: int filemtime ( string $filename );
                     19:    Description: Returns the time the file was last modified, or FALSE 
                     20:      in case of an error. 
                     21: 
                     22:    Prototype: int filectime ( string $filename );
                     23:    Description: Returns the time the file was last changed, or FALSE
                     24:      in case of an error. The time is returned as a Unix timestamp.
                     25: 
                     26:    Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
                     27:    Description: Attempts to set the access and modification times of the file
                     28:      named in the filename parameter to the value given in time.
                     29: */
                     30: 
                     31: /*
                     32:    Prototype: void stat_fn(string $filename);
                     33:    Description: Prints access, modification and change times of a file
                     34: */
                     35: function stat_fn( $filename ) {
                     36:   echo "\n-- File '$filename' --\n";
                     37:   echo "-- File access time is => "; 
                     38:   echo fileatime($filename)."\n";
                     39:   clearstatcache();
                     40:   echo "-- File modification time is => "; 
                     41:   echo filemtime($filename)."\n";
                     42:   clearstatcache();
                     43:   echo "-- inode change time is => "; 
                     44:   echo filectime($filename)."\n";
                     45:   clearstatcache();
                     46:   
                     47: 
                     48: }
                     49: 
                     50: echo "*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***\n";
                     51: echo "\n*** testing touch ***\n";
                     52: $a = touch(NULL);
                     53: $b = touch(false);
                     54: $c = touch('');
                     55: $d = touch(' ');
                     56: $e = touch('|');
                     57: 
                     58: var_dump($a);
                     59: var_dump($b);
                     60: var_dump($c);
                     61: var_dump($d);
                     62: var_dump($e);
                     63: 
                     64: echo "\n*** testing file info ***";
                     65: stat_fn(NULL);
                     66: stat_fn(false);
                     67: stat_fn('');
                     68: stat_fn(' ');
                     69: stat_fn('|');
                     70: 
                     71: var_dump(unlink(' '));
                     72: var_dump(unlink('|'));
                     73: 
                     74: echo "Done";
                     75: ?>
                     76: --EXPECTF--
                     77: *** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***
                     78: 
                     79: *** testing touch ***
                     80: bool(false)
                     81: bool(false)
                     82: bool(false)
                     83: bool(true)
                     84: bool(true)
                     85: 
                     86: *** testing file info ***
                     87: -- File '' --
                     88: -- File access time is => 
                     89: -- File modification time is => 
                     90: -- inode change time is => 
                     91: 
                     92: -- File '' --
                     93: -- File access time is => 
                     94: -- File modification time is => 
                     95: -- inode change time is => 
                     96: 
                     97: -- File '' --
                     98: -- File access time is => 
                     99: -- File modification time is => 
                    100: -- inode change time is => 
                    101: 
                    102: -- File ' ' --
                    103: -- File access time is => %d
                    104: -- File modification time is => %d
                    105: -- inode change time is => %d
                    106: 
                    107: -- File '|' --
                    108: -- File access time is => %d
                    109: -- File modification time is => %d
                    110: -- inode change time is => %d
                    111: bool(true)
                    112: bool(true)
                    113: Done

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