1--TEST-- 2fopencookie detected and working (or cast mechanism works) 3--FILE-- 4<?php 5 6/* This test verifies that the casting mechanism is working correctly. 7 * On systems with fopencookie, a FILE* is created around the user 8 * stream and that is passed back to the ZE to include. 9 * On systems without fopencookie, the stream is fed into a temporary 10 * file, and that temporary file is passed back to the ZE. 11 * The important thing here is really fopencookie; the glibc people 12 * changed the binary interface, so if haven't detected it correctly, 13 * you can expect this test to segfault. 14 * 15 * FIXME: the test really needs something to fseek(3) on the FILE* 16 * used internally for this test to be really effective. 17 */ 18 19class userstream { 20 public $position = 0; 21 public $data = "If you can read this, it worked"; 22 23 function stream_open($path, $mode, $options, &$opened_path) 24 { 25 return true; 26 } 27 28 function stream_read($count) 29 { 30 $ret = substr($this->data, $this->position, $count); 31 $this->position += strlen($ret); 32 return $ret; 33 } 34 35 function stream_tell() 36 { 37 return $this->position; 38 } 39 40 function stream_eof() 41 { 42 return $this->position >= strlen($this->data); 43 } 44 45 function stream_seek($offset, $whence) 46 { 47 switch($whence) { 48 case SEEK_SET: 49 if ($offset < strlen($this->data) && $offset >= 0) { 50 $this->position = $offset; 51 return true; 52 } else { 53 return false; 54 } 55 break; 56 case SEEK_CUR: 57 if ($offset >= 0) { 58 $this->position += $offset; 59 return true; 60 } else { 61 return false; 62 } 63 break; 64 case SEEK_END: 65 if (strlen($this->data) + $offset >= 0) { 66 $this->position = strlen($this->data) + $offset; 67 return true; 68 } else { 69 return false; 70 } 71 break; 72 default: 73 return false; 74 } 75 } 76 function stream_stat() { 77 return array('size' => strlen($this->data)); 78 } 79 function stream_set_option($option, $arg1, $arg2) { 80 return false; 81 } 82} 83 84stream_wrapper_register("cookietest", "userstream"); 85 86include("cookietest://foo"); 87 88?> 89--EXPECT-- 90If you can read this, it worked 91