Remove Variant::operator[](litstr)
And its remaining call sites.
Esse commit está contido em:
@@ -841,11 +841,11 @@ class Variant : private TypedValue {
|
||||
const Variant operator[](int key) const { return rvalAt(key);}
|
||||
const Variant operator[](int64_t key) const { return rvalAt(key);}
|
||||
const Variant operator[](double key) const { return rvalAt(key);}
|
||||
const Variant operator[](litstr key) const { return rvalAt(key);}
|
||||
const Variant operator[](CStrRef key) const { return rvalAt(key);}
|
||||
const Variant operator[](CArrRef key) const { return rvalAt(key);}
|
||||
const Variant operator[](CObjRef key) const { return rvalAt(key);}
|
||||
const Variant operator[](CVarRef key) const { return rvalAt(key);}
|
||||
const Variant operator[](const char*) const = delete;
|
||||
|
||||
template<typename T>
|
||||
Variant &lval(const T &key) {
|
||||
|
||||
@@ -1010,10 +1010,11 @@ Variant f_fb_compact_unserialize(CVarRef thing, VRefParam success,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const StaticString s_affected("affected");
|
||||
static const StaticString s_result("result");
|
||||
static const StaticString s_error("error");
|
||||
static const StaticString s_errno("errno");
|
||||
static const StaticString
|
||||
s_affected("affected"),
|
||||
s_result("result"),
|
||||
s_error("error"),
|
||||
s_errno("errno");
|
||||
|
||||
static void output_dataset(Array &ret, int affected, DBDataSet &ds,
|
||||
const DBConn::ErrorInfoMap &errors) {
|
||||
@@ -1045,13 +1046,17 @@ static void output_dataset(Array &ret, int affected, DBDataSet &ds,
|
||||
}
|
||||
}
|
||||
|
||||
static const StaticString s_session_variable("session_variable");
|
||||
static const StaticString s_ip("ip");
|
||||
static const StaticString s_db("db");
|
||||
static const StaticString s_port("port");
|
||||
static const StaticString s_username("username");
|
||||
static const StaticString s_password("password");
|
||||
static const StaticString s_sql("sql");
|
||||
static const StaticString
|
||||
s_session_variable("session_variable"),
|
||||
s_ip("ip"),
|
||||
s_db("db"),
|
||||
s_port("port"),
|
||||
s_username("username"),
|
||||
s_password("password"),
|
||||
s_sql("sql"),
|
||||
s_host("host"),
|
||||
s_auth("auth"),
|
||||
s_timeout("timeout");
|
||||
|
||||
void f_fb_load_local_databases(CArrRef servers) {
|
||||
DBConn::ClearLocalDatabases();
|
||||
@@ -1419,10 +1424,10 @@ Variant f_fb_stubout_intercept_handler(CStrRef name, CVarRef obj,
|
||||
|
||||
Variant f_fb_rpc_intercept_handler(CStrRef name, CVarRef obj, CArrRef params,
|
||||
CVarRef data, VRefParam done) {
|
||||
String host = data["host"].toString();
|
||||
int port = data["port"].toInt32();
|
||||
String auth = data["auth"].toString();
|
||||
int timeout = data["timeout"].toInt32();
|
||||
String host = data[s_host].toString();
|
||||
int port = data[s_port].toInt32();
|
||||
String auth = data[s_auth].toString();
|
||||
int timeout = data[s_timeout].toInt32();
|
||||
|
||||
if (obj.isNull()) {
|
||||
return f_call_user_func_array_rpc(host, port, auth, timeout, name, params);
|
||||
|
||||
@@ -155,11 +155,17 @@ Variant f_end_user_func_async(CObjRef handle,
|
||||
return uninit_null();
|
||||
}
|
||||
|
||||
static const StaticString
|
||||
s_func("func"),
|
||||
s_args("args"),
|
||||
s_exception("exception"),
|
||||
s_ret("ret");
|
||||
|
||||
String f_call_user_func_serialized(CStrRef input) {
|
||||
Variant out;
|
||||
try {
|
||||
Variant in = unserialize_from_string(input);
|
||||
out.set("ret", vm_call_user_func(in["func"], in["args"]));
|
||||
out.set("ret", vm_call_user_func(in[s_func], in[s_args]));
|
||||
} catch (Object &e) {
|
||||
out.set("exception", e);
|
||||
}
|
||||
@@ -172,11 +178,6 @@ Variant f_call_user_func_array_rpc(CStrRef host, int port, CStrRef auth,
|
||||
return f_call_user_func_rpc(0, host, port, auth, timeout, function, params);
|
||||
}
|
||||
|
||||
static const StaticString s_func("func");
|
||||
static const StaticString s_args("args");
|
||||
static const StaticString s_exception("exception");
|
||||
static const StaticString s_ret("ret");
|
||||
|
||||
Variant f_call_user_func_rpc(int _argc, CStrRef host, int port, CStrRef auth,
|
||||
int timeout, CVarRef function,
|
||||
CArrRef _argv /* = null_array */) {
|
||||
|
||||
@@ -1254,6 +1254,13 @@ static php_iconv_err_t _php_iconv_mime_decode(StringBuffer &retval,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const StaticString
|
||||
s_scheme("scheme"),
|
||||
s_input_charset("input-charset"),
|
||||
s_output_charset("output-charset"),
|
||||
s_line_length("line-length"),
|
||||
s_line_break_chars("line-break-chars");
|
||||
|
||||
Variant f_iconv_mime_encode(CStrRef field_name, CStrRef field_value,
|
||||
CVarRef preferences /* = null_variant */) {
|
||||
php_iconv_enc_scheme_t scheme_id = PHP_ICONV_ENC_SCHEME_BASE64;
|
||||
@@ -1265,7 +1272,7 @@ Variant f_iconv_mime_encode(CStrRef field_name, CStrRef field_value,
|
||||
char *buf = NULL;
|
||||
|
||||
if (!preferences.isNull()) {
|
||||
Variant scheme = preferences["scheme"];
|
||||
Variant scheme = preferences[s_scheme];
|
||||
if (scheme.isString()) {
|
||||
String s = scheme.toString();
|
||||
switch (*s.data()) {
|
||||
@@ -1278,24 +1285,24 @@ Variant f_iconv_mime_encode(CStrRef field_name, CStrRef field_value,
|
||||
}
|
||||
}
|
||||
|
||||
Variant input_charset = preferences["input-charset"];
|
||||
Variant input_charset = preferences[s_input_charset];
|
||||
if (input_charset.isString()) {
|
||||
in_charset = input_charset.toString();
|
||||
if (!validate_charset(in_charset)) return false;
|
||||
}
|
||||
|
||||
Variant output_charset = preferences["output-charset"];
|
||||
Variant output_charset = preferences[s_output_charset];
|
||||
if (output_charset.isString()) {
|
||||
out_charset = output_charset.toString();
|
||||
if (!validate_charset(out_charset)) return false;
|
||||
}
|
||||
|
||||
Variant line_length = preferences["line-length"];
|
||||
Variant line_length = preferences[s_line_length];
|
||||
if (!line_length.isNull()) {
|
||||
line_len = line_length.toInt64();
|
||||
}
|
||||
|
||||
Variant line_break_chars = preferences["line-break-chars"];
|
||||
Variant line_break_chars = preferences[s_line_break_chars];
|
||||
if (!line_break_chars.isNull()) {
|
||||
lfchars = line_break_chars.toString();
|
||||
}
|
||||
|
||||
@@ -277,9 +277,11 @@ static void bin_to_readable(CStrRef in, StringBuffer &out, char nbits) {
|
||||
}
|
||||
}
|
||||
|
||||
static const StaticString s_REMOTE_ADDR("REMOTE_ADDR");
|
||||
|
||||
String SessionModule::create_sid() {
|
||||
SystemGlobals *g = (SystemGlobals*)get_global_variables();
|
||||
String remote_addr = g->GV(_SERVER)["REMOTE_ADDR"].toString();
|
||||
String remote_addr = g->GV(_SERVER)[s_REMOTE_ADDR].toString();
|
||||
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
@@ -1187,9 +1189,11 @@ static inline void strcpy_gmt(char *ubuf, time_t *when) {
|
||||
ubuf[n] = '\0';
|
||||
}
|
||||
|
||||
static const StaticString s_PATH_TRANSLATED("PATH_TRANSLATED");
|
||||
|
||||
static inline void last_modified() {
|
||||
SystemGlobals *g = (SystemGlobals*)get_global_variables();
|
||||
String path = g->GV(_SERVER)["PATH_TRANSLATED"].toString();
|
||||
String path = g->GV(_SERVER)[s_PATH_TRANSLATED].toString();
|
||||
if (!path.empty()) {
|
||||
struct stat sb;
|
||||
if (stat(path.data(), &sb) == -1) {
|
||||
@@ -1451,6 +1455,10 @@ bool f_session_decode(CStrRef data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static const StaticString
|
||||
s_REQUEST_URI("REQUEST_URI"),
|
||||
s_HTTP_REFERER("HTTP_REFERER");
|
||||
|
||||
bool f_session_start() {
|
||||
PS(apply_trans_sid) = PS(use_trans_sid);
|
||||
|
||||
@@ -1521,7 +1529,7 @@ bool f_session_start() {
|
||||
'<session-name>=<session-id>' to allow URLs of the form
|
||||
http://yoursite/<session-name>=<session-id>/script.php */
|
||||
if (!PS(use_only_cookies) && PS(id).empty()) {
|
||||
value = g->GV(_SERVER)["REQUEST_URI"].toString();
|
||||
value = g->GV(_SERVER)[s_REQUEST_URI].toString();
|
||||
const char *p = strstr(value.data(), PS(session_name).c_str());
|
||||
if (p && p[lensess] == '=') {
|
||||
p += lensess + 1;
|
||||
@@ -1536,7 +1544,7 @@ bool f_session_start() {
|
||||
/* check whether the current request was referred to by
|
||||
an external site which invalidates the previously found id */
|
||||
if (!PS(id).empty() && PS(extern_referer_chk)[0] != '\0') {
|
||||
value = g->GV(_SERVER)["HTTP_REFERER"].toString();
|
||||
value = g->GV(_SERVER)[s_HTTP_REFERER].toString();
|
||||
if (strstr(value.data(), PS(extern_referer_chk).c_str()) == NULL) {
|
||||
PS(id).reset();
|
||||
PS(send_cookie) = 1;
|
||||
|
||||
@@ -1751,12 +1751,14 @@ static void model_to_string(sdlContentModelPtr model, StringBuffer &buf,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// soap fault functions
|
||||
|
||||
static const StaticString s_HTTP_USER_AGENT("HTTP_USER_AGENT");
|
||||
|
||||
static void send_soap_server_fault(sdlFunctionPtr function, Variant fault,
|
||||
soapHeader *hdr) {
|
||||
USE_SOAP_GLOBAL;
|
||||
bool use_http_error_status = true;
|
||||
SystemGlobals *g = (SystemGlobals*)get_global_variables();
|
||||
if (g->GV(_SERVER)["HTTP_USER_AGENT"].toString() == "Shockwave Flash") {
|
||||
if (g->GV(_SERVER)[s_HTTP_USER_AGENT].toString() == "Shockwave Flash") {
|
||||
use_http_error_status = false;
|
||||
}
|
||||
if (use_http_error_status) {
|
||||
|
||||
@@ -216,10 +216,10 @@ MimePart::MimeHeader::MimeHeader(php_rfc822_tokenized_t *toks)
|
||||
void MimePart::MimeHeader::clear() {
|
||||
m_empty = true;
|
||||
m_value.clear();
|
||||
m_attributes.reset();
|
||||
m_attributes = null_array;
|
||||
}
|
||||
|
||||
Variant MimePart::MimeHeader::get(const char *attrname) {
|
||||
Variant MimePart::MimeHeader::get(CStrRef attrname) {
|
||||
return m_attributes[attrname];
|
||||
}
|
||||
|
||||
@@ -496,27 +496,29 @@ MimePart *MimePart::getParent() {
|
||||
return m_parent.getTyped<MimePart>();
|
||||
}
|
||||
|
||||
static const StaticString s_headers("headers");
|
||||
static const StaticString s_starting_pos("starting-pos");
|
||||
static const StaticString s_starting_pos_body("starting-pos-body");
|
||||
static const StaticString s_ending_pos("ending-pos");
|
||||
static const StaticString s_ending_pos_body("ending-pos-body");
|
||||
static const StaticString s_line_count("line-count");
|
||||
static const StaticString s_body_line_count("body-line-count");
|
||||
static const StaticString s_charset("charset");
|
||||
static const StaticString s_transfer_encoding("transfer-encoding");
|
||||
static const StaticString s_content_type("content-type");
|
||||
static const StaticString s_content_("content-");
|
||||
static const StaticString s_text_plain_error("text/plain; (error)");
|
||||
static const StaticString s_content_disposition("content-disposition");
|
||||
static const StaticString s_disposition_("disposition-");
|
||||
static const StaticString s_content_location("content-location");
|
||||
static const StaticString s_content_base("content-base");
|
||||
static const StaticString s_content_boundary("content-boundary");
|
||||
static const StaticString s_content_id("content-id");
|
||||
static const StaticString s_content_description("content-description");
|
||||
static const StaticString s_content_language("content-language");
|
||||
static const StaticString s_content_md5("content-md5");
|
||||
static const StaticString
|
||||
s_headers("headers"),
|
||||
s_starting_pos("starting-pos"),
|
||||
s_starting_pos_body("starting-pos-body"),
|
||||
s_ending_pos("ending-pos"),
|
||||
s_ending_pos_body("ending-pos-body"),
|
||||
s_line_count("line-count"),
|
||||
s_body_line_count("body-line-count"),
|
||||
s_charset("charset"),
|
||||
s_transfer_encoding("transfer-encoding"),
|
||||
s_content_type("content-type"),
|
||||
s_content_("content-"),
|
||||
s_text_plain_error("text/plain, (error)"),
|
||||
s_content_disposition("content-disposition"),
|
||||
s_disposition_("disposition-"),
|
||||
s_content_location("content-location"),
|
||||
s_content_base("content-base"),
|
||||
s_content_boundary("content-boundary"),
|
||||
s_content_id("content-id"),
|
||||
s_content_description("content-description"),
|
||||
s_content_language("content-language"),
|
||||
s_content_md5("content-md5"),
|
||||
s_boundary("boundary");
|
||||
|
||||
Variant MimePart::getPartData() {
|
||||
Array ret = Array::Create();
|
||||
@@ -710,11 +712,11 @@ bool MimePart::processHeader() {
|
||||
m_content_transfer_encoding = header_val_stripped;
|
||||
} else if (header_key == "content-type") {
|
||||
m_content_type = MimeHeader(toks);
|
||||
Variant boundary = m_content_type.get("boundary");
|
||||
Variant boundary = m_content_type.get(s_boundary);
|
||||
if (!boundary.isNull()) {
|
||||
m_boundary = boundary.toString();
|
||||
}
|
||||
Variant charset = m_content_type.get("charset");
|
||||
Variant charset = m_content_type.get(s_charset);
|
||||
if (!charset.isNull()) {
|
||||
m_charset = charset.toString();
|
||||
}
|
||||
|
||||
@@ -64,18 +64,18 @@ private:
|
||||
class MimeHeader {
|
||||
public:
|
||||
MimeHeader();
|
||||
MimeHeader(const char *value);
|
||||
explicit MimeHeader(const char *value);
|
||||
MimeHeader(php_rfc822_tokenized_t *toks);
|
||||
|
||||
bool empty() const { return m_empty;}
|
||||
void clear();
|
||||
|
||||
Variant get(const char *attrname);
|
||||
Variant get(CStrRef attrname);
|
||||
void getAll(Array &ret, CStrRef valuelabel, CStrRef attrprefix);
|
||||
|
||||
bool m_empty;
|
||||
String m_value;
|
||||
Variant m_attributes;
|
||||
Array m_attributes;
|
||||
|
||||
private:
|
||||
void rfc2231_to_mime(StringBuffer &value_buf, char* value,
|
||||
|
||||
@@ -673,7 +673,7 @@ bool TestCppBase::TestVariant() {
|
||||
VS(v[1], "test");
|
||||
VS(v[1.5], "test");
|
||||
VS(v[Variant(1.5)], "test");
|
||||
VS(v["1"], "test");
|
||||
VS(v[s_1], "test");
|
||||
VS(v[Variant("1")], "test");
|
||||
}
|
||||
{
|
||||
@@ -682,7 +682,7 @@ bool TestCppBase::TestVariant() {
|
||||
VS(v[1], "test");
|
||||
VS(v[1.5], "test");
|
||||
VS(v[Variant(1.5)], "test");
|
||||
VS(v["1"], "test");
|
||||
VS(v[s_1], "test");
|
||||
VS(v[Variant("1")], "test");
|
||||
}
|
||||
{
|
||||
@@ -691,7 +691,7 @@ bool TestCppBase::TestVariant() {
|
||||
VS(v[1], "test");
|
||||
VS(v[1.5], "test");
|
||||
VS(v[Variant(1.5)], "test");
|
||||
VS(v["1"], "test");
|
||||
VS(v[s_1], "test");
|
||||
VS(v[Variant("1")], "test");
|
||||
}
|
||||
{
|
||||
@@ -700,7 +700,7 @@ bool TestCppBase::TestVariant() {
|
||||
VS(v[1], "test");
|
||||
VS(v[1.5], "test");
|
||||
VS(v[Variant(1.5)], "test");
|
||||
VS(v["1"], "test");
|
||||
VS(v[s_1], "test");
|
||||
VS(v[Variant("1")], "test");
|
||||
}
|
||||
|
||||
|
||||
@@ -132,9 +132,17 @@ bool TestExtCurl::test_curl_copy_handle() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
static const StaticString
|
||||
s_protocols("protocols"),
|
||||
s_url("url"),
|
||||
s_result("result"),
|
||||
s_code("code"),
|
||||
s_response("response"),
|
||||
s_headers("headers");
|
||||
|
||||
bool TestExtCurl::test_curl_version() {
|
||||
Variant ret = f_curl_version();
|
||||
VERIFY(!ret["protocols"].toArray().empty());
|
||||
VERIFY(!ret[s_protocols].toArray().empty());
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
@@ -182,7 +190,7 @@ bool TestExtCurl::test_curl_getinfo() {
|
||||
f_curl_setopt(c, k_CURLOPT_RETURNTRANSFER, true);
|
||||
f_curl_exec(c);
|
||||
Variant ret = f_curl_getinfo(c);
|
||||
VS(ret["url"], String(get_request_uri()));
|
||||
VS(ret[s_url], String(get_request_uri()));
|
||||
ret = f_curl_getinfo(c, k_CURLINFO_EFFECTIVE_URL);
|
||||
VS(ret, String(get_request_uri()));
|
||||
return Count(true);
|
||||
@@ -303,7 +311,7 @@ bool TestExtCurl::test_curl_multi_info_read() {
|
||||
} while (more(still_running, 0));
|
||||
|
||||
Variant ret = f_curl_multi_info_read(mh);
|
||||
VS(ret["result"], 0);
|
||||
VS(ret[s_result], 0);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
@@ -330,10 +338,10 @@ bool TestExtCurl::test_evhttp_set_cache() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Variant ret = f_evhttp_get(String(get_request_uri()),
|
||||
CREATE_VECTOR1("ECHO: foo"));
|
||||
VS(ret["code"], 200);
|
||||
VS(ret["response"], "OK");
|
||||
VS(ret["headers"][0], "ECHOED: foo");
|
||||
VS(ret["headers"][4], "Content-Length: 2");
|
||||
VS(ret[s_code], 200);
|
||||
VS(ret[s_response], "OK");
|
||||
VS(ret[s_headers][0], "ECHOED: foo");
|
||||
VS(ret[s_headers][4], "Content-Length: 2");
|
||||
}
|
||||
|
||||
return Count(true);
|
||||
@@ -342,20 +350,20 @@ bool TestExtCurl::test_evhttp_set_cache() {
|
||||
bool TestExtCurl::test_evhttp_get() {
|
||||
Variant ret = f_evhttp_get(String(get_request_uri()),
|
||||
CREATE_VECTOR1("ECHO: foo"));
|
||||
VS(ret["code"], 200);
|
||||
VS(ret["response"], "OK");
|
||||
VS(ret["headers"][0], "ECHOED: foo");
|
||||
VS(ret["headers"][4], "Content-Length: 2");
|
||||
VS(ret[s_code], 200);
|
||||
VS(ret[s_response], "OK");
|
||||
VS(ret[s_headers][0], "ECHOED: foo");
|
||||
VS(ret[s_headers][4], "Content-Length: 2");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtCurl::test_evhttp_post() {
|
||||
Variant ret = f_evhttp_post(String(get_request_uri()), "echo",
|
||||
CREATE_VECTOR1("ECHO: foo"));
|
||||
VS(ret["code"], 200);
|
||||
VS(ret["response"], "POST: echo");
|
||||
VS(ret["headers"][0], "ECHOED: foo");
|
||||
VS(ret["headers"][4], "Content-Length: 10");
|
||||
VS(ret[s_code], 200);
|
||||
VS(ret[s_response], "POST: echo");
|
||||
VS(ret[s_headers][0], "ECHOED: foo");
|
||||
VS(ret[s_headers][4], "Content-Length: 10");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
@@ -370,10 +378,10 @@ bool TestExtCurl::test_evhttp_post_gzip() {
|
||||
Variant ret = f_evhttp_post(String(get_request_uri()), postBody,
|
||||
CREATE_VECTOR2("ECHO: foo",
|
||||
"Accept-Encoding: gzip"));
|
||||
VS(ret["code"], 200);
|
||||
VS(ret["response"], fullPostBody);
|
||||
VS(ret["headers"][0], "ECHOED: foo");
|
||||
VS(ret["headers"][1], "Content-Encoding: gzip");
|
||||
VS(ret[s_code], 200);
|
||||
VS(ret[s_response], fullPostBody);
|
||||
VS(ret[s_headers][0], "ECHOED: foo");
|
||||
VS(ret[s_headers][1], "Content-Encoding: gzip");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
@@ -381,10 +389,10 @@ bool TestExtCurl::test_evhttp_async_get() {
|
||||
Variant ret = f_evhttp_async_get(String(get_request_uri()),
|
||||
CREATE_VECTOR1("ECHO: foo"));
|
||||
ret = f_evhttp_recv(ret);
|
||||
VS(ret["code"], 200);
|
||||
VS(ret["response"], "OK");
|
||||
VS(ret["headers"][0], "ECHOED: foo");
|
||||
VS(ret["headers"][4], "Content-Length: 2");
|
||||
VS(ret[s_code], 200);
|
||||
VS(ret[s_response], "OK");
|
||||
VS(ret[s_headers][0], "ECHOED: foo");
|
||||
VS(ret[s_headers][4], "Content-Length: 2");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
@@ -392,10 +400,10 @@ bool TestExtCurl::test_evhttp_async_post() {
|
||||
Variant ret = f_evhttp_async_post(String(get_request_uri()), "echo",
|
||||
CREATE_VECTOR1("ECHO: foo"));
|
||||
ret = f_evhttp_recv(ret);
|
||||
VS(ret["code"], 200);
|
||||
VS(ret["response"], "POST: echo");
|
||||
VS(ret["headers"][0], "ECHOED: foo");
|
||||
VS(ret["headers"][4], "Content-Length: 10");
|
||||
VS(ret[s_code], 200);
|
||||
VS(ret[s_response], "POST: echo");
|
||||
VS(ret[s_headers][0], "ECHOED: foo");
|
||||
VS(ret[s_headers][4], "Content-Length: 10");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -699,13 +699,19 @@ bool TestExtDatetime::test_timezone_open() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
static const StaticString
|
||||
s_ts("ts"),
|
||||
s_offset("offset"),
|
||||
s_isdst("isdst"),
|
||||
s_abbr("abbr");
|
||||
|
||||
bool TestExtDatetime::test_timezone_transitions_get() {
|
||||
Object timezone = f_timezone_open("CET");
|
||||
Array transitions = f_timezone_transitions_get(timezone);
|
||||
VS(transitions[0]["ts"], -1693706400);
|
||||
VS(transitions[0]["offset"], 7200);
|
||||
VS(transitions[0]["isdst"], true);
|
||||
VS(transitions[0]["abbr"], "CEST");
|
||||
VS(transitions[0][s_ts], -1693706400);
|
||||
VS(transitions[0][s_offset], 7200);
|
||||
VS(transitions[0][s_isdst], true);
|
||||
VS(transitions[0][s_abbr], "CEST");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -223,13 +223,15 @@ bool TestExtFile::test_fseek() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
static const StaticString s_size("size");
|
||||
|
||||
bool TestExtFile::test_fstat() {
|
||||
Variant f = f_fopen("test/test_ext_file.tmp", "w");
|
||||
f_fputs(f, "testing fstat");
|
||||
f_fclose(f);
|
||||
|
||||
f = f_fopen("test/test_ext_file.tmp", "r");
|
||||
VS(f_fstat(f)["size"], 13);
|
||||
VS(f_fstat(f)[s_size], 13);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
@@ -730,12 +732,12 @@ bool TestExtFile::test_clearstatcache() {
|
||||
}
|
||||
|
||||
bool TestExtFile::test_stat() {
|
||||
VS(f_stat("test/test_ext_file.txt")["size"], 17);
|
||||
VS(f_stat("test/test_ext_file.txt")[s_size], 17);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtFile::test_lstat() {
|
||||
VS(f_lstat("test/test_ext_file.txt")["size"], 17);
|
||||
VS(f_lstat("test/test_ext_file.txt")[s_size], 17);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,9 @@ bool TestExtMailparse::test_mailparse_msg_parse_file() {
|
||||
}
|
||||
|
||||
bool TestExtMailparse::test_mailparse_msg_parse() {
|
||||
static const StaticString
|
||||
s_headers("headers"),
|
||||
s_to("to");
|
||||
String text =
|
||||
"To: fred@bloggs.com\n"
|
||||
"To: wez@thebrainroom.com\n"
|
||||
@@ -128,7 +131,7 @@ bool TestExtMailparse::test_mailparse_msg_parse() {
|
||||
Variant mime = f_mailparse_msg_create();
|
||||
f_mailparse_msg_parse(mime, text);
|
||||
Variant data = f_mailparse_msg_get_part_data(mime);
|
||||
VS(data["headers"]["to"], "fred@bloggs.com, wez@thebrainroom.com");
|
||||
VS(data[s_headers][s_to], "fred@bloggs.com, wez@thebrainroom.com");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
@@ -274,6 +277,10 @@ bool TestExtMailparse::test_mailparse_msg_get_structure() {
|
||||
}
|
||||
|
||||
bool TestExtMailparse::test_mailparse_rfc822_parse_addresses() {
|
||||
static const StaticString
|
||||
s_display("display"),
|
||||
s_address("address"),
|
||||
s_is_group("is_group");
|
||||
Array addresses =
|
||||
CREATE_VECTOR2("\":sysmail\"@ Some-Group. Some-Org, Muhammed."
|
||||
"(I am the greatest) Ali @(the)Vegas.WBA",
|
||||
@@ -286,13 +293,13 @@ bool TestExtMailparse::test_mailparse_rfc822_parse_addresses() {
|
||||
Variant parsed = f_mailparse_rfc822_parse_addresses(iter.second());
|
||||
for (ArrayIter iter2(parsed); iter2; ++iter2) {
|
||||
Variant pair = iter2.second();
|
||||
echo(pair["display"]); echo("\n");
|
||||
echo(pair["address"]); echo("\n");
|
||||
if (pair["is_group"].toBoolean()) {
|
||||
echo(pair[s_display]); echo("\n");
|
||||
echo(pair[s_address]); echo("\n");
|
||||
if (pair[s_is_group].toBoolean()) {
|
||||
Variant sub = f_mailparse_rfc822_parse_addresses
|
||||
(f_substr(pair["address"], 1, f_strlen(pair["address"]) - 2));
|
||||
(f_substr(pair[s_address], 1, f_strlen(pair[s_address]) - 2));
|
||||
for (ArrayIter iter3(sub); iter3; ++iter3) {
|
||||
echo(" "); echo(iter3.second()["address"]); echo("\n");
|
||||
echo(" "); echo(iter3.second()[s_address]); echo("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -365,6 +372,7 @@ bool TestExtMailparse::test_mailparse_stream_encode() {
|
||||
}
|
||||
|
||||
bool TestExtMailparse::test_mailparse_uudecode_all() {
|
||||
static const StaticString s_filename("filename");
|
||||
String text =
|
||||
"To: fred@bloggs.com\n"
|
||||
"\n"
|
||||
@@ -383,12 +391,12 @@ bool TestExtMailparse::test_mailparse_uudecode_all() {
|
||||
|
||||
Variant data = f_mailparse_uudecode_all(fp);
|
||||
echo("BODY\n");
|
||||
f_readfile(data[0]["filename"]);
|
||||
f_readfile(data[0][s_filename]);
|
||||
echo("UUE\n");
|
||||
f_readfile(data[1]["filename"]);
|
||||
f_readfile(data[1][s_filename]);
|
||||
|
||||
f_unlink(data[0]["filename"]);
|
||||
f_unlink(data[1]["filename"]);
|
||||
f_unlink(data[0][s_filename]);
|
||||
f_unlink(data[1][s_filename]);
|
||||
|
||||
String output = f_ob_get_contents();
|
||||
f_ob_end_clean();
|
||||
|
||||
@@ -91,14 +91,18 @@ bool TestExtMb::test_mb_list_encodings() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
static const StaticString
|
||||
s_Quoted_Printable("Quoted-Printable"),
|
||||
s_UUENCODE("UUENCODE");
|
||||
|
||||
bool TestExtMb::test_mb_list_encodings_alias_names() {
|
||||
VS(f_mb_list_encodings_alias_names()["Quoted-Printable"],
|
||||
VS(f_mb_list_encodings_alias_names()[s_Quoted_Printable],
|
||||
CREATE_VECTOR1("qprint"));
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtMb::test_mb_list_mime_names() {
|
||||
VS(f_mb_list_mime_names()["UUENCODE"], "x-uuencode");
|
||||
VS(f_mb_list_mime_names()[s_UUENCODE], "x-uuencode");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
@@ -354,7 +358,8 @@ bool TestExtMb::test_mb_eregi() {
|
||||
}
|
||||
|
||||
bool TestExtMb::test_mb_get_info() {
|
||||
VERIFY(!f_mb_get_info()["detect_order"].toArray().empty());
|
||||
static const StaticString s_detect_order("detect_order");
|
||||
VERIFY(!f_mb_get_info()[s_detect_order].toArray().empty());
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
@@ -390,10 +395,13 @@ bool TestExtMb::test_mb_output_handler() {
|
||||
}
|
||||
|
||||
bool TestExtMb::test_mb_parse_str() {
|
||||
static const StaticString
|
||||
s_first("first"),
|
||||
s_arr("arr[]");
|
||||
Variant output;
|
||||
f_mb_parse_str("first=value&arr[]=foo+bar&arr[]=baz", ref(output));
|
||||
VS(output["first"], "value");
|
||||
VS(output["arr[]"], "baz"); // bug in mb_parse_str not following PHP's
|
||||
VS(output[s_first], "value");
|
||||
VS(output[s_arr], "baz"); // bug in mb_parse_str not following PHP's
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -376,10 +376,11 @@ bool TestExtMysql::test_mysql_db_query() {
|
||||
}
|
||||
|
||||
bool TestExtMysql::test_mysql_list_dbs() {
|
||||
static const StaticString s_Database("Database");
|
||||
Variant conn = f_mysql_connect(TEST_HOSTNAME, TEST_USERNAME, TEST_PASSWORD);
|
||||
Variant res = f_mysql_list_dbs();
|
||||
Variant db = f_mysql_fetch_assoc(res);
|
||||
if (db["Database"].toString().empty()) {
|
||||
if (db[s_Database].toString().empty()) {
|
||||
return CountSkip();
|
||||
}
|
||||
return Count(true);
|
||||
@@ -405,10 +406,11 @@ bool TestExtMysql::test_mysql_list_fields() {
|
||||
}
|
||||
|
||||
bool TestExtMysql::test_mysql_list_processes() {
|
||||
static const StaticString s_Id("Id");
|
||||
Variant conn = f_mysql_connect(TEST_HOSTNAME, TEST_USERNAME, TEST_PASSWORD);
|
||||
Variant res = f_mysql_list_processes();
|
||||
Variant process = f_mysql_fetch_assoc(res);
|
||||
VERIFY(!process["Id"].toString().empty());
|
||||
VERIFY(!process[s_Id].toString().empty());
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,10 +98,16 @@ bool TestExtOpenssl::test_openssl_csr_get_public_key() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
static const StaticString
|
||||
s_O("O"),
|
||||
s_cert("cert"),
|
||||
s_pkey("pkey"),
|
||||
s_subject("subject");
|
||||
|
||||
bool TestExtOpenssl::test_openssl_csr_get_subject() {
|
||||
Variant csr = f_openssl_csr_new(uninit_null(), uninit_null());
|
||||
VERIFY(!csr.isNull());
|
||||
VERIFY(f_openssl_csr_get_subject(csr)["O"] == "Internet Widgits Pty Ltd");
|
||||
VERIFY(f_openssl_csr_get_subject(csr)[s_O] == "Internet Widgits Pty Ltd");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
@@ -194,8 +200,8 @@ bool TestExtOpenssl::test_openssl_pkcs12_read() {
|
||||
|
||||
Variant certs;
|
||||
VERIFY(f_openssl_pkcs12_read(pkcs12, ref(certs), "1234"));
|
||||
VERIFY(certs["cert"].toString().size() > 500);
|
||||
VERIFY(certs["pkey"].toString().size() > 500);
|
||||
VERIFY(certs[s_cert].toString().size() > 500);
|
||||
VERIFY(certs[s_pkey].toString().size() > 500);
|
||||
|
||||
return Count(true);
|
||||
}
|
||||
@@ -486,7 +492,7 @@ bool TestExtOpenssl::test_openssl_x509_export_to_file() {
|
||||
Variant fcert2 = f_file_get_contents(tmp);
|
||||
Variant cert2 = f_openssl_x509_read(fcert2);
|
||||
Variant info = f_openssl_x509_parse(cert2);
|
||||
VS(info["subject"]["O"], "RSA Data Security, Inc.");
|
||||
VS(info[s_subject][s_O], "RSA Data Security, Inc.");
|
||||
|
||||
f_unlink(tmp);
|
||||
return Count(true);
|
||||
@@ -499,7 +505,7 @@ bool TestExtOpenssl::test_openssl_x509_export() {
|
||||
VERIFY(f_openssl_x509_export(cert, ref(out)));
|
||||
Variant cert2 = f_openssl_x509_read(out);
|
||||
Variant info = f_openssl_x509_parse(cert2);
|
||||
VS(info["subject"]["O"], "RSA Data Security, Inc.");
|
||||
VS(info[s_subject][s_O], "RSA Data Security, Inc.");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
@@ -515,7 +521,7 @@ bool TestExtOpenssl::test_openssl_x509_parse() {
|
||||
Variant fcert = f_file_get_contents("test/test_x509.crt");
|
||||
Variant cert = f_openssl_x509_read(fcert);
|
||||
Variant info = f_openssl_x509_parse(cert);
|
||||
VS(info["subject"]["O"], "RSA Data Security, Inc.");
|
||||
VS(info[s_subject][s_O], "RSA Data Security, Inc.");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ bool TestExtPdo::test_pdo_mysql() {
|
||||
}
|
||||
|
||||
bool TestExtPdo::test_pdo_sqlite() {
|
||||
static const StaticString s_id("id");
|
||||
CreateSqliteTestTable();
|
||||
|
||||
try {
|
||||
@@ -155,7 +156,7 @@ bool TestExtPdo::test_pdo_sqlite() {
|
||||
Variant res = dbh->t_query("SELECT id FROM foobar LIMIT 1");
|
||||
c_PDOStatement *stmt = res.toObject().getTyped<c_PDOStatement>();
|
||||
Variant ret = stmt->t_fetch();
|
||||
VS(ret["id"], "1");
|
||||
VS(ret[s_id], "1");
|
||||
|
||||
} catch (Object &e) {
|
||||
VS(e, uninit_null());
|
||||
|
||||
@@ -101,22 +101,24 @@ bool TestExtPosix::test_posix_getgid() {
|
||||
}
|
||||
|
||||
bool TestExtPosix::test_posix_getgrgid() {
|
||||
static const StaticString s_name("name");
|
||||
Variant ret = f_posix_getgrgid(f_posix_getgid());
|
||||
VERIFY(!same(ret, false));
|
||||
VERIFY(!ret.toArray().empty());
|
||||
|
||||
Variant bynam = f_posix_getgrnam(ret["name"]);
|
||||
Variant bynam = f_posix_getgrnam(ret[s_name]);
|
||||
VS(ret, bynam);
|
||||
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtPosix::test_posix_getgrnam() {
|
||||
static const StaticString s_gid("gid");
|
||||
Variant ret = f_posix_getgrnam("root");
|
||||
VERIFY(!same(ret, false));
|
||||
VERIFY(!ret.toArray().empty());
|
||||
|
||||
Variant bygid = f_posix_getgrgid(ret["gid"]);
|
||||
Variant bygid = f_posix_getgrgid(ret[s_gid]);
|
||||
VS(ret, bygid);
|
||||
|
||||
return Count(true);
|
||||
|
||||
@@ -129,10 +129,13 @@ bool TestExtServer::test_pagelet_server_task_result() {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TestExtServer::test_xbox_send_message() {
|
||||
static const StaticString
|
||||
s_code("code"),
|
||||
s_response("response");
|
||||
Variant ret;
|
||||
VERIFY(f_xbox_send_message("hello", ref(ret), 5000));
|
||||
VS(ret["code"], 200);
|
||||
VS(ret["response"], "olleh");
|
||||
VS(ret[s_code], 200);
|
||||
VS(ret[s_response], "olleh");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -268,6 +268,9 @@ bool TestExtStream::test_stream_get_line() {
|
||||
}
|
||||
|
||||
bool TestExtStream::test_stream_get_meta_data() {
|
||||
static const StaticString
|
||||
s_timed_out("timed_out"),
|
||||
s_blocked("blocked");
|
||||
int port = get_random_port();
|
||||
string address = string("127.0.0.1:") + boost::lexical_cast<string>(port);
|
||||
|
||||
@@ -277,8 +280,8 @@ bool TestExtStream::test_stream_get_meta_data() {
|
||||
f_stream_set_timeout(client, 0, 500 * 1000); // 500ms
|
||||
Variant line = f_fgets(client);
|
||||
Variant meta = f_stream_get_meta_data(client);
|
||||
VS(meta["timed_out"], true);
|
||||
VS(meta["blocked"], false);
|
||||
VS(meta[s_timed_out], true);
|
||||
VS(meta[s_blocked], false);
|
||||
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
@@ -942,18 +942,23 @@ bool TestExtString::test_metaphone() {
|
||||
}
|
||||
|
||||
bool TestExtString::test_parse_str() {
|
||||
static const StaticString
|
||||
s_first("first"),
|
||||
s_arr("arr"),
|
||||
s_a("a"),
|
||||
s_i("i");
|
||||
{
|
||||
Variant output;
|
||||
f_parse_str("first=value&arr[]=foo+bar&arr[]=baz", ref(output));
|
||||
VS(output["first"], "value");
|
||||
VS(output["arr"][0], "foo bar");
|
||||
VS(output["arr"][1], "baz");
|
||||
VS(output[s_first], "value");
|
||||
VS(output[s_arr][0], "foo bar");
|
||||
VS(output[s_arr][1], "baz");
|
||||
}
|
||||
{
|
||||
Variant output;
|
||||
f_parse_str("a[2][i]=3&a[4][i]=5", ref(output));
|
||||
VS(output["a"][2]["i"], "3");
|
||||
VS(output["a"][4]["i"], "5");
|
||||
VS(output[s_a][2][s_i], "3");
|
||||
VS(output[s_a][4][s_i], "5");
|
||||
}
|
||||
|
||||
return Count(true);
|
||||
|
||||
@@ -32,6 +32,9 @@ static const StaticString
|
||||
s_runId("runId");
|
||||
|
||||
bool TestLogger::initializeRun() {
|
||||
static const StaticString
|
||||
s_result("result"),
|
||||
s_runId("runId");
|
||||
if (!doLog())
|
||||
return true;
|
||||
|
||||
@@ -59,6 +62,7 @@ bool TestLogger::initializeRun() {
|
||||
}
|
||||
|
||||
run_id = response[s_result][s_runId];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário