diff options
Diffstat (limited to 'tests/php/phpt')
18 files changed, 809 insertions, 24 deletions
diff --git a/tests/php/phpt/base/001.phpt b/tests/php/phpt/class_obj/001.phpt index b22a44c..b22a44c 100644 --- a/tests/php/phpt/base/001.phpt +++ b/tests/php/phpt/class_obj/001.phpt diff --git a/tests/php/phpt/base/002.phpt b/tests/php/phpt/class_obj/002.phpt index 847e602..847e602 100644 --- a/tests/php/phpt/base/002.phpt +++ b/tests/php/phpt/class_obj/002.phpt diff --git a/tests/php/phpt/class_obj/003-comparable.phpt b/tests/php/phpt/class_obj/003-comparable.phpt new file mode 100644 index 0000000..3e0b1f6 --- /dev/null +++ b/tests/php/phpt/class_obj/003-comparable.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test comparable objects +--SKIPIF-- +<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?> +--FILEEOF-- +<?php + +// initialize a couple of objects +$object1 = new TestBaseClass\Comparable(); +$object2 = new TestBaseClass\Comparable(); +$object3 = new TestBaseClass\Comparable(); + +// compare the objects +if ($object1 < $object2) +{ + echo("$object1 is smaller than $object2\n"); +} +else +{ + echo("$object1 is bigger than $object2\n"); +} + +if ($object1 == $object3) +{ + echo("$object1 is equal to $object3\n"); +} +else +{ + echo("$object1 is not equal to $object3\n"); +} + +if ($object1 != $object2) +{ + echo("$object1 is not equal to $object2\n"); +} +else +{ + echo("$object1 is equal to $object2\n"); +} + + +//echo PHP_EOL; +--EXPECT-- +Obj#1(2) is bigger than Obj#2(1) +Obj#1(2) is equal to Obj#3(2) +Obj#1(2) is not equal to Obj#2(1)
\ No newline at end of file diff --git a/tests/php/phpt/class_obj/004-static-funct.phpt b/tests/php/phpt/class_obj/004-static-funct.phpt new file mode 100644 index 0000000..8c78210 --- /dev/null +++ b/tests/php/phpt/class_obj/004-static-funct.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test class with static function +--SKIPIF-- +<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?> +--FILEEOF-- +<?php + +// this will call PublicClass::staticMethod() +TestBaseClass\ClassWithStatic::static1(); + +// this will call PrivateClass::staticMethod() +TestBaseClass\ClassWithStatic::static2(); + +// this will call regularFunction() +TestBaseClass\ClassWithStatic::static3(); + +// this will also call PrivateClass::staticMethod() +TestBaseClass\staticFun1(); + + +//echo PHP_EOL; +--EXPECT-- +testStaticPubClass::staticMethod() +testStatic regular function +testStaticPrivClass::staticMethod() +testStaticPrivClass::staticMethod()
\ No newline at end of file diff --git a/tests/php/phpt/class_obj/004-static-prop.phpt b/tests/php/phpt/class_obj/004-static-prop.phpt new file mode 100644 index 0000000..4073247 --- /dev/null +++ b/tests/php/phpt/class_obj/004-static-prop.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test class with static property and class constant +--SKIPIF-- +<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?> +--FILEEOF-- +<?php + +var_dump( TestBaseClass\MyClass::CONSTANT1 ); +var_dump( TestBaseClass\MyClass::EXP ); +var_dump( TestBaseClass\MyClass::CONSTANT2 ); +var_dump( TestBaseClass\MyClass::CONSTANT1 ); + + +//echo PHP_EOL; +--EXPECT-- +bool(true) +float(2.718281828459) +int(-2582341) +bool(true)
\ No newline at end of file diff --git a/tests/php/phpt/base/readme b/tests/php/phpt/class_obj/readme index 6c89a94..6c89a94 100644 --- a/tests/php/phpt/base/readme +++ b/tests/php/phpt/class_obj/readme diff --git a/tests/php/phpt/valueiterator/007-Iterate-internal-array.phpt b/tests/php/phpt/valueiterator/007-Iterate-internal-array.phpt new file mode 100644 index 0000000..1f18203 --- /dev/null +++ b/tests/php/phpt/valueiterator/007-Iterate-internal-array.phpt @@ -0,0 +1,15 @@ +--TEST-- +Iterate internal array +--SKIPIF-- +<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?> +--FILEEOF-- +<?php + +TestValueIterator\loopArray(); + +--EXPECT-- +Array/Object contains 4 items +[0]=val0 +[1]=val1 +[third]=val3 +[fourth]=val3 diff --git a/tests/php/phpt/variables/003-value-types.phpt- b/tests/php/phpt/variables/003-value-types.phpt index 477fbe2..477fbe2 100644 --- a/tests/php/phpt/variables/003-value-types.phpt- +++ b/tests/php/phpt/variables/003-value-types.phpt diff --git a/tests/php/phpt/variables/005-cast-objects-to-scalars.phpt b/tests/php/phpt/variables/005-cast-objects-to-scalars.phpt new file mode 100644 index 0000000..9de9ba5 --- /dev/null +++ b/tests/php/phpt/variables/005-cast-objects-to-scalars.phpt @@ -0,0 +1,22 @@ +--TEST-- +cast objects to scalars +--DESCRIPTION-- +http://www.phpcpp.com/documentation/special-features#casting-functions +--SKIPIF-- +<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?> +--FILEEOF-- +<?php + + +function bool2str($b) { + return $b ? "Yes" : "No"; +} +$obj = new TestVariables\Obj2Scalar(); +echo " long: ", (int)$obj, "\n string: ", (string)$obj, "\n double: ", (double)$obj, "\n bool: ", bool2str((bool)$obj); + + +--EXPECT-- + long: 27032014 + string: Mount Meru, also called Sumeru (Sanskrit) + double: 3.14159265359 + bool: Yes diff --git a/tests/php/phpt/variables/005-value-casting-operators.phpt- b/tests/php/phpt/variables/011-value-casting-operators.phpt index 5e0fb8e..3fe6817 100644 --- a/tests/php/phpt/variables/005-value-casting-operators.phpt- +++ b/tests/php/phpt/variables/011-value-casting-operators.phpt @@ -3,13 +3,9 @@ Test Php::Value casting operators --DESCRIPTION-- The Php::Value class has casting operators to cast the object to almost every thinkable native type. - -It seems need to replace double on long double - native_value_casting - repeats the behavior of c++ functions TestVariables\value_casting the output of each of these functions should be the same - --SKIPIF-- <?php if (!extension_loaded("extension_for_tests")) print "skip"; ?> --FILEEOF-- @@ -20,7 +16,8 @@ function bool2str($b) { return $b ? "Yes" : "No"; } function native_value_casting($value) { - echo " long:", (int)$value, "\n string:", (string)$value, "\n double:", (double)$value, "\n bool:", bool2str((bool)$value), PHP_EOL; + //echo " long:", (int)$value, "\n string:", (string)$value, "\n double:", (double)$value, "\n bool:", bool2str((bool)$value), PHP_EOL; + echo " long:", (int)$value, "\n string:", (string)$value, "\n bool:", bool2str((bool)$value), PHP_EOL; } @@ -61,114 +58,95 @@ out(0x1A); // hexadecimal number (equivalent to 26 decimal) Test 5555555555555555: long:5555555555555555 string:5555555555555555 - double:5.5555555555556E+15 bool:Yes Test '9223372036854775807': long:9223372036854775807 string:9223372036854775807 - double:9.2233720368548E+18 bool:Yes Test 9223372036854775807: long:9223372036854775807 string:9223372036854775807 - double:9.2233720368548E+18 bool:Yes Test 5: long:5 string:5 - double:5 bool:Yes Test -99999999: long:-99999999 string:-99999999 - double:-99999999 bool:Yes Test '18': long:18 string:18 - double:18 bool:Yes Test '3.14159265359': long:3 string:3.14159265359 - double:3.14159265359 bool:Yes Test 3.14159265359: long:3 string:3.14159265359 - double:3.14159265359 bool:Yes Test 3.5714285714286: long:3 string:3.5714285714286 - double:3.5714285714286 bool:Yes Test ' this is a string ': long:0 string: this is a string - double:0 bool:Yes Test ' 2-nd string ': long:2 string: 2-nd string - double:2 bool:Yes Test 'false': long:0 string:false - double:0 bool:Yes Test false: long:0 string: - double:0 bool:No Test 'true': long:0 string:true - double:0 bool:Yes Test true: long:1 string:1 - double:1 bool:Yes Test 0: long:0 string:0 - double:0 bool:No Test '0': long:0 string:0 - double:0 bool:No Test 83: long:83 string:83 - double:83 bool:Yes Test 26: long:26 string:26 - double:26 bool:Yes diff --git a/tests/php/phpt/variables/012-value-casting-operators-double.phpt b/tests/php/phpt/variables/012-value-casting-operators-double.phpt new file mode 100644 index 0000000..32086ef --- /dev/null +++ b/tests/php/phpt/variables/012-value-casting-operators-double.phpt @@ -0,0 +1,80 @@ +--TEST-- +Test Php::Value casting operators (double) +--DESCRIPTION-- +The Php::Value class has casting operators to cast the object to almost every thinkable native type. + +native_value_casting - repeats the behavior of c++ functions TestVariables\value_casting +the output of each of these functions should be the same +--SKIPIF-- +<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?> +--FILEEOF-- +<?php + + + +function out($v) { + echo 'Test '; + var_export($v); + echo ':', PHP_EOL; + TestVariables\value_cast2double($v); + //echo (double)$v, PHP_EOL;; + //echo PHP_EOL; +} + +out(5555555555555555); +out("999999999999999"); +out(999999999999999); +out(5); +out(-99999999); +out("18"); +out("3.14159265359"); +out(3.14159265359); +out(" this is a string "); +out(" 2-nd string "); +out("false"); +out(false); +out("true"); +out(true); +out(0); +out("0"); +out(0123); // octal number (equivalent to 83 decimal) +out(0x1A); // hexadecimal number (equivalent to 26 decimal) + + +--EXPECT-- +Test 5555555555555555: +5555555555555555 +Test '999999999999999': +999999999999999 +Test 999999999999999: +999999999999999 +Test 5: +5 +Test -99999999: +-99999999 +Test '18': +18 +Test '3.14159265359': +3.14159265359 +Test 3.14159265359: +3.14159265359 +Test ' this is a string ': +0 +Test ' 2-nd string ': +2 +Test 'false': +0 +Test false: +0 +Test 'true': +0 +Test true: +1 +Test 0: +0 +Test '0': +0 +Test 83: +83 +Test 26: +26
\ No newline at end of file diff --git a/tests/php/phpt/variables/013-calling-php-functions.phpt b/tests/php/phpt/variables/013-calling-php-functions.phpt new file mode 100644 index 0000000..5ec6644 --- /dev/null +++ b/tests/php/phpt/variables/013-calling-php-functions.phpt @@ -0,0 +1,113 @@ +--TEST-- +calling-php-functions from userspace +--SKIPIF-- +<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?> +--FILEEOF-- +<?php + + + +function some_function($param) { + echo("userspace function called with parameters:\n"); + var_export(func_get_args ()); +} + +TestVariables\fnFromUserSpace(); + + + +--EXPECT-- +fnFromUserSpace +userspace function called with parameters: +array ( + 0 => 'param1', +)userspace function called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', +)userspace function called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', +)userspace function called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', +)userspace function called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => + array ( + 0 => 'param5', + 1 => 3.14159265359, + 2 => 28032014, + 'key' => 'value', + ), +)userspace function called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => + array ( + 0 => 'param5', + 1 => 3.14159265359, + 2 => 28032014, + 'key' => 'value', + ), + 5 => + DateTime::__set_state(array( + 'date' => '2014-03-28 19:42:15', + 'timezone_type' => 3, + 'timezone' => 'Asia/Yekaterinburg', + )), +)userspace function called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', +)userspace function called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', + 7 => 'param8', +)userspace function called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', + 7 => 'param8', + 8 => 'param9', +)userspace function called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', + 7 => 'param8', + 8 => 'param9', + 9 => 'param10', +)
\ No newline at end of file diff --git a/tests/php/phpt/variables/014-calling-php-functions.phpt b/tests/php/phpt/variables/014-calling-php-functions.phpt new file mode 100644 index 0000000..4a05e2a --- /dev/null +++ b/tests/php/phpt/variables/014-calling-php-functions.phpt @@ -0,0 +1,113 @@ +--TEST-- +calling-php-Callback-functions +--SKIPIF-- +<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?> +--FILEEOF-- +<?php + + + +function some_function($param) { + echo("Callback called with parameters:\n"); + var_export(func_get_args ()); +} + +TestVariables\fnCallback("some_function"); + + + +--EXPECT-- +call callback +Callback called with parameters: +array ( + 0 => 'param1', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => + array ( + 0 => 'param5', + 1 => 3.14159265359, + 2 => 28032014, + 'key' => 'value', + ), +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => + array ( + 0 => 'param5', + 1 => 3.14159265359, + 2 => 28032014, + 'key' => 'value', + ), + 5 => + DateTime::__set_state(array( + 'date' => '2014-03-28 19:42:15', + 'timezone_type' => 3, + 'timezone' => 'Asia/Yekaterinburg', + )), +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', + 7 => 'param8', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', + 7 => 'param8', + 8 => 'param9', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', + 7 => 'param8', + 8 => 'param9', + 9 => 'param10', +)
\ No newline at end of file diff --git a/tests/php/phpt/variables/015-calling-php-functions.phpt b/tests/php/phpt/variables/015-calling-php-functions.phpt new file mode 100644 index 0000000..e9382b2 --- /dev/null +++ b/tests/php/phpt/variables/015-calling-php-functions.phpt @@ -0,0 +1,109 @@ +--TEST-- +calling-php-Callback-functions (lambda) +--SKIPIF-- +<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?> +--FILEEOF-- +<?php + + +TestVariables\fnCallback( function($param) { + echo("Callback called with parameters:\n"); + var_export(func_get_args ()); +}); + + +--EXPECT-- +call callback +Callback called with parameters: +array ( + 0 => 'param1', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => + array ( + 0 => 'param5', + 1 => 3.14159265359, + 2 => 28032014, + 'key' => 'value', + ), +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => + array ( + 0 => 'param5', + 1 => 3.14159265359, + 2 => 28032014, + 'key' => 'value', + ), + 5 => + DateTime::__set_state(array( + 'date' => '2014-03-28 19:42:15', + 'timezone_type' => 3, + 'timezone' => 'Asia/Yekaterinburg', + )), +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', + 7 => 'param8', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', + 7 => 'param8', + 8 => 'param9', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', + 7 => 'param8', + 8 => 'param9', + 9 => 'param10', +)
\ No newline at end of file diff --git a/tests/php/phpt/variables/016-calling-php-functions.phpt b/tests/php/phpt/variables/016-calling-php-functions.phpt new file mode 100644 index 0000000..46fda6e --- /dev/null +++ b/tests/php/phpt/variables/016-calling-php-functions.phpt @@ -0,0 +1,113 @@ +--TEST-- +calling-php-Callback-functions (__invoke) +--SKIPIF-- +<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?> +--FILEEOF-- +<?php + + +class CallableClass { + public function __invoke() { + echo("Callback called with parameters:\n"); + var_export(func_get_args ()); + } +} + +TestVariables\fnCallback(new CallableClass()); + + +--EXPECT-- +call callback +Callback called with parameters: +array ( + 0 => 'param1', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => + array ( + 0 => 'param5', + 1 => 3.14159265359, + 2 => 28032014, + 'key' => 'value', + ), +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => + array ( + 0 => 'param5', + 1 => 3.14159265359, + 2 => 28032014, + 'key' => 'value', + ), + 5 => + DateTime::__set_state(array( + 'date' => '2014-03-28 19:42:15', + 'timezone_type' => 3, + 'timezone' => 'Asia/Yekaterinburg', + )), +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', + 7 => 'param8', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', + 7 => 'param8', + 8 => 'param9', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', + 7 => 'param8', + 8 => 'param9', + 9 => 'param10', +)
\ No newline at end of file diff --git a/tests/php/phpt/variables/017-calling-php-functions.phpt b/tests/php/phpt/variables/017-calling-php-functions.phpt new file mode 100644 index 0000000..630399a --- /dev/null +++ b/tests/php/phpt/variables/017-calling-php-functions.phpt @@ -0,0 +1,115 @@ +--TEST-- +calling-php-Callback-functions (method of class) +--SKIPIF-- +<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?> +--FILEEOF-- +<?php + + +class someClass { + function someMethod() { + echo("Callback called with parameters:\n"); + var_export(func_get_args ()); + } +} + +$anObject = new someClass(); +$methodVariable = array($anObject, 'someMethod'); +TestVariables\fnCallback($methodVariable); + + +--EXPECT-- +call callback +Callback called with parameters: +array ( + 0 => 'param1', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => + array ( + 0 => 'param5', + 1 => 3.14159265359, + 2 => 28032014, + 'key' => 'value', + ), +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => + array ( + 0 => 'param5', + 1 => 3.14159265359, + 2 => 28032014, + 'key' => 'value', + ), + 5 => + DateTime::__set_state(array( + 'date' => '2014-03-28 19:42:15', + 'timezone_type' => 3, + 'timezone' => 'Asia/Yekaterinburg', + )), +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', + 7 => 'param8', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', + 7 => 'param8', + 8 => 'param9', +)Callback called with parameters: +array ( + 0 => 'param1', + 1 => 'param2', + 2 => 'param3', + 3 => 'param4', + 4 => 'param5', + 5 => 'param6', + 6 => 'param7', + 7 => 'param8', + 8 => 'param9', + 9 => 'param10', +)
\ No newline at end of file diff --git a/tests/php/phpt/variables/018-calling-php-functions.phpt b/tests/php/phpt/variables/018-calling-php-functions.phpt new file mode 100644 index 0000000..1b8bfeb --- /dev/null +++ b/tests/php/phpt/variables/018-calling-php-functions.phpt @@ -0,0 +1,32 @@ +--TEST-- +calling-php-callable +--DESCRIPTION-- +call callable object of class from user space +call method of class from user space +--SKIPIF-- +<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?> +--FILEEOF-- +<?php + + +class CallableClass { + public function __construct($a){ $this->a = $a;} + public function __invoke($b){ echo "CallableClass({$this->a})::__invoke($b)";} + private $a = ""; +} + +class usrspClass { + function __construct($a){ $this->a = $a;} + function someMethod($b) {echo "usrspClass({$this->a})::someMethod($b)";} + private $a = ""; +} + + +TestVariables\fnFromUserSpace2(); + + +--EXPECT-- +2014-03-28 21:22:15 +2014-03-28 21:22:15 +usrspClass(Mount Meru)::someMethod(is in the Arctics) +CallableClass(Arctics around mount Meru)::__invoke(is the birthplace of the Hyperboreans)
\ No newline at end of file diff --git a/tests/php/phpt/variables/readme b/tests/php/phpt/variables/readme index 8162526..a47cb89 100644 --- a/tests/php/phpt/variables/readme +++ b/tests/php/phpt/variables/readme @@ -1 +1,5 @@ tests variables + +TODO: more tests for globals variables +including separate test for $_GET, $_POST, $_COOKIE, $_FILES, $_SERVER, $_REQUEST and $_ENV (Php::GET, Php::POST, Php::COOKIE, Php::FILES, Php::SERVER, Php::REQUEST and Php::ENV) variables. + |