com php-src: Added more indirect call tests, remove invalid test: Zend/tests/call_static_005.phpt Zend/tests/indire ct_call_string_001.phpt
Zend/tests/indirect_c all_string_002.phpt

From: Date: Fri, 26 Jun 2015 00:46:28 +0000
Subject: com php-src: Added more indirect call tests, remove invalid test: Zend/tests/call_static_005.phpt Zend/tests/indire ct_call_string_001.phpt
Zend/tests/indirect_c all_string_002.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-87538@lists.php.net to get a copy of this message
Commit: bc0df38e887e362761737227dd3c7b9b252e946c Author: Aaron Piotrowski <aaron@trowski.com> Thu, 25 Jun 2015 19:46:28 -0500 Parents: ba67fc221890aaa395912aefebb96155afe671c1 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bc0df38e887e362761737227dd3c7b9b252e946c Log: Added more indirect call tests, remove invalid test Changed paths: D Zend/tests/call_static_005.phpt A Zend/tests/indirect_call_string_001.phpt A Zend/tests/indirect_call_string_002.phpt Diff: diff --git a/Zend/tests/call_static_005.phpt b/Zend/tests/call_static_005.phpt deleted file mode 100644 index 3b8d346..0000000 --- a/Zend/tests/call_static_005.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Invalid method name in dynamic static call ---FILE-- -<?php - -class foo { - static function __callstatic($a, $b) { - var_dump($a); - } -} - -try { - $a = 'foo::'; - $a(); -} catch (Error $e) { - echo $e->getMessage(); -} - -?> ---EXPECT-- -Call to undefined function foo::() diff --git a/Zend/tests/indirect_call_string_001.phpt b/Zend/tests/indirect_call_string_001.phpt new file mode 100644 index 0000000..4493d6b --- /dev/null +++ b/Zend/tests/indirect_call_string_001.phpt @@ -0,0 +1,42 @@ +--TEST-- +Indirect call with 'Class::method' syntax with class in namespace +--FILE-- +<?php +namespace TestNamespace +{ + class TestClass + { + public static function staticMethod() + { + echo "Static method called!\n"; + } + + public static function staticMethodWithArgs($arg1, $arg2, $arg3) + { + printf("Static method called with args: %s, %s, %s\n", $arg1, $arg2, $arg3); + } + } + + // Test basic call using Class::method syntax. + $callback = 'TestNamespace\TestClass::staticMethod'; + $callback(); + + // Case should not matter. + $callback = 'testnamespace\testclass::staticmethod'; + $callback(); + + $args = ['arg1', 'arg2', 'arg3']; + $callback = 'TestNamespace\TestClass::staticMethodWithArgs'; + + // Test call with args. + $callback($args[0], $args[1], $args[2]); + + // Test call with splat operator. + $callback(...$args); +} +?> +--EXPECT-- +Static method called! +Static method called! +Static method called with args: arg1, arg2, arg3 +Static method called with args: arg1, arg2, arg3 diff --git a/Zend/tests/indirect_call_string_002.phpt b/Zend/tests/indirect_call_string_002.phpt new file mode 100644 index 0000000..40c913a --- /dev/null +++ b/Zend/tests/indirect_call_string_002.phpt @@ -0,0 +1,59 @@ +--TEST-- +Indirect call with empty class and/or method name. +--FILE-- +<?php +class TestClass +{ + public static function __callStatic($method, array $args) + { + var_dump($method); + } +} + +// Test call using array syntax +$callback = ['TestClass', '']; +$callback(); + +// Test call using Class::method syntax. +$callback = 'TestClass::'; +$callback(); + +// Test array syntax with empty class name +$callback = '::method'; +try { + $callback(); +} catch (Error $e) { + echo $e->getMessage() . "\n"; +} + +// Test Class::method syntax with empty class name +$callback = '::method'; +try { + $callback(); +} catch (Error $e) { + echo $e->getMessage() . "\n"; +} + +// Test array syntax with empty class and method name +$callback = ['', '']; +try { + $callback(); +} catch (Error $e) { + echo $e->getMessage() . "\n"; +} + +// Test Class::method syntax with empty class and method name +$callback = '::'; +try { + $callback(); +} catch (Error $e) { + echo $e->getMessage() . "\n"; +} +?> +--EXPECT-- +string(0) "" +string(0) "" +Class '' not found +Class '' not found +Class '' not found +Class '' not found

« previous php.cvs (#87538) next »