diff options
author | valmat <ufabiz@gmail.com> | 2014-03-28 19:00:17 +0600 |
---|---|---|
committer | valmat <ufabiz@gmail.com> | 2014-03-28 19:00:17 +0600 |
commit | 708a22fae15b13db871ca5ffc73004c70f0584fe (patch) | |
tree | 639e424f544f8ca5c950803620399c57fceb69bd /tests/cpp/include/variables/009-010-value-object.h | |
parent | 7bc500847e3027bb785c5525a21078ff72acc2ab (diff) |
Changed the structure of the test file. With the increasing number of tests the old structure became uncomfortable.
Diffstat (limited to 'tests/cpp/include/variables/009-010-value-object.h')
-rw-r--r-- | tests/cpp/include/variables/009-010-value-object.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/cpp/include/variables/009-010-value-object.h b/tests/cpp/include/variables/009-010-value-object.h new file mode 100644 index 0000000..e3eba85 --- /dev/null +++ b/tests/cpp/include/variables/009-010-value-object.h @@ -0,0 +1,68 @@ +/** + * + * 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 + */ +} + |