Return to bug40459.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / streams |
1.1 misho 1: --TEST-- 2: bug 40459 - Test whether the constructor of the user-space stream wrapper is called when stream functions are called 3: --FILE-- 4: <?php 5: // Test whether the constructor of the user-space stream wrapper is called when stream functions are called 6: class testwrapper { 7: private $constructorCalled = false; 8: function __construct() { 9: $this->constructorCalled = true; 10: } 11: 12: function stream_open($path, $mode, $options, &$opened_path) 13: { 14: echo $this->constructorCalled ? 'yes' : 'no'; 15: return true; 16: } 17: 18: function url_stat($url, $flags) 19: { 20: echo $this->constructorCalled ? 'yes' : 'no'; 21: return array(); 22: } 23: 24: function unlink($url) 25: { 26: echo $this->constructorCalled ? 'yes' : 'no'; 27: } 28: 29: function rename($from, $to) 30: { 31: echo $this->constructorCalled ? 'yes' : 'no'; 32: } 33: 34: function mkdir($dir, $mode, $options) 35: { 36: echo $this->constructorCalled ? 'yes' : 'no'; 37: } 38: 39: function rmdir($dir, $options) 40: { 41: echo $this->constructorCalled ? 'yes' : 'no'; 42: } 43: 44: function dir_opendir($url, $options) 45: { 46: echo $this->constructorCalled ? 'yes' : 'no'; 47: return TRUE; 48: } 49: function stream_metadata() 50: { 51: echo $this->constructorCalled ? 'yes' : 'no'; 52: return TRUE; 53: } 54: } 55: 56: stream_wrapper_register('test', 'testwrapper', STREAM_IS_URL); 57: 58: echo 'stream_open: '; 59: fopen('test://test', 'r'); 60: echo "\n"; 61: 62: echo 'url_stat: '; 63: stat('test://test'); 64: echo "\n"; 65: 66: echo 'dir_opendir: '; 67: opendir('test://test'); 68: echo "\n"; 69: 70: echo 'rmdir: '; 71: rmdir('test://test'); 72: echo "\n"; 73: 74: echo 'mkdir: '; 75: mkdir('test://test'); 76: echo "\n"; 77: 78: echo 'rename: '; 79: rename('test://test', 'test://test2'); 80: echo "\n"; 81: 82: echo 'unlink: '; 83: unlink('test://test'); 84: echo "\n"; 85: 86: echo 'touch: '; 87: touch('test://test', time()); 88: echo "\n"; 89: 90: 91: 92: ?> 93: ==DONE== 94: --EXPECT-- 95: stream_open: yes 96: url_stat: yes 97: dir_opendir: yes 98: rmdir: yes 99: mkdir: yes 100: rename: yes 101: unlink: yes 102: touch: yes 103: ==DONE==