diff options
Diffstat (limited to 'tests/cpp/include')
-rw-r--r-- | tests/cpp/include/ini_entries/001.h | 34 | ||||
-rw-r--r-- | tests/cpp/include/variables/023-cookie.h | 31 | ||||
-rw-r--r-- | tests/cpp/include/variables/024-get-post.h | 38 | ||||
-rw-r--r-- | tests/cpp/include/variables/025-post-raw1.h | 41 | ||||
-rw-r--r-- | tests/cpp/include/variables/026-post-raw2.h | 76 | ||||
-rw-r--r-- | tests/cpp/include/variables/027-env.h | 26 | ||||
-rw-r--r-- | tests/cpp/include/variables/tpl.h | 21 |
7 files changed, 232 insertions, 35 deletions
diff --git a/tests/cpp/include/ini_entries/001.h b/tests/cpp/include/ini_entries/001.h index ece2aa4..8a4c5ca 100644 --- a/tests/cpp/include/ini_entries/001.h +++ b/tests/cpp/include/ini_entries/001.h @@ -10,33 +10,19 @@ */ namespace TestIniEntries { - + // will be retrieved at boot extension + double ini6val = 0.0; + void iniTest1(Php::Parameters ¶ms) { - /* - .add(Php::Ini(, "valIni1")) - .add(Php::Ini("ini2", "valIni2", "OrigValIni2")) - .add(Php::Ini("ini3", "valIni3", "OrigValIni3", Php::Ini::System)) - .add(Php::Ini("ini4", true, false, Php::Ini::Place::User)) - .add(Php::Ini("ini5", false)); - - Ini::get("ini1") - */ - - Php::out << "ini_get(ini1) = {{" << Php::ini_get("ini1") << " | " << Php::ini_get_orig("ini1") << "}}" << std::endl; - Php::out << "ini_get(ini2) = {{" << Php::ini_get("ini2") << " | " << Php::ini_get_orig("ini2") << "}}" << std::endl; - Php::out << "ini_get(ini3) = {{" << Php::ini_get("ini3") << " | " << Php::ini_get_orig("ini3") << "}}" << std::endl; - Php::out << "ini_get(ini4) = {{" << Php::ini_get("ini4") << " | " << Php::ini_get_orig("ini4") << "}}" << std::endl; - /* - Php::out << "extension_for_tests.some_string ={{" << Php::ini_get("extension_for_tests.some_string") << "}}" << std::endl; - Php::out << "extension_for_tests.some_string2 ={{" << Php::ini_get("extension_for_tests.some_string2") << "}}" << std::endl; - Php::out << "extension_for_tests.some_string3 ={{" << Php::ini_get("extension_for_tests.some_string3") << "}}" << std::endl; - Php::out << "extension_for_tests.some_string3 ={{" << Php::ini_get("extension_for_tests.some_bool") << "}}" << std::endl; - */ - - + Php::out << "ini_get(ini1) = " << Php::ini_get("ini1") << std::endl; + Php::out << "ini_get(ini2) = " << Php::ini_get("ini2") << std::endl; + Php::out << "ini_get(ini3) = " << Php::ini_get("ini3") << std::endl; + Php::out << "ini_get(ini4) = " << Php::ini_get("ini4") << std::endl; + Php::out << "ini_get(ini5) = " << Php::ini_get("ini5") << std::endl; + Php::out << "ini_get(ini6) = " << Php::ini_get("ini6") << std::endl; - return; + Php::out << "ini6val = " << ini6val << std::endl; } /** * End of namespace diff --git a/tests/cpp/include/variables/023-cookie.h b/tests/cpp/include/variables/023-cookie.h new file mode 100644 index 0000000..6f74883 --- /dev/null +++ b/tests/cpp/include/variables/023-cookie.h @@ -0,0 +1,31 @@ +/** + * + * 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 new file mode 100644 index 0000000..e615f0f --- /dev/null +++ b/tests/cpp/include/variables/024-get-post.h @@ -0,0 +1,38 @@ +/** + * + * 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 new file mode 100644 index 0000000..37c6ae1 --- /dev/null +++ b/tests/cpp/include/variables/025-post-raw1.h @@ -0,0 +1,41 @@ +/** + * + * 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 new file mode 100644 index 0000000..d250dc8 --- /dev/null +++ b/tests/cpp/include/variables/026-post-raw2.h @@ -0,0 +1,76 @@ +/** + * + * 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 new file mode 100644 index 0000000..b8455b4 --- /dev/null +++ b/tests/cpp/include/variables/027-env.h @@ -0,0 +1,26 @@ +/** + * + * 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/tpl.h b/tests/cpp/include/variables/tpl.h index 3c4ed7c..0df5892 100644 --- a/tests/cpp/include/variables/tpl.h +++ b/tests/cpp/include/variables/tpl.h @@ -1,7 +1,7 @@ /** * * Test variables - * phptname.phpt + * phptname.phpt * */ @@ -12,16 +12,15 @@ * Set up namespace */ namespace TestVariables { - - - /* - * Test - */ - void fnname(Php::Parameters ¶ms) - { - - - } + + /* + * Test + */ + void fnname(Php::Parameters ¶ms) + { + + + } /** * End of namespace |