Annotation of embedaddon/php/tests/output/ob_start_basic_004.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
1.1.1.2 ! misho 2: ob_start() chunk_size: confirm buffer is flushed after any output call that causes its length to equal or exceed chunk_size.
1.1 misho 3: --FILE--
4: <?php
5: /*
6: * proto bool ob_start([ string|array user_function [, int chunk_size [, bool erase]]])
7: * Function is implemented in main/output.c
8: */
1.1.1.2 ! misho 9: // In HEAD, $chunk_size value of 1 should not have any special behaviour (http://marc.info/?l=php-internals&m=123476465621346&w=2).
1.1 misho 10: function callback($string) {
11: global $callback_invocations;
12: $callback_invocations++;
13: $len = strlen($string);
14: return "f[call:$callback_invocations; len:$len]$string\n";
15: }
16:
17: for ($cs=-1; $cs<10; $cs++) {
18: echo "\n----( chunk_size: $cs, output append size: 1 )----\n";
19: $callback_invocations=0;
20: ob_start('callback', $cs);
21: echo '1'; echo '2'; echo '3'; echo '4'; echo '5'; echo '6'; echo '7'; echo '8';
22: ob_end_flush();
23: }
24:
25: for ($cs=-1; $cs<10; $cs++) {
26: echo "\n----( chunk_size: $cs, output append size: 4 )----\n";
27: $callback_invocations=0;
28: ob_start('callback', $cs);
29: echo '1234'; echo '5678';
30: ob_end_flush();
31: }
32:
33: ?>
34: --EXPECTF--
35:
36: ----( chunk_size: -1, output append size: 1 )----
37: f[call:1; len:8]12345678
38:
39: ----( chunk_size: 0, output append size: 1 )----
40: f[call:1; len:8]12345678
41:
42: ----( chunk_size: 1, output append size: 1 )----
1.1.1.2 ! misho 43: f[call:1; len:1]1
! 44: f[call:2; len:1]2
! 45: f[call:3; len:1]3
! 46: f[call:4; len:1]4
! 47: f[call:5; len:1]5
! 48: f[call:6; len:1]6
! 49: f[call:7; len:1]7
! 50: f[call:8; len:1]8
! 51: f[call:9; len:0]
1.1 misho 52:
53: ----( chunk_size: 2, output append size: 1 )----
54: f[call:1; len:2]12
55: f[call:2; len:2]34
56: f[call:3; len:2]56
57: f[call:4; len:2]78
58: f[call:5; len:0]
59:
60: ----( chunk_size: 3, output append size: 1 )----
61: f[call:1; len:3]123
62: f[call:2; len:3]456
63: f[call:3; len:2]78
64:
65: ----( chunk_size: 4, output append size: 1 )----
66: f[call:1; len:4]1234
67: f[call:2; len:4]5678
68: f[call:3; len:0]
69:
70: ----( chunk_size: 5, output append size: 1 )----
71: f[call:1; len:5]12345
72: f[call:2; len:3]678
73:
74: ----( chunk_size: 6, output append size: 1 )----
75: f[call:1; len:6]123456
76: f[call:2; len:2]78
77:
78: ----( chunk_size: 7, output append size: 1 )----
79: f[call:1; len:7]1234567
80: f[call:2; len:1]8
81:
82: ----( chunk_size: 8, output append size: 1 )----
83: f[call:1; len:8]12345678
84: f[call:2; len:0]
85:
86: ----( chunk_size: 9, output append size: 1 )----
87: f[call:1; len:8]12345678
88:
89: ----( chunk_size: -1, output append size: 4 )----
90: f[call:1; len:8]12345678
91:
92: ----( chunk_size: 0, output append size: 4 )----
93: f[call:1; len:8]12345678
94:
95: ----( chunk_size: 1, output append size: 4 )----
1.1.1.2 ! misho 96: f[call:1; len:4]1234
! 97: f[call:2; len:4]5678
! 98: f[call:3; len:0]
1.1 misho 99:
100: ----( chunk_size: 2, output append size: 4 )----
101: f[call:1; len:4]1234
102: f[call:2; len:4]5678
103: f[call:3; len:0]
104:
105: ----( chunk_size: 3, output append size: 4 )----
106: f[call:1; len:4]1234
107: f[call:2; len:4]5678
108: f[call:3; len:0]
109:
110: ----( chunk_size: 4, output append size: 4 )----
111: f[call:1; len:4]1234
112: f[call:2; len:4]5678
113: f[call:3; len:0]
114:
115: ----( chunk_size: 5, output append size: 4 )----
116: f[call:1; len:8]12345678
117: f[call:2; len:0]
118:
119: ----( chunk_size: 6, output append size: 4 )----
120: f[call:1; len:8]12345678
121: f[call:2; len:0]
122:
123: ----( chunk_size: 7, output append size: 4 )----
124: f[call:1; len:8]12345678
125: f[call:2; len:0]
126:
127: ----( chunk_size: 8, output append size: 4 )----
128: f[call:1; len:8]12345678
129: f[call:2; len:0]
130:
131: ----( chunk_size: 9, output append size: 4 )----
132: f[call:1; len:8]12345678
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>