TestExtOutput -> php
Esse commit está contido em:
@@ -39,7 +39,6 @@
|
||||
#include "hphp/test/ext/test_ext_memcached.h"
|
||||
#include "hphp/test/ext/test_ext_mysql.h"
|
||||
#include "hphp/test/ext/test_ext_openssl.h"
|
||||
#include "hphp/test/ext/test_ext_output.h"
|
||||
#include "hphp/test/ext/test_ext_pdo.h"
|
||||
#include "hphp/test/ext/test_ext_posix.h"
|
||||
#include "hphp/test/ext/test_ext_process.h"
|
||||
|
||||
@@ -1,227 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| HipHop for PHP |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include "hphp/test/ext/test_ext_output.h"
|
||||
#include "hphp/runtime/ext/ext_output.h"
|
||||
|
||||
IMPLEMENT_SEP_EXTENSION_TEST(Output);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TestExtOutput::RunTests(const std::string &which) {
|
||||
bool ret = true;
|
||||
|
||||
DECLARE_TEST_FUNCTIONS("function mytolower($a) {"
|
||||
" return strtolower($a);"
|
||||
"}");
|
||||
|
||||
RUN_TEST(test_ob_start);
|
||||
RUN_TEST(test_ob_clean);
|
||||
RUN_TEST(test_ob_flush);
|
||||
RUN_TEST(test_ob_end_clean);
|
||||
RUN_TEST(test_ob_end_flush);
|
||||
RUN_TEST(test_flush);
|
||||
RUN_TEST(test_ob_get_clean);
|
||||
RUN_TEST(test_ob_get_contents);
|
||||
RUN_TEST(test_ob_get_flush);
|
||||
RUN_TEST(test_ob_get_length);
|
||||
RUN_TEST(test_ob_get_level);
|
||||
RUN_TEST(test_ob_get_status);
|
||||
RUN_TEST(test_ob_gzhandler);
|
||||
RUN_TEST(test_ob_implicit_flush);
|
||||
RUN_TEST(test_ob_list_handlers);
|
||||
RUN_TEST(test_output_add_rewrite_var);
|
||||
RUN_TEST(test_output_reset_rewrite_vars);
|
||||
RUN_TEST(test_hphp_crash_log);
|
||||
RUN_TEST(test_hphp_stats);
|
||||
RUN_TEST(test_hphp_get_stats);
|
||||
RUN_TEST(test_hphp_get_timers);
|
||||
RUN_TEST(test_hphp_output_global_state);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TestExtOutput::test_ob_start() {
|
||||
f_ob_start();
|
||||
f_ob_start("mytolower");
|
||||
g_context->write("TEst");
|
||||
f_ob_end_flush();
|
||||
VS(f_ob_get_clean(), "test");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_ob_clean() {
|
||||
f_ob_start();
|
||||
g_context->write("test");
|
||||
f_ob_clean();
|
||||
VS(f_ob_get_clean(), "");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_ob_flush() {
|
||||
f_ob_start();
|
||||
f_ob_start("mytolower");
|
||||
g_context->write("TEst");
|
||||
f_ob_flush();
|
||||
VS(f_ob_get_clean(), "");
|
||||
VS(f_ob_get_clean(), "test");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_ob_end_clean() {
|
||||
f_ob_start();
|
||||
f_ob_start("mytolower");
|
||||
g_context->write("TEst");
|
||||
f_ob_end_clean();
|
||||
VS(f_ob_get_clean(), "");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_ob_end_flush() {
|
||||
f_ob_start();
|
||||
f_ob_start("mytolower");
|
||||
g_context->write("TEst");
|
||||
f_ob_end_flush();
|
||||
VS(f_ob_get_clean(), "test");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_flush() {
|
||||
f_ob_start();
|
||||
f_ob_start("mytolower");
|
||||
g_context->write(""); // we can't really verify what's written to stdout
|
||||
f_flush();
|
||||
f_ob_end_clean();
|
||||
f_ob_end_clean();
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_ob_get_clean() {
|
||||
f_ob_start();
|
||||
f_ob_start();
|
||||
g_context->write("test");
|
||||
VS(f_ob_get_clean(), "test");
|
||||
VS(f_ob_get_clean(), "");
|
||||
VS(f_ob_get_clean(), "");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_ob_get_contents() {
|
||||
f_ob_start();
|
||||
g_context->write("test");
|
||||
VS(f_ob_get_contents(), "test");
|
||||
VS(f_ob_get_contents(), "test"); // verifying content stays
|
||||
f_ob_end_clean();
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_ob_get_flush() {
|
||||
f_ob_start();
|
||||
f_ob_start();
|
||||
g_context->write("test");
|
||||
VS(f_ob_get_flush(), "test");
|
||||
VS(f_ob_get_flush(), "");
|
||||
f_ob_end_clean();
|
||||
VS(f_ob_get_flush(), "test");
|
||||
f_ob_end_clean();
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_ob_get_length() {
|
||||
f_ob_start();
|
||||
g_context->write("test");
|
||||
VS(f_ob_get_length(), 4);
|
||||
f_ob_end_clean();
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_ob_get_level() {
|
||||
VS(f_ob_get_level(), 0);
|
||||
f_ob_start();
|
||||
VS(f_ob_get_level(), 1);
|
||||
f_ob_end_clean();
|
||||
VS(f_ob_get_level(), 0);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_ob_get_status() {
|
||||
f_ob_get_status();
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_ob_gzhandler() {
|
||||
try {
|
||||
f_ob_gzhandler("value", 0);
|
||||
} catch (const NotSupportedException& e) {
|
||||
return Count(true);
|
||||
}
|
||||
return Count(false);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_ob_implicit_flush() {
|
||||
f_ob_implicit_flush(true); // no-op currently
|
||||
f_ob_implicit_flush(false); // no-op currently
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_ob_list_handlers() {
|
||||
f_ob_start();
|
||||
f_ob_start("test");
|
||||
Array handlers = f_ob_list_handlers();
|
||||
f_ob_end_clean();
|
||||
f_ob_end_clean();
|
||||
VS(handlers, CREATE_VECTOR2(uninit_null(), "test"));
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_output_add_rewrite_var() {
|
||||
try {
|
||||
f_output_add_rewrite_var("name", "value");
|
||||
} catch (const NotSupportedException& e) {
|
||||
return Count(true);
|
||||
}
|
||||
return Count(false);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_output_reset_rewrite_vars() {
|
||||
try {
|
||||
f_output_reset_rewrite_vars();
|
||||
} catch (const NotSupportedException& e) {
|
||||
return Count(true);
|
||||
}
|
||||
return Count(false);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_hphp_crash_log() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_hphp_stats() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_hphp_get_stats() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_hphp_get_timers() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtOutput::test_hphp_output_global_state() {
|
||||
return Count(true);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| HipHop for PHP |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef incl_HPHP_TEST_EXT_OUTPUT_H_
|
||||
#define incl_HPHP_TEST_EXT_OUTPUT_H_
|
||||
|
||||
// >>>>>> Generated by idl.php. Do NOT modify. <<<<<<
|
||||
|
||||
#include "hphp/test/ext/test_cpp_ext.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class TestExtOutput : public TestCppExt {
|
||||
public:
|
||||
virtual bool RunTests(const std::string &which);
|
||||
|
||||
bool test_ob_start();
|
||||
bool test_ob_clean();
|
||||
bool test_ob_flush();
|
||||
bool test_ob_end_clean();
|
||||
bool test_ob_end_flush();
|
||||
bool test_flush();
|
||||
bool test_ob_get_clean();
|
||||
bool test_ob_get_contents();
|
||||
bool test_ob_get_flush();
|
||||
bool test_ob_get_length();
|
||||
bool test_ob_get_level();
|
||||
bool test_ob_get_status();
|
||||
bool test_ob_gzhandler();
|
||||
bool test_ob_implicit_flush();
|
||||
bool test_ob_list_handlers();
|
||||
bool test_output_add_rewrite_var();
|
||||
bool test_output_reset_rewrite_vars();
|
||||
bool test_hphp_crash_log();
|
||||
bool test_hphp_stats();
|
||||
bool test_hphp_get_stats();
|
||||
bool test_hphp_get_timers();
|
||||
bool test_hphp_output_global_state();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // incl_HPHP_TEST_EXT_OUTPUT_H_
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
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) {
|
||||
throw new Exception("test failed: got $x, expected $y");
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
ob_start();
|
||||
ob_start("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("mytolower");
|
||||
echo "TEst";
|
||||
ob_flush();
|
||||
VS(ob_get_clean(), "");
|
||||
VS(ob_get_clean(), "test");
|
||||
|
||||
ob_start();
|
||||
ob_start("mytolower");
|
||||
echo "TEst";
|
||||
ob_end_clean();
|
||||
VS(ob_get_clean(), "");
|
||||
|
||||
ob_start();
|
||||
ob_start("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(), "");
|
||||
|
||||
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(), "");
|
||||
ob_end_clean();
|
||||
VS(ob_get_flush(), "test");
|
||||
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("test");
|
||||
$handlers = ob_list_handlers();
|
||||
ob_end_clean();
|
||||
ob_end_clean();
|
||||
VS($handlers, array(null, "test"));
|
||||
|
||||
echo "\nok\n";
|
||||
@@ -0,0 +1,2 @@
|
||||
test
|
||||
ok
|
||||
Referência em uma Nova Issue
Bloquear um usuário