diff options
Diffstat (limited to 'tests/cpp')
-rw-r--r-- | tests/cpp/h/variables.h | 2 | ||||
-rw-r--r-- | tests/cpp/include/variables/013-018-calling-php-functions.h (renamed from tests/cpp/include/variables/013-017-calling-php-functions.h) | 42 | ||||
-rw-r--r-- | tests/cpp/main.cpp | 1 |
3 files changed, 43 insertions, 2 deletions
diff --git a/tests/cpp/h/variables.h b/tests/cpp/h/variables.h index df0d923..3ff77e9 100644 --- a/tests/cpp/h/variables.h +++ b/tests/cpp/h/variables.h @@ -17,7 +17,7 @@ #include "../include/variables/008-value-arrays.h" #include "../include/variables/009-010-value-object.h" #include "../include/variables/011-012-value-casting-operators.h" -#include "../include/variables/013-017-calling-php-functions.h" +#include "../include/variables/013-018-calling-php-functions.h" //#include "../include/variables/.h" //#include "../include/variables/.h" diff --git a/tests/cpp/include/variables/013-017-calling-php-functions.h b/tests/cpp/include/variables/013-018-calling-php-functions.h index 94367e0..c646f60 100644 --- a/tests/cpp/include/variables/013-017-calling-php-functions.h +++ b/tests/cpp/include/variables/013-018-calling-php-functions.h @@ -3,7 +3,7 @@ * Test call function * 013-calling-php-functions.phpt * ... - * 017-calling-php-functions.phpt + * 018-calling-php-functions.phpt * */ @@ -79,6 +79,46 @@ namespace TestVariables { } + /* + * 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; + + + + //::someMethod + //(new usrspClass("Mount Meru"))->someMethod("is in the Arctics"); + + + + + + } /** * End of namespace diff --git a/tests/cpp/main.cpp b/tests/cpp/main.cpp index 4db7b9c..5d0d0a6 100644 --- a/tests/cpp/main.cpp +++ b/tests/cpp/main.cpp @@ -103,6 +103,7 @@ extern "C" extension.add("TestVariables\\value_object1", TestVariables::value_object1); extension.add("TestVariables\\value_object2", TestVariables::value_object2); extension.add("TestVariables\\fnFromUserSpace", TestVariables::fnFromUserSpace); + extension.add("TestVariables\\fnFromUserSpace2", TestVariables::fnFromUserSpace2); extension.add("TestVariables\\fnCallback", TestVariables::fnCallback); |