--- /dev/null
+--TEST--
+output buffering - fatalism
+--XFAIL--
+This test will fail until the fix in version 1.178 of ext/main/output.c
+is backported from php 6
+--FILE--
+<?php
+function obh($s)
+{
+ return ob_get_flush();
+}
+ob_start("obh");
+echo "foo\n";
+?>
+--EXPECTF--
+Fatal error: ob_get_flush(): Cannot use output buffering in output buffering display handlers in %sob_011.php on line %d
--- /dev/null
+--TEST--
+output buffering - multiple
+--FILE--
+<?php
+echo 0;
+ ob_start();
+ ob_start();
+ ob_start();
+ ob_start();
+ echo 1;
+ ob_end_flush();
+ echo 2;
+ $ob = ob_get_clean();
+ echo 3;
+ ob_flush();
+ ob_end_clean();
+ echo 4;
+ ob_end_flush();
+echo $ob;
+?>
+--EXPECT--
+03412
--- /dev/null
+--TEST--
+output buffering - handlers/status
+--FILE--
+<?php
+function a($s){return $s;}
+function b($s){return $s;}
+function c($s){return $s;}
+function d($s){return $s;}
+
+ob_start();
+ob_start('a');
+ob_start('b');
+ob_start('c');
+ob_start('d');
+ob_start();
+
+echo "foo\n";
+
+ob_flush();
+ob_end_clean();
+ob_flush();
+
+print_r(ob_list_handlers());
+print_r(ob_get_status());
+print_r(ob_get_status(true));
+
+?>
+--EXPECTF--
+foo
+Array
+(
+ [0] => default output handler
+ [1] => a
+ [2] => b
+ [3] => c
+ [4] => d
+)
+Array
+(
+ [level] => 5
+ [type] => 1
+ [status] => 1
+ [name] => d
+ [del] => 1
+)
+Array
+(
+ [0] => Array
+ (
+ [chunk_size] => 0
+ [size] => 40960
+ [block_size] => 10240
+ [type] => 1
+ [status] => 0
+ [name] => default output handler
+ [del] => 1
+ )
+
+ [1] => Array
+ (
+ [chunk_size] => 0
+ [size] => 40960
+ [block_size] => 10240
+ [type] => 1
+ [status] => 0
+ [name] => a
+ [del] => 1
+ )
+
+ [2] => Array
+ (
+ [chunk_size] => 0
+ [size] => 40960
+ [block_size] => 10240
+ [type] => 1
+ [status] => 0
+ [name] => b
+ [del] => 1
+ )
+
+ [3] => Array
+ (
+ [chunk_size] => 0
+ [size] => 40960
+ [block_size] => 10240
+ [type] => 1
+ [status] => 0
+ [name] => c
+ [del] => 1
+ )
+
+ [4] => Array
+ (
+ [chunk_size] => 0
+ [size] => 40960
+ [block_size] => 10240
+ [type] => 1
+ [status] => 1
+ [name] => d
+ [del] => 1
+ )
+
+)
\ No newline at end of file
--- /dev/null
+--TEST--
+output buffering - failure
+--FILE--
+<?php
+ob_start("str_rot13");
+echo "foo\n";
+// str_rot13 expects 1 param and returns NULL when passed 2 params.
+// It is invoked with 2 params when used as an OB callback.
+// Therefore, there will be no data in the buffer. This is expected: see bug 46900.
+ob_end_flush();
+
+// Show the error.
+print_r(error_get_last());
+?>
+--EXPECTF--
+Array
+(
+ [type] => 2
+ [message] => str_rot13() expects exactly 1 parameter, 2 given
+ [file] => %s
+ [line] => 7
+)
--- /dev/null
+--TEST--
+output buffering - failure
+--FILE--
+<?php
+ob_start("str_rot13", 1);
+echo "foo\n";
+// str_rot13 expects 1 param and returns NULL when passed 2 params.
+// It is invoked with 2 params when used as an OB callback.
+// Therefore, there will be no data in the buffer. This is expected: see bug 46900.
+ob_end_flush();
+
+// Show the error.
+print_r(error_get_last());
+?>
+--EXPECTF--
+Array
+(
+ [type] => 2
+ [message] => str_rot13() expects exactly 1 parameter, 2 given
+ [file] => %s
+ [line] => 7
+)
--- /dev/null
+--TEST--
+output buffering - stati
+--FILE--
+<?php
+$stati = array();
+function oh($str, $flags) {
+ global $stati;
+ $stati[] = "$flags: $str";
+ return $str;
+}
+ob_start("oh", 3);
+echo "yes";
+echo "!\n";
+ob_flush();
+echo "no";
+ob_clean();
+echo "yes!\n";
+echo "no";
+ob_end_clean();
+print_r($stati);
+?>
+--EXPECT--
+yes!
+yes!
+Array
+(
+ [0] => 3: yes
+ [1] => 2: !
+
+ [2] => 2: no
+ [3] => 2: yes!
+
+ [4] => 4: no
+)
\ No newline at end of file
--- /dev/null
+--TEST--
+output buffering - error message nirvana bug #37714
+--SKIPIF--
+<?php
+if (!extension_loaded("zlib")) die("skip need ext/zlib");
+?>
+--ENV--
+HTTP_ACCEPT_ENCODING=gzip,deflate
+--INI--
+display_errors=1
+zlib.output_compression=1
+--FILE--
+<?php
+ob_start('ob_gzhandler');
+?>
+--EXPECTF--
+\1f\8b\b%a
--- /dev/null
+--TEST--
+output buffering - ob_list_handlers
+--FILE--
+<?php
+print_r(ob_list_handlers());
+
+ob_start();
+print_r(ob_list_handlers());
+
+ob_start();
+print_r(ob_list_handlers());
+
+ob_end_flush();
+print_r(ob_list_handlers());
+
+ob_end_flush();
+print_r(ob_list_handlers());
+?>
+--EXPECT--
+Array
+(
+)
+Array
+(
+ [0] => default output handler
+)
+Array
+(
+ [0] => default output handler
+ [1] => default output handler
+)
+Array
+(
+ [0] => default output handler
+)
+Array
+(
+)