Return to userwrapper.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Userstream unlink, rename, mkdir, rmdir, and url_stat. 3: --FILE-- 4: <?php # vim:ft=php: 5: class test { 6: function unlink($file) { 7: print "Unlinking file: $file\n"; 8: } 9: 10: function rename($from, $to) { 11: print "Renaming $from to $to\n"; 12: } 13: 14: function mkdir($directory, $mode, $options) { 15: printf("Making directory: %s as %o%s\n", $directory, $mode, $options & STREAM_MKDIR_RECURSIVE ? " recursively" : ""); 16: } 17: 18: function rmdir($directory, $options) { 19: print "Removing directory: $directory\n"; 20: } 21: 22: function url_stat($path, $options) { 23: /* By printing out a notice that we are actively stating the file 24: then subsequently performing multiple stat operations on it 25: we effectively test the stat cache mechanism */ 26: print "Stating file: $path\n"; 27: return array('dev'=>1, 'ino'=>2, 'mode'=>0644, 'nlink'=>3, 28: 'uid'=>100, 'gid'=>1000, 'rdev'=>-1, 'size'=>31337, 29: 'atime'=>1234567890, 'mtime'=>1231231231, 'ctime'=>1234564564, 30: 'blksize'=>-1, 'blocks'=>-1); 31: } 32: } 33: 34: stream_wrapper_register('test', 'test'); 35: 36: unlink('test://example.com/path/to/file'); 37: rename('test://example.com/path/to/from', 'test://example.com/path/to/to'); 38: /* We *want* this to fail and thus not output the watch statement */ 39: @rename('test://example.com/path/to/from', 'http://example.com/path/to/to'); 40: mkdir('test://example.com/path/to/directory', 0755); 41: rmdir('test://example.com/path/to/directory'); 42: print_r(stat('test://example.com/path/to/file')); 43: echo "Filesize = " . filesize('test://example.com/path/to/file') . "\n"; 44: echo "filemtime = " . filemtime('test://example.com/path/to/file') . "\n"; 45: ?> 46: --EXPECT-- 47: Unlinking file: test://example.com/path/to/file 48: Renaming test://example.com/path/to/from to test://example.com/path/to/to 49: Making directory: test://example.com/path/to/directory as 755 50: Removing directory: test://example.com/path/to/directory 51: Stating file: test://example.com/path/to/file 52: Array 53: ( 54: [0] => 1 55: [1] => 2 56: [2] => 420 57: [3] => 3 58: [4] => 100 59: [5] => 1000 60: [6] => -1 61: [7] => 31337 62: [8] => 1234567890 63: [9] => 1231231231 64: [10] => 1234564564 65: [11] => -1 66: [12] => -1 67: [dev] => 1 68: [ino] => 2 69: [mode] => 420 70: [nlink] => 3 71: [uid] => 100 72: [gid] => 1000 73: [rdev] => -1 74: [size] => 31337 75: [atime] => 1234567890 76: [mtime] => 1231231231 77: [ctime] => 1234564564 78: [blksize] => -1 79: [blocks] => -1 80: ) 81: Filesize = 31337 82: filemtime = 1231231231 83: