Annotation of embedaddon/php/ext/standard/tests/file/userstreams_003.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: User-space streams: stream_set_option()
! 3: --FILE--
! 4: <?php
! 5: class test_wrapper_base {
! 6: public $return_value;
! 7: public $expected_option;
! 8: public $expected_value;
! 9: function stream_open($path, $mode, $openedpath) {
! 10: return true;
! 11: }
! 12: function stream_eof() {
! 13: return false;
! 14: }
! 15: }
! 16: class test_wrapper extends test_wrapper_base {
! 17: function stream_set_option($option, $value, $ptrparam) {
! 18: echo "value:\n";
! 19: var_dump($value);
! 20: echo "ptrparam:\n";
! 21: var_dump($ptrparam);
! 22: echo "\$option === $option === " . $this->expected_option . ":\n";;
! 23: var_dump($option === $this->expected_option);
! 24: echo "\$value === $value === " . $this->expected_value. ":\n";;
! 25: var_dump($value === $this->expected_value);
! 26: return $this->return_value;
! 27: }
! 28: }
! 29:
! 30: function test($name, $fd, $return_value, $func, $args, $expected_option, $expected_value) {
! 31: echo "\n------ $name: -------\n";
! 32: $data = stream_get_meta_data($fd);
! 33: $data['wrapper_data']->return_value = $return_value;
! 34: $data['wrapper_data']->expected_option = $expected_option;
! 35: $data['wrapper_data']->expected_value = $expected_value;
! 36: var_dump(call_user_func_array($func, $args));
! 37: }
! 38:
! 39: var_dump(stream_wrapper_register('test', 'test_wrapper'));
! 40: var_dump(stream_wrapper_register('test2', 'test_wrapper_base'));
! 41:
! 42: $fd = fopen("test://foo","r");
! 43: $fd2 = fopen("test2://foo","r");
! 44:
! 45: test("stream_set_blocking - 1", $fd, true, "stream_set_blocking", array($fd,0), STREAM_OPTION_BLOCKING, 0);
! 46: test("stream_set_blocking - 2", $fd, false, "stream_set_blocking", array($fd,1), STREAM_OPTION_BLOCKING, 1);
! 47: test("stream_set_blocking - 3", $fd, "foo", "stream_set_blocking", array($fd,0), STREAM_OPTION_BLOCKING, 0);
! 48: test("stream_set_blocking - 4", $fd2, true, "stream_set_blocking", array($fd2,1), STREAM_OPTION_BLOCKING, 1);
! 49:
! 50: test("stream_set_write_buffer - 1", $fd, true, "stream_set_write_buffer", array($fd,0), STREAM_OPTION_WRITE_BUFFER, STREAM_BUFFER_NONE);
! 51: test("stream_set_write_buffer - 2", $fd, true, "stream_set_write_buffer", array($fd,4096), STREAM_OPTION_WRITE_BUFFER, STREAM_BUFFER_FULL);
! 52: test("stream_set_write_buffer - 3", $fd, false, "stream_set_write_buffer", array($fd,8192), STREAM_OPTION_WRITE_BUFFER, STREAM_BUFFER_FULL);
! 53:
! 54: test("stream_set_timeout - 1", $fd, true, "stream_set_timeout", array($fd,10,11), STREAM_OPTION_READ_TIMEOUT, 10);
! 55: test("stream_set_timeout - 2", $fd, false, "stream_set_timeout", array($fd,11,12), STREAM_OPTION_READ_TIMEOUT, 11);
! 56:
! 57: ?>
! 58: --EXPECTF--
! 59: bool(true)
! 60: bool(true)
! 61:
! 62: ------ stream_set_blocking - 1: -------
! 63: value:
! 64: int(0)
! 65: ptrparam:
! 66: NULL
! 67: $option === 1 === 1:
! 68: bool(true)
! 69: $value === 0 === 0:
! 70: bool(true)
! 71: bool(true)
! 72:
! 73: ------ stream_set_blocking - 2: -------
! 74: value:
! 75: int(1)
! 76: ptrparam:
! 77: NULL
! 78: $option === 1 === 1:
! 79: bool(true)
! 80: $value === 1 === 1:
! 81: bool(true)
! 82: bool(false)
! 83:
! 84: ------ stream_set_blocking - 3: -------
! 85: value:
! 86: int(0)
! 87: ptrparam:
! 88: NULL
! 89: $option === 1 === 1:
! 90: bool(true)
! 91: $value === 0 === 0:
! 92: bool(true)
! 93: bool(true)
! 94:
! 95: ------ stream_set_blocking - 4: -------
! 96:
! 97: Warning: stream_set_blocking(): test_wrapper_base::stream_set_option is not implemented! in %s
! 98: bool(false)
! 99:
! 100: ------ stream_set_write_buffer - 1: -------
! 101: value:
! 102: int(0)
! 103: ptrparam:
! 104: int(%d)
! 105: $option === 3 === 3:
! 106: bool(true)
! 107: $value === 0 === 0:
! 108: bool(true)
! 109: int(0)
! 110:
! 111: ------ stream_set_write_buffer - 2: -------
! 112: value:
! 113: int(2)
! 114: ptrparam:
! 115: int(4096)
! 116: $option === 3 === 3:
! 117: bool(true)
! 118: $value === 2 === 2:
! 119: bool(true)
! 120: int(0)
! 121:
! 122: ------ stream_set_write_buffer - 3: -------
! 123: value:
! 124: int(2)
! 125: ptrparam:
! 126: int(8192)
! 127: $option === 3 === 3:
! 128: bool(true)
! 129: $value === 2 === 2:
! 130: bool(true)
! 131: int(-1)
! 132:
! 133: ------ stream_set_timeout - 1: -------
! 134: value:
! 135: int(10)
! 136: ptrparam:
! 137: int(11)
! 138: $option === 4 === 4:
! 139: bool(true)
! 140: $value === 10 === 10:
! 141: bool(true)
! 142: bool(true)
! 143:
! 144: ------ stream_set_timeout - 2: -------
! 145: value:
! 146: int(11)
! 147: ptrparam:
! 148: int(12)
! 149: $option === 4 === 4:
! 150: bool(true)
! 151: $value === 11 === 11:
! 152: bool(true)
! 153: bool(false)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>