]> granicus.if.org Git - php/commitdiff
Backport ob test to php 5.2 and 53.
authorandy wharmby <wharmby@php.net>
Thu, 18 Jun 2009 21:03:00 +0000 (21:03 +0000)
committerandy wharmby <wharmby@php.net>
Thu, 18 Jun 2009 21:03:00 +0000 (21:03 +0000)
tests/output/ob_011.phpt [new file with mode: 0644]
tests/output/ob_012.phpt [new file with mode: 0644]
tests/output/ob_013.phpt [new file with mode: 0644]
tests/output/ob_014.phpt [new file with mode: 0644]
tests/output/ob_015.phpt [new file with mode: 0644]
tests/output/ob_017.phpt [new file with mode: 0644]
tests/output/ob_018.phpt [new file with mode: 0644]
tests/output/ob_020.phpt [new file with mode: 0644]

diff --git a/tests/output/ob_011.phpt b/tests/output/ob_011.phpt
new file mode 100644 (file)
index 0000000..996ed39
--- /dev/null
@@ -0,0 +1,16 @@
+--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
diff --git a/tests/output/ob_012.phpt b/tests/output/ob_012.phpt
new file mode 100644 (file)
index 0000000..9e6e885
--- /dev/null
@@ -0,0 +1,22 @@
+--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
diff --git a/tests/output/ob_013.phpt b/tests/output/ob_013.phpt
new file mode 100644 (file)
index 0000000..ce5b5e5
--- /dev/null
@@ -0,0 +1,103 @@
+--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
diff --git a/tests/output/ob_014.phpt b/tests/output/ob_014.phpt
new file mode 100644 (file)
index 0000000..0953427
--- /dev/null
@@ -0,0 +1,22 @@
+--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
+)
diff --git a/tests/output/ob_015.phpt b/tests/output/ob_015.phpt
new file mode 100644 (file)
index 0000000..2acdb40
--- /dev/null
@@ -0,0 +1,22 @@
+--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
+)
diff --git a/tests/output/ob_017.phpt b/tests/output/ob_017.phpt
new file mode 100644 (file)
index 0000000..fc50e2f
--- /dev/null
@@ -0,0 +1,34 @@
+--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
diff --git a/tests/output/ob_018.phpt b/tests/output/ob_018.phpt
new file mode 100644 (file)
index 0000000..1ff7d5a
--- /dev/null
@@ -0,0 +1,17 @@
+--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
diff --git a/tests/output/ob_020.phpt b/tests/output/ob_020.phpt
new file mode 100644 (file)
index 0000000..05f66cc
--- /dev/null
@@ -0,0 +1,38 @@
+--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
+(
+)