diff options
Diffstat (limited to 'tests/cpp/include/variables')
22 files changed, 0 insertions, 1237 deletions
diff --git a/tests/cpp/include/variables/001-process_globals.h b/tests/cpp/include/variables/001-process_globals.h deleted file mode 100644 index ae930d2..0000000 --- a/tests/cpp/include/variables/001-process_globals.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * - * Test variables - * 001-process_globals.phpt - * Global variables in PHP-CPP - * - */ - - - - -/** - * Set up namespace - */ -namespace TestVariables { - - - - /** - * process_globals() - * - * This function reads and modifies global variables - */ - Php::Value process_globals() - { - // all global variables can be accessed via the Php::GLOBALS variable, - // which is more or less the same as the PHP $_GLOBALS variable - - // set a global variable - Php::GLOBALS["a"] = 1; - - // increment a global variable - Php::GLOBALS["b"] += 1; - - // set a global variable to be an array - Php::GLOBALS["c"] = Php::Array(); - - // add a member to an array - Php::GLOBALS["c"]["member"] = 123; - - // and increment it - Php::GLOBALS["c"]["member"] += 77; - - // change value e - Php::GLOBALS["e"] = Php::GLOBALS["e"][0]("hello"); - - // if a global variable holds a function, we can call it - return Php::GLOBALS["d"](1,2,3); - } - - - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/002-get_complex_array.h b/tests/cpp/include/variables/002-get_complex_array.h deleted file mode 100644 index b12e5ee..0000000 --- a/tests/cpp/include/variables/002-get_complex_array.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * - * Test variables - * 002-get_complex_array.phpt - * - */ - - - - -/** - * Set up namespace - */ -namespace TestVariables { - - /** - * This function returns complex array - */ - Php::Value get_complex_array() - { - Php::Value r; - r["a"] = 123; - r["b"] = 456; - r["c"][0] = "nested value"; - r["c"][1] = "example"; - r["c"][2] = 7; - return r; - } - - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/003-value-types.h b/tests/cpp/include/variables/003-value-types.h deleted file mode 100644 index d24549b..0000000 --- a/tests/cpp/include/variables/003-value-types.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * - * Test variables - * 003-value-types.phpt - * - */ - -namespace TestVariables { - - /* - * Check type of value - * @param array - */ - void value_types(Php::Parameters ¶ms) - { - if (params.size() == 0) return; - Php::Value arr = params[0]; - - Php::out << "Null: " << bool2str( arr.get("Null").isNull() ) << std::endl; - Php::out << "Numeric: " << bool2str( arr.get("Numeric").isNumeric()) << std::endl; - Php::out << "Float: " << bool2str( arr.get("Float").isFloat() ) << std::endl; - Php::out << "Bool: " << bool2str( arr.get("Bool").isBool() ) << std::endl; - Php::out << "Array: " << bool2str( arr.get("Array").isArray() ) << std::endl; - Php::out << "Object: " << bool2str( arr.get("Object").isObject() ) << std::endl; - Php::out << "String: " << bool2str( arr.get("String").isString() ) << std::endl; - Php::out << "Resource: " << bool2str( arr.get("Resource").type() == Php::Type::Resource ) << std::endl; - Php::out << "Constant: " << bool2str( arr.get("Constant").type() == Php::Type::Constant ) << std::endl; - Php::out << "ConstantArray: " << bool2str( arr.get("ConstantArray").type() == Php::Type::ConstantArray ) << std::endl; - Php::out << "Callable1: " << bool2str( arr.get("Callable1").isCallable() ) << std::endl; - Php::out << "Callable2: " << bool2str( arr.get("Callable2").isCallable() ) << std::endl; - Php::out << "Callable3: " << bool2str( arr.get("Callable3").isCallable() ) << std::endl; - Php::out << "Callable4: " << bool2str( arr.get("Callable4").isCallable() ) << std::endl; - - } - -} - diff --git a/tests/cpp/include/variables/004-store-scalar-variables.h b/tests/cpp/include/variables/004-store-scalar-variables.h deleted file mode 100644 index 9ce82e5..0000000 --- a/tests/cpp/include/variables/004-store-scalar-variables.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * - * Test variables - * 004-store-scalar-variables.phpt - * - */ - -/** - * Set up namespace - */ -namespace TestVariables { - - /* - * Test variables defined in PHP-CPP - */ - Php::Value scalar_store(void) { - - Php::Value value1 = 1234; - Php::Value value2 = "this is a string"; - Php::Value value3 = std::string("another string"); - Php::Value value4 = nullptr; - Php::Value value5 = 123.45; - Php::Value value6 = true; - - Php::Value r; - r[0] = value1; - r[1] = value2; - r[2] = value3; - r[3] = value4; - r[4] = value5; - r[5] = value6; - - r[6] = 1234; - r[7] = "this is a string"; - r[8] = std::string("another string"); - r[9] = nullptr; - r[10] = Php::Value(); - r[11] = 123.45; - r[12] = false; - - return r; - } - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/005-cast-objects-to-scalars.h b/tests/cpp/include/variables/005-cast-objects-to-scalars.h deleted file mode 100644 index f053c4d..0000000 --- a/tests/cpp/include/variables/005-cast-objects-to-scalars.h +++ /dev/null @@ -1,75 +0,0 @@ -/** - * - * Test variables - * 005-cast-objects-to-scalars.phpt - * - */ - - - -/** - * Set up namespace - */ -namespace TestVariables { - - /** - * A sample class, with methods to cast objects to scalars - */ - class Obj2Scalar : public Php::Base - { - public: - /** - * C++ constructor and C++ destructpr - */ - Obj2Scalar() {} - virtual ~Obj2Scalar() {} - - /** - * Cast to a string - * - * Note that now we use const char* as return value, and not Php::Value. - * The __toString function is detected at compile time, and it does - * not have a fixed signature. You can return any value that can be picked - * up by a Php::Value object. - * - * @return const char * - */ - const char *__toString() - { - return "Mount Meru, also called Sumeru (Sanskrit)"; - } - - /** - * Cast to a integer - * @return long - */ - long __toInteger() - { - return 27032014; - } - - /** - * Cast to a floating point number - * @return double - */ - double __toFloat() - { - return 3.14159265359; - } - - /** - * Cast to a boolean - * @return bool - */ - bool __toBool() - { - return true; - } - }; - - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/006-casting-obj2str.h b/tests/cpp/include/variables/006-casting-obj2str.h deleted file mode 100644 index 879683d..0000000 --- a/tests/cpp/include/variables/006-casting-obj2str.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * - * Test variables - * 006-casting-obj2str.phpt - * - */ - - - -/** - * Set up namespace - */ -namespace TestVariables { - - - /* - * Test Php::Value casting operators - */ - void value_cast2str(Php::Parameters ¶ms) - { - std::string value = params[0]; - Php::out << value << std::endl; - } - - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/007-overloaded-operators.h b/tests/cpp/include/variables/007-overloaded-operators.h deleted file mode 100644 index 88b3117..0000000 --- a/tests/cpp/include/variables/007-overloaded-operators.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * - * Test variables - * 007-overloaded-operators.phpt - * - */ - - - -namespace TestVariables { - - /* - * Test Php::Value overloaded operators - */ - void overloaded_op(Php::Parameters ¶ms) - { - Php::Value value = params[0]; - if (value == "some string") - { - Php::out << "value == 'some string'" << std::endl; - } - - if (value == 12) - { - Php::out << "value == 12" << std::endl; - } - else if (value > 100) - { - Php::out << "value > 100" << std::endl; - } - - value += 10; - Php::out << value << std::endl; - - int r1 = value - 8; - Php::out << r1 << std::endl; - - double r2 = value*123.45; - Php::out << r2 << std::endl; - - double r3 = value/123.45; - Php::out << r3 << std::endl; - } - -} - diff --git a/tests/cpp/include/variables/008-value-arrays.h b/tests/cpp/include/variables/008-value-arrays.h deleted file mode 100644 index 937f79a..0000000 --- a/tests/cpp/include/variables/008-value-arrays.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * - * Test variables - * 008-value-arrays.phpt - * - */ - - -namespace TestVariables { - - - /* - * Test Php::Value arrays - */ - Php::Value value_arrays(void) - { - // create a regular array - Php::Value array; - array[0] = "apple"; - array[1] = "banana"; - array[2] = "tomato"; - - // an initializer list can be used to create a filled array - Php::Value filled({ "a", "b", "c", "d"}); - - // create an associative array - Php::Value assoc; - assoc["apple"] = "green"; - assoc["banana"] = "yellow"; - assoc["tomato"] = "green"; - - // the variables in an array do not all have to be of the same type - Php::Value assoc2; - assoc2["x"] = "info@example.com"; - assoc2["y"] = nullptr; - assoc2["z"] = 123; - - // nested arrays are possible too - Php::Value assoc3; - assoc3["x"] = "info@example.com"; - assoc3["y"] = nullptr; - assoc3["z"][0] = "a"; - assoc3["z"][1] = "b"; - assoc3["z"][2] = "c"; - - Php::Value r; - r["array"] = array; - r["filled"] = filled; - r["assoc"] = assoc; - r["assoc2"] = assoc2; - r["assoc3"] = assoc3; - return r; - } - - -} - diff --git a/tests/cpp/include/variables/009-010-value-object.h b/tests/cpp/include/variables/009-010-value-object.h deleted file mode 100644 index e3eba85..0000000 --- a/tests/cpp/include/variables/009-010-value-object.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * - * Test variables - * 009-value-object.phpt - * 010-value-object2.phpt - * - */ - - -/** - * Set up namespace - */ -namespace TestVariables { - - - /* - * Test Php::Value object - */ - Php::Value value_object1(void) - { - - // create empty object of type stdClass - Php::Object object; - - // object properties can be accessed with square brackets - object["property1"] = "value1"; - object["property2"] = "value2"; - - // Php::Value is the base class, so you can assign Php::Object objects - //Php::Value value = object; - - return object; - } - - /* - * Test Php::Value object - */ - Php::Value value_object2(void) - { - - // create empty object of type stdClass - Php::Object object; - - // to create an object of a different type, pass in the class name - // to the constructor with optional constructor parameters - //object = Php::Object("DateTime", "2014-03-27 00:37:15.638276"); - - auto timeZone = Php::Object("DateTimeZone", "Europe/Amsterdam"); - object = Php::Object("DateTime", "2014-03-27 00:37:15", timeZone); - - - // methods can be called with the call() method - Php::out << object.call("format", "Y-m-d H:i:s") << std::endl; - - // all these methods can be called on a Php::Value object too - Php::Value value = Php::Object("DateTime", "2016-03-31 15:48:00", timeZone); - Php::out << value.call("format", "Y-m-d H:i:s") << std::endl; - Php::out << value.call("getOffset") << std::endl; - - return object; - } - - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/011-012-value-casting-operators.h b/tests/cpp/include/variables/011-012-value-casting-operators.h deleted file mode 100644 index 2d791b2..0000000 --- a/tests/cpp/include/variables/011-012-value-casting-operators.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * - * Test variables - * 011-value-casting-operators.phpt - * 012-value-casting-operators-double.phpt - * - */ - - - -/** - * Set up namespace - */ -namespace TestVariables { - - /* - * Test Php::Value casting operators - */ - void value_casting(Php::Parameters ¶ms) - { - Php::Value value = params[0]; - - int64_t value1 = value; - std::string value2 = value; - bool value4 = value; - - Php::out << " long:" << value1 << "\n string:" << value2 << "\n bool:" << bool2str(value4) << std::endl; - } - - - /* - * Test Php::Value casting operators - */ - void value_cast2double(Php::Parameters ¶ms) - { - Php::Value value = params[0]; - double value3 = value; - - /* - * The remark (from valmat). - * Somehow std::to_string truncates the tail of numbers of type `double` when converting it to a string. - * So I wrote my own function `double2str()`, which does not have this drawback. - */ - Php::out << double2str(value3) << std::endl; - } - - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/013-018-calling-php-functions.h b/tests/cpp/include/variables/013-018-calling-php-functions.h deleted file mode 100644 index 9a77408..0000000 --- a/tests/cpp/include/variables/013-018-calling-php-functions.h +++ /dev/null @@ -1,117 +0,0 @@ -/** - * - * Test call function - * 013-calling-php-functions.phpt - * ... - * 018-calling-php-functions.phpt - * - */ - - -/** - * Set up namespace - */ -namespace TestVariables { - - - /* - * Test call function from user space - */ - void fnFromUserSpace(void) - { - - - Php::out << "fnFromUserSpace" << std::endl; - - Php::Value param5; - param5.set(0, "param5"); - param5.set(1, 3.14159265359); - param5.set(2, 28032014); - param5.set("key", "value"); - - auto timeZone = Php::Object("DateTimeZone", "Asia/Yekaterinburg"); - Php::Value param6 = Php::Object("DateTime", "2014-03-28 19:42:15", timeZone); - - // call a function from user space - Php::call("some_function", "param1"); - Php::call("some_function", "param1", "param2"); - Php::call("some_function", "param1", "param2", "param3"); - Php::call("some_function", "param1", "param2", "param3", "param4"); - Php::call("some_function", "param1", "param2", "param3", "param4", param5); - Php::call("some_function", "param1", "param2", "param3", "param4", param5, param6); - Php::call("some_function", "param1", "param2", "param3", "param4", "param5", "param6", "param7"); - Php::call("some_function", "param1", "param2", "param3", "param4", "param5", "param6", "param7", "param8"); - Php::call("some_function", "param1", "param2", "param3", "param4", "param5", "param6", "param7", "param8", "param9"); - Php::call("some_function", "param1", "param2", "param3", "param4", "param5", "param6", "param7", "param8", "param9", "param10"); - - } - - /* - * Test call callback - */ - void fnCallback(Php::Parameters ¶ms) - { - Php::out << "call callback" << std::endl; - - Php::Value callback = params[0]; - - - Php::Value param5; - param5.set(0, "param5"); - param5.set(1, 3.14159265359); - param5.set(2, 28032014); - param5.set("key", "value"); - - auto timeZone = Php::Object("DateTimeZone", "Asia/Yekaterinburg"); - Php::Value param6 = Php::Object("DateTime", "2014-03-28 19:42:15", timeZone); - - // call a function from user space - callback("param1"); - callback("param1", "param2"); - callback("param1", "param2", "param3"); - callback("param1", "param2", "param3", "param4"); - callback("param1", "param2", "param3", "param4", param5); - callback("param1", "param2", "param3", "param4", param5, param6); - callback("param1", "param2", "param3", "param4", "param5", "param6", "param7"); - callback("param1", "param2", "param3", "param4", "param5", "param6", "param7", "param8"); - callback("param1", "param2", "param3", "param4", "param5", "param6", "param7", "param8", "param9"); - callback("param1", "param2", "param3", "param4", "param5", "param6", "param7", "param8", "param9", "param10"); - - } - - /* - * Test - */ - void fnFromUserSpace2(void) - { - - // create an object (this will also call __construct()) - Php::Object time("DateTime", "2014-03-28 21:22:15", Php::Object("DateTimeZone", "Asia/Irkutsk")); - - // call a method on the datetime object - Php::out << time.call("format", "Y-m-d H:i:s") << std::endl; - - // in PHP it is possible to create an array with two parameters, the first - // parameter being an object, and the second parameter should be the name - // of the method, we can do that in PHP-CPP too - Php::Array time_format({time, "format"}); - - // call the method that is stored in the array - Php::out << time_format("Y-m-d H:i:s") << std::endl; - - // call method of class from user space - Php::Object usrspcl("usrspClass", "Mount Meru"); - Php::Array usrspcl_meth({usrspcl, "someMethod"}); - // call the method that is stored in the array - Php::out << usrspcl_meth("is in the Arctics") << std::endl; - - // call callable object of class from user space - Php::Object clbl("CallableClass", "Arctics around mount Meru"); - Php::out << clbl("is the birthplace of the Hyperboreans") << std::endl; - } - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/019-HashMember-1.h b/tests/cpp/include/variables/019-HashMember-1.h deleted file mode 100644 index 28003f0..0000000 --- a/tests/cpp/include/variables/019-HashMember-1.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - * - * Test variables - * 019-HashMember-1.phpt - * Test HashMember - * - */ - - - - -/** - * Set up namespace - */ -namespace TestVariables { - - /** - * This function returns complex array - */ - Php::Value test_HashMember_1() - { - Php::Value r, tmp(Php::Type::Array); - r["key1"] = tmp; - r["key1"]["key2"] = "val2"; - r["key1"]["key3"] = "val3"; - return r; - } - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/020-HashMember-2.h b/tests/cpp/include/variables/020-HashMember-2.h deleted file mode 100644 index dfa95c2..0000000 --- a/tests/cpp/include/variables/020-HashMember-2.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * - * Test variables - * 019-HashMember-2.phpt - * Test HashMember - * - */ - - - - -/** - * Set up namespace - */ -namespace TestVariables { - - /** - * This function returns complex array - */ - Php::Value test_HashMember_2() - { - Php::Value r, empty_array(Php::Type::Array); - r["k1"]["k3"] = "v1"; - r["k1"]["k2"]["k4"] = "v2"; - r["k5"][1] = "v3"; - r[2]["k6"][1] = "v4"; - r[3][4][1] = "v5"; - r[3][4][2][5][7][11] = "v5"; - r[3][4][2][5][7]["k"] = "v5"; - r["c"][0] = "nested value"; - r["c"][1] = nullptr; - r["c"][2] = empty_array; - r["c"][3] = "example"; - return r; - } - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/021-HashMember-3.h b/tests/cpp/include/variables/021-HashMember-3.h deleted file mode 100644 index f7c0914..0000000 --- a/tests/cpp/include/variables/021-HashMember-3.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * - * Test variables - * 019-HashMember-3.phpt - * Test HashMember - * - */ - - - - -/** - * Set up namespace - */ -namespace TestVariables { - - /** - * This function returns complex array - */ - Php::Value test_HashMember_3() - { - - Php::Value r, tmp(Php::Type::Array); - //Php::Value tmp; - - tmp.set("key2", "val1-2"); - r.set("key1", tmp); - r.get("key1").set("key3", "val1-3"); - - // expect to receive the same as when recording: - //r["key1"]["key2"] = "val1-2"; - //r["key1"]["key3"] = "val1-3"; - - return r; - } - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/022-HashMember-4.h b/tests/cpp/include/variables/022-HashMember-4.h deleted file mode 100644 index e51eb3a..0000000 --- a/tests/cpp/include/variables/022-HashMember-4.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - * - * Test variables - * 019-HashMember-4.phpt - * Test HashMember - * - */ - - - - -/** - * Set up namespace - */ -namespace TestVariables { - - /** - * This function returns complex array - */ - Php::Value test_HashMember_4() - { - - - Php::Value r1; - Php::Value tmp1,tmp2; - tmp2.set("key3", "val"); - tmp1.set("key2", tmp2); - r1.set("key1", tmp1); - // this should be equivalent to: - // r1["key1"]["key2"]["key3"] = "val"; - - Php::Value r2; - r2.set("str1", "example"); - r2.set("str2", r2.get("str1")); - // this should be equivalent to: - // r2["str1"] = "example"; - // r2["str2"] = r2["str1"]; - // i.e. - // r2["str1"] = "example"; - // r2["str2"] = "example"; - - Php::Value r3; - Php::Value tmp; - tmp.set("str2", "val1-2"); - tmp.set("str3", "val1-3"); - r3.set("str1", tmp); - // this should be equivalent to: - // r3["str1"]["str2"] = "val1-2"; - // r3["str1"]["str3"] = "val1-3"; - - - Php::Value r; - r[0] = r1; - r[1] = r2; - r[2] = r3; - - - return r; - } - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/023-cookie.h b/tests/cpp/include/variables/023-cookie.h deleted file mode 100644 index 6f74883..0000000 --- a/tests/cpp/include/variables/023-cookie.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - * - * Test superglobal variables _COOKIE - * 023-cookie.phpt - * - */ - - - - -/** - * Set up namespace - */ -namespace TestVariables { - - - /* - * Test - */ - void getCookie(void) - { - Php::out << "_COOKIE[peace] = " << Php::COOKIE["peace"] << std::endl; - Php::out << "_COOKIE[freedom] = " << Php::COOKIE["freedom"] << std::endl; - Php::out << "_COOKIE[empty] = " << Php::COOKIE["empty"] << std::endl; - } - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/024-get-post.h b/tests/cpp/include/variables/024-get-post.h deleted file mode 100644 index e615f0f..0000000 --- a/tests/cpp/include/variables/024-get-post.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * - * Test superglobal variables _GET & _POST - * 024-get-post.phpt - * - */ - - - - -/** - * Set up namespace - */ -namespace TestVariables { - - - /* - * Test - */ - void get_post(void) - { - Php::out << "_GET[a] = " << Php::GET["a"] << std::endl; - Php::out << "_GET[b] = " << Php::GET["b"] << std::endl; - Php::out << "_GET[ar][elm1] = " << Php::GET["ar"]["elm1"] << std::endl; - Php::out << "_GET[ar][elm2] = " << Php::GET["ar"]["elm2"] << std::endl; - - Php::out << "_POST[c] = " << Php::POST["c"] << std::endl; - Php::out << "_POST[d] = " << Php::POST["d"] << std::endl; - Php::out << "_POST[e] = " << Php::POST["e"] << std::endl; - Php::out << "_POST[e][0] = " << Php::POST["e"][0] << std::endl; - Php::out << "_POST[e][1] = " << Php::POST["e"][1] << std::endl; - } - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/025-post-raw1.h b/tests/cpp/include/variables/025-post-raw1.h deleted file mode 100644 index 37c6ae1..0000000 --- a/tests/cpp/include/variables/025-post-raw1.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * - * Test superglobal variables _POST - * 025-post-raw1.phpt - * - */ - - - - -/** - * Set up namespace - */ -namespace TestVariables { - using namespace Php; - - - /* - * Test - */ - void post_raw1(void) - { - out << "username => "<< POST["username"] << std::endl; - out << "text => "<< POST["text"] << std::endl; - - /* - XXX TODO: conversion from ‘Php::Super’ to ‘Php::Value‘ - Value v = POST; - - out << "Array/Object contains " << v.size() << " items" << std::endl; - for (auto it=v.begin(), itend = v.end(); it != itend; ++it) { - out << "["<< it->first << "]="<< it->second << std::endl; - } - */ - } - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/026-post-raw2.h b/tests/cpp/include/variables/026-post-raw2.h deleted file mode 100644 index d250dc8..0000000 --- a/tests/cpp/include/variables/026-post-raw2.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * - * Test superglobal variables _POST - * 026-post-raw2.phpt - * - */ - - -#include <iostream> -#include <fstream> - -/** - * Set up namespace - */ -namespace TestVariables { - using namespace Php; - - - /* - * Test - */ - void post_raw2(void) - { - out << "name1 : "<< FILES["flnm"]["name"][0] << std::endl; - out << "name2 : "<< FILES["flnm"]["name"][1] << std::endl; - - out << "type1 : "<< FILES["flnm"]["type"][0] << std::endl; - out << "type2 : "<< FILES["flnm"]["type"][1] << std::endl; - - out << "error1 : "<< FILES["flnm"]["error"][0] << std::endl; - out << "error2 : "<< FILES["flnm"]["error"][1] << std::endl; - - out << "size1 : "<< FILES["flnm"]["size"][0] << std::endl; - out << "size2 : "<< FILES["flnm"]["size"][1] << std::endl; - - - int length0 = FILES["flnm"]["size"][0]; - int length1 = FILES["flnm"]["size"][1]; - char *buffer0, *buffer1; - - std::ifstream file0, file1; - std::string filename0 = FILES["flnm"]["tmp_name"][0]; - std::string filename1 = FILES["flnm"]["tmp_name"][1]; - - file0.open(filename0, std::ios::in | std::ios::binary); - file1.open(filename1, std::ios::in | std::ios::binary); - - if(!file0.is_open() || !file1.is_open()) { - out << "Cannot open file." << std::endl; - return; - } - - //allocate memory - buffer0 = new char[length0]; - buffer1 = new char[length1]; - - //read data as a block to buffer - file0.read(buffer0, length0); - file1.read(buffer1, length1); - file0.close(); - file1.close(); - - out << "content1 : "; - out.write(buffer0, length0); - out << std::endl; - out << "content2 : "<< buffer1 << std::endl; - - delete[] buffer0; - delete[] buffer1; - } - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/027-env.h b/tests/cpp/include/variables/027-env.h deleted file mode 100644 index b8455b4..0000000 --- a/tests/cpp/include/variables/027-env.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - * - * Test superglobal variables _ENV - * 027-env.phpt - * - */ - - - -namespace TestVariables { - - - /* - * Test - */ - void test_env(void) - { - Php::out << "HTTP_USER_AGENT => " << Php::SERVER["HTTP_USER_AGENT"] << std::endl; - Php::out << "ENVVAR1 => " << Php::SERVER["ENVVAR1"] << std::endl; - Php::out << "HTTP_REFERER => " << Php::SERVER["HTTP_REFERER"] << std::endl; - Php::out << "REQUEST_METHOD => " << Php::SERVER["REQUEST_METHOD"] << std::endl; - Php::out << "HTTP_HOST => " << Php::SERVER["HTTP_HOST"] << std::endl; - } - -} - diff --git a/tests/cpp/include/variables/028-029-compare.h b/tests/cpp/include/variables/028-029-compare.h deleted file mode 100644 index bd95298..0000000 --- a/tests/cpp/include/variables/028-029-compare.h +++ /dev/null @@ -1,194 +0,0 @@ -/** - * - * Test variables - * phptname.phpt - * - */ - - - - -/** - * Set up namespace - */ -namespace TestVariables { - - /* - * Test bool Value::operator==(const Value &value) const - */ - void test_compare1() - { - Php::Value v1(5), v2(5.0), v3("5"), v4("5.0"); - - Php::out << "true:" << std::endl; - Php::out << (v1 == v2) << std::endl; - Php::out << (v1 == v3) << std::endl; - Php::out << (v1 == v4) << std::endl; - Php::out << (v2 == v1) << std::endl; - Php::out << (v2 == v3) << std::endl; - Php::out << (v2 == v4) << std::endl; - Php::out << (v3 == v1) << std::endl; - Php::out << (v3 == v2) << std::endl; - Php::out << (v3 == v4) << std::endl; - Php::out << (v4 == v1) << std::endl; - Php::out << (v4 == v2) << std::endl; - Php::out << (v4 == v3) << std::endl; - - Php::Value v5(6), v6(6.0), v7("6"), v8("6.0"); - - Php::out << "false:" << std::endl; - Php::out << (v1 == v5) << std::endl; - Php::out << (v1 == v6) << std::endl; - Php::out << (v1 == v7) << std::endl; - Php::out << (v1 == v8) << std::endl; - - Php::out << (v2 == v5) << std::endl; - Php::out << (v2 == v6) << std::endl; - Php::out << (v2 == v7) << std::endl; - Php::out << (v2 == v8) << std::endl; - - Php::out << (v3 == v5) << std::endl; - Php::out << (v3 == v6) << std::endl; - Php::out << (v3 == v7) << std::endl; - Php::out << (v3 == v8) << std::endl; - - Php::out << (v4 == v5) << std::endl; - Php::out << (v4 == v6) << std::endl; - Php::out << (v4 == v7) << std::endl; - Php::out << (v4 == v8) << std::endl; - - Php::Value v9, v10, v11, v12; - v9[0] = 5; - v9[1] = 6; - - v10[0] = 5; - v10[1] = "Hello!"; - - v11[0] = 5; - v11[1] = 6; - - v12[0] = 5; - - Php::out << "Compare array:" << std::endl; - Php::out << (v1 == v9) << std::endl; - Php::out << (v5 == v9) << std::endl; - Php::out << (v9 == v10) << std::endl; - Php::out << (v11 == v9) << std::endl; - Php::out << (v12 == v9) << std::endl; - - Php::Value v13 = false, v14, v15 = 0; - Php::out << "Compare NULL:" << std::endl; - Php::out << (v1 == v13) << std::endl; - Php::out << (v1 == v14) << std::endl; - Php::out << (v1 == v15) << std::endl; - - Php::out << (v13 == v14) << std::endl; - Php::out << (v13 == v15) << std::endl; - Php::out << (v14 == v15) << std::endl; - } - - /* - * Test bool Value::operator< (const Value &value) const - */ - void test_compare2() - { - Php::Value v1(5), v2(5.0), v3("5"), v4("5.0"); - - Php::out << "false:" << std::endl; - Php::out << (v1 < v2) << std::endl; - Php::out << (v1 < v3) << std::endl; - Php::out << (v1 < v4) << std::endl; - Php::out << (v2 < v1) << std::endl; - Php::out << (v2 < v3) << std::endl; - Php::out << (v2 < v4) << std::endl; - Php::out << (v3 < v1) << std::endl; - Php::out << (v3 < v2) << std::endl; - Php::out << (v3 < v4) << std::endl; - Php::out << (v4 < v1) << std::endl; - Php::out << (v4 < v2) << std::endl; - Php::out << (v4 < v3) << std::endl; - - Php::Value v5(6), v6(6.0), v7("6"), v8("6.0"); - - Php::out << "true:" << std::endl; - Php::out << (v1 < v5) << std::endl; - Php::out << (v1 < v6) << std::endl; - Php::out << (v1 < v7) << std::endl; - Php::out << (v1 < v8) << std::endl; - - Php::out << (v2 < v5) << std::endl; - Php::out << (v2 < v6) << std::endl; - Php::out << (v2 < v7) << std::endl; - Php::out << (v2 < v8) << std::endl; - - Php::out << (v3 < v5) << std::endl; - Php::out << (v3 < v6) << std::endl; - Php::out << (v3 < v7) << std::endl; - Php::out << (v3 < v8) << std::endl; - - Php::out << (v4 < v5) << std::endl; - Php::out << (v4 < v6) << std::endl; - Php::out << (v4 < v7) << std::endl; - Php::out << (v4 < v8) << std::endl; - - Php::out << "false:" << std::endl; - Php::out << (v1 > v5) << std::endl; - Php::out << (v1 > v6) << std::endl; - Php::out << (v1 > v7) << std::endl; - Php::out << (v1 > v8) << std::endl; - - Php::out << (v2 > v5) << std::endl; - Php::out << (v2 > v6) << std::endl; - Php::out << (v2 > v7) << std::endl; - Php::out << (v2 > v8) << std::endl; - - Php::out << (v3 > v5) << std::endl; - Php::out << (v3 > v6) << std::endl; - Php::out << (v3 > v7) << std::endl; - Php::out << (v3 > v8) << std::endl; - - Php::out << (v4 > v5) << std::endl; - Php::out << (v4 > v6) << std::endl; - Php::out << (v4 > v7) << std::endl; - Php::out << (v4 > v8) << std::endl; - - Php::Value v9, v10, v11, v12; - v9[0] = 5; - v9[1] = 6; - - v10[0] = 5; - v10[1] = "Hello!"; - - v11[0] = 5; - v11[1] = 6; - - v12[0] = 5; - - Php::out << "Compare array:" << std::endl; - Php::out << (v1 < v9) << std::endl; - Php::out << (v5 < v9) << std::endl; - Php::out << (v9 < v10) << std::endl; - Php::out << (v9 > v10) << std::endl; - Php::out << (v11 < v9) << std::endl; - Php::out << (v12 < v9) << std::endl; - - Php::Value v13 = false, v14, v15 = 0; - Php::out << "Compare NULL:" << std::endl; - Php::out << (v1 < v13) << std::endl; - Php::out << (v1 < v14) << std::endl; - Php::out << (v1 < v15) << std::endl; - - Php::out << (v1 > v13) << std::endl; - Php::out << (v1 > v14) << std::endl; - Php::out << (v1 > v15) << std::endl; - - Php::out << (v13 < v14) << std::endl; - Php::out << (v13 < v15) << std::endl; - Php::out << (v14 < v15) << std::endl; - } - -/** - * End of namespace - */ -} - diff --git a/tests/cpp/include/variables/tpl.h b/tests/cpp/include/variables/tpl.h deleted file mode 100644 index 0df5892..0000000 --- a/tests/cpp/include/variables/tpl.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * - * Test variables - * phptname.phpt - * - */ - - - - -/** - * Set up namespace - */ -namespace TestVariables { - - /* - * Test - */ - void fnname(Php::Parameters ¶ms) - { - - - } - -/** - * End of namespace - */ -} - |