/hphp/test/slow/ext_output/ext_output.php
http://github.com/facebook/hiphop-php · PHP · 96 lines · 76 code · 17 blank · 3 comment · 1 complexity · 41fdcbdd6c34928fe30aba87f980f5ba MD5 · raw file
- <?hh
- function mytolower($a) {
- return strtolower($a);
- }
- // don't print things here, since this tests what accumulates in the
- // output buffer.
- function VS($x, $y) {
- if ($x !== $y) {
- var_dump($x);
- var_dump($y);
- throw new Exception("test failed: got $x, expected $y");
- }
- }
- //////////////////////////////////////////////////////////////////////
- <<__EntryPoint>>
- function main_ext_output() {
- ob_start();
- ob_start(fun("mytolower"));
- echo "TEst";
- ob_end_flush();
- VS(ob_get_clean(), "test");
- ob_start();
- echo "test";
- ob_clean();
- VS(ob_get_clean(), "");
- ob_start();
- ob_start(fun("mytolower"));
- echo "TEst";
- ob_flush();
- VS(ob_get_clean(), "");
- VS(ob_get_clean(), "test");
- ob_start();
- ob_start(fun("mytolower"));
- echo "TEst";
- ob_end_clean();
- VS(ob_get_clean(), "");
- ob_start();
- ob_start(fun("mytolower"));
- echo "TEst";
- ob_end_flush();
- VS(ob_get_clean(), "test");
- ob_start();
- ob_start();
- echo "test";
- VS(ob_get_clean(), "test");
- VS(ob_get_clean(), "");
- VS(ob_get_clean(), false);
- ob_start();
- echo "test";
- VS(ob_get_contents(), "test");
- VS(ob_get_contents(), "test"); // verifying content stays
- ob_end_clean();
- ob_start();
- ob_start();
- echo "test";
- VS(ob_get_flush(), "test");
- VS(ob_get_flush(), "test");
- ob_end_clean();
- VS(ob_get_flush(), false);
- ob_end_clean();
- ob_start();
- echo "test";
- VS(ob_get_length(), 4);
- ob_end_clean();
- VS(ob_get_level(), 0);
- ob_start();
- VS(ob_get_level(), 1);
- ob_end_clean();
- VS(ob_get_level(), 0);
- ob_get_status();
- ob_start();
- ob_start(fun("mytolower"));
- $handlers = ob_list_handlers();
- ob_end_clean();
- ob_end_clean();
- VS($handlers, varray["default output handler", "mytolower"]);
- VS(is_varray($handlers), true);
- echo "\nok\n";
- }