/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

  1. <?hh
  2. function mytolower($a) {
  3. return strtolower($a);
  4. }
  5. // don't print things here, since this tests what accumulates in the
  6. // output buffer.
  7. function VS($x, $y) {
  8. if ($x !== $y) {
  9. var_dump($x);
  10. var_dump($y);
  11. throw new Exception("test failed: got $x, expected $y");
  12. }
  13. }
  14. //////////////////////////////////////////////////////////////////////
  15. <<__EntryPoint>>
  16. function main_ext_output() {
  17. ob_start();
  18. ob_start(fun("mytolower"));
  19. echo "TEst";
  20. ob_end_flush();
  21. VS(ob_get_clean(), "test");
  22. ob_start();
  23. echo "test";
  24. ob_clean();
  25. VS(ob_get_clean(), "");
  26. ob_start();
  27. ob_start(fun("mytolower"));
  28. echo "TEst";
  29. ob_flush();
  30. VS(ob_get_clean(), "");
  31. VS(ob_get_clean(), "test");
  32. ob_start();
  33. ob_start(fun("mytolower"));
  34. echo "TEst";
  35. ob_end_clean();
  36. VS(ob_get_clean(), "");
  37. ob_start();
  38. ob_start(fun("mytolower"));
  39. echo "TEst";
  40. ob_end_flush();
  41. VS(ob_get_clean(), "test");
  42. ob_start();
  43. ob_start();
  44. echo "test";
  45. VS(ob_get_clean(), "test");
  46. VS(ob_get_clean(), "");
  47. VS(ob_get_clean(), false);
  48. ob_start();
  49. echo "test";
  50. VS(ob_get_contents(), "test");
  51. VS(ob_get_contents(), "test"); // verifying content stays
  52. ob_end_clean();
  53. ob_start();
  54. ob_start();
  55. echo "test";
  56. VS(ob_get_flush(), "test");
  57. VS(ob_get_flush(), "test");
  58. ob_end_clean();
  59. VS(ob_get_flush(), false);
  60. ob_end_clean();
  61. ob_start();
  62. echo "test";
  63. VS(ob_get_length(), 4);
  64. ob_end_clean();
  65. VS(ob_get_level(), 0);
  66. ob_start();
  67. VS(ob_get_level(), 1);
  68. ob_end_clean();
  69. VS(ob_get_level(), 0);
  70. ob_get_status();
  71. ob_start();
  72. ob_start(fun("mytolower"));
  73. $handlers = ob_list_handlers();
  74. ob_end_clean();
  75. ob_end_clean();
  76. VS($handlers, varray["default output handler", "mytolower"]);
  77. VS(is_varray($handlers), true);
  78. echo "\nok\n";
  79. }