diff options
author | valmat <ufabiz@gmail.com> | 2014-03-28 21:58:30 +0600 |
---|---|---|
committer | valmat <ufabiz@gmail.com> | 2014-03-28 21:58:30 +0600 |
commit | 4091487adfbfd07750524fd7910d7178af21f816 (patch) | |
tree | fb909ff7dedbe5eef51533364cdff09e9f4e575e /tests/cpp/include | |
parent | 168eeabc6e52165a71a3130c5e0f26a7fd9382c9 (diff) |
add test: 018-calling-php-functions
Diffstat (limited to 'tests/cpp/include')
-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 |
1 files changed, 41 insertions, 1 deletions
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 |