Browse Source

Backport ob test to php 5.2 and 53.

PHP-5.2.1RC1
andy wharmby 17 years ago
parent
commit
edd936517a
  1. 17
      tests/output/ob_011.phpt
  2. 22
      tests/output/ob_012.phpt
  3. 103
      tests/output/ob_013.phpt
  4. 22
      tests/output/ob_014.phpt
  5. 22
      tests/output/ob_015.phpt
  6. 34
      tests/output/ob_017.phpt
  7. 17
      tests/output/ob_018.phpt
  8. 38
      tests/output/ob_020.phpt

17
tests/output/ob_011.phpt

@ -0,0 +1,17 @@
--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

22
tests/output/ob_012.phpt

@ -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

103
tests/output/ob_013.phpt

@ -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
)
)

22
tests/output/ob_014.phpt

@ -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] => Wrong parameter count for str_rot13()
[file] => %s
[line] => 7
)

22
tests/output/ob_015.phpt

@ -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] => Wrong parameter count for str_rot13()
[file] => %s
[line] => 7
)

34
tests/output/ob_017.phpt

@ -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
)

17
tests/output/ob_018.phpt

@ -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--
‹%a

38
tests/output/ob_020.phpt

@ -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
(
)
Loading…
Cancel
Save