diff --git a/examples/call3.php b/examples/call3.php new file mode 100644 index 00000000..086431c2 --- /dev/null +++ b/examples/call3.php @@ -0,0 +1,21 @@ +f($a); + $c->f($b); + + var_dump($a, $b); +} + diff --git a/tests/core/classes/__call_001.phpt b/tests/core/classes/__call_001.phpt new file mode 100644 index 00000000..84902429 --- /dev/null +++ b/tests/core/classes/__call_001.phpt @@ -0,0 +1,41 @@ +--TEST-- +ZE2 __call() +--FILE-- +x; + } +} + +function main() { + $foo = new Caller(); + $a = $foo->test(1, '2', 3.4, true); + var_dump($a); +} +?> +--EXPECT-- +Method test called: +array(4) { + [0]=> + int(1) + [1]=> + string(1) "2" + [2]=> + float(3.4) + [3]=> + bool(true) +} +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} diff --git a/tests/core/classes/__call_002.phpt b/tests/core/classes/__call_002.phpt new file mode 100644 index 00000000..ecf89d24 --- /dev/null +++ b/tests/core/classes/__call_002.phpt @@ -0,0 +1,20 @@ +--TEST-- +ZE2 __call() signature check +--SKIPIF-- + +--FILE-- +test(); +} + +?> +--EXPECTF-- +Fatal error: Method Test::__call() must take exactly 2 arguments in %s__call_002.php on line %d diff --git a/tests/core/classes/__call_003.phpt b/tests/core/classes/__call_003.phpt new file mode 100644 index 00000000..997740a6 --- /dev/null +++ b/tests/core/classes/__call_003.phpt @@ -0,0 +1,31 @@ +--TEST-- +Force pass-by-reference to __call (Incompatible) +--FILE-- +f($a); + $c->f($b); + + var_dump($a, $b); +} +?> +--EXPECT-- +array(1) { + [0]=> + string(7) "changed" +} +array(1) { + [0]=> + string(7) "changed" +} diff --git a/tests/core/classes/__call_004.phpt b/tests/core/classes/__call_004.phpt new file mode 100644 index 00000000..3dc2d609 --- /dev/null +++ b/tests/core/classes/__call_004.phpt @@ -0,0 +1,44 @@ +--TEST-- +When __call() is invoked via ::, ensure current scope's __call() is favoured over the specified class's __call(). +--SKIPIF-- + +--FILE-- +test(); +} +?> +--EXPECT-- +In B::__call(test1, array(1,a)) +object(B)#1 (0) { +} +In B::__call(test2, array(1,a)) +object(B)#1 (0) { +} +In B::__call(test3, array(1,a)) +object(B)#1 (0) { +} +In B::__call(test4, array(1,a)) +object(B)#1 (0) { +} diff --git a/tests/core/classes/__call_005.phpt b/tests/core/classes/__call_005.phpt new file mode 100644 index 00000000..589d0f5f --- /dev/null +++ b/tests/core/classes/__call_005.phpt @@ -0,0 +1,40 @@ +--TEST-- +When __call() is invoked via ::, ensure private implementation of __call() in superclass is accessed without error. +--SKIPIF-- + +--FILE-- +test(); +} +?> +--EXPECTF-- +Warning: The magic method A::__call() must have public visibility in %s__call_005.php on line 3 +In A::__call(test1, array(1,a)) +object(B)#1 (0) { +} +In A::__call(test2, array(1,a)) +object(B)#1 (0) { +} +In A::__call(test3, array(1,a)) +object(B)#1 (0) { +} +In A::__call(test4, array(1,a)) +object(B)#1 (0) { +} diff --git a/tests/core/classes/ctor_dtor.phpt b/tests/core/classes/ctor_dtor.phpt new file mode 100644 index 00000000..bcd73430 --- /dev/null +++ b/tests/core/classes/ctor_dtor.phpt @@ -0,0 +1,39 @@ +--TEST-- +ZE2 The new constructor/destructor is called +--FILE-- +__construct(); + unset($t); + $t = new late(); + //unset($t); delay to end of script + + echo "Done\n"; +} +?> +--EXPECT-- +early::__construct +early::__construct +early::__destruct +late::__construct +Done +late::__destruct