felipe Sun, 19 Jul 2009 16:31:43 +0000 URL: http://svn.php.net/viewvc?view=revision&revision=284379
Changed paths: A php/php-src/branches/PHP_5_3/Zend/tests/call_user_func_001.phpt A php/php-src/branches/PHP_5_3/Zend/tests/call_user_func_002.phpt A php/php-src/branches/PHP_5_3/Zend/tests/call_user_func_003.phpt A php/php-src/trunk/Zend/tests/call_user_func_001.phpt A php/php-src/trunk/Zend/tests/call_user_func_002.phpt A php/php-src/trunk/Zend/tests/call_user_func_003.phpt Log: - New tests Added: php/php-src/branches/PHP_5_3/Zend/tests/call_user_func_001.phpt =================================================================== --- php/php-src/branches/PHP_5_3/Zend/tests/call_user_func_001.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/Zend/tests/call_user_func_001.phpt 2009-07-19 16:31:43 UTC (rev 284379) @@ -0,0 +1,35 @@ +--TEST-- +Testing call_user_func inside namespace +--FILE-- +<?php + +namespace testing { + function foobar($str) { + var_dump($str); + } + + abstract class bar { + protected function prot($str) { + print "Shouldn't be called!\n"; + } + } + class foo extends bar { + private function priv($str) { + print "Shouldn't be called!\n"; + } + } + + call_user_func(__NAMESPACE__ .'\foobar', 'foobar'); + + $class = __NAMESPACE__ .'\foo'; + call_user_func(array(new $class, 'priv'), 'foobar'); + call_user_func(array(new $class, 'prot'), 'foobar'); +} + +?> +--EXPECTF-- +%string|unicode%(6) "foobar" + +Warning: call_user_func() expects parameter 1 to be a valid callback, cannot access private method testing\foo::priv() in %s on line %d + +Warning: call_user_func() expects parameter 1 to be a valid callback, cannot access protected method testing\foo::prot() in %s on line %d Property changes on: php/php-src/branches/PHP_5_3/Zend/tests/call_user_func_001.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Added: php/php-src/branches/PHP_5_3/Zend/tests/call_user_func_002.phpt =================================================================== --- php/php-src/branches/PHP_5_3/Zend/tests/call_user_func_002.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/Zend/tests/call_user_func_002.phpt 2009-07-19 16:31:43 UTC (rev 284379) @@ -0,0 +1,29 @@ +--TEST-- +Testing call_user_func() with autoload and passing invalid params +--FILE-- +<?php + +function __autoload($class) { + var_dump($class); +} + +call_user_func(array('foo', 'bar')); +call_user_func(array('', 'bar')); +call_user_func(array($foo, 'bar')); +call_user_func(array($foo, '')); + +?> +--EXPECTF-- +%unicode|string%(3) "foo" + +Warning: call_user_func() expects parameter 1 to be a valid callback, class 'foo' not found in %s on line %d + +Warning: call_user_func() expects parameter 1 to be a valid callback, class '' not found in %s on line %d + +Notice: Undefined variable: foo in %s on line %d + +Warning: call_user_func() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in %s on line %d + +Notice: Undefined variable: foo in %s on line %d + +Warning: call_user_func() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in %s on line %d Property changes on: php/php-src/branches/PHP_5_3/Zend/tests/call_user_func_002.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Added: php/php-src/branches/PHP_5_3/Zend/tests/call_user_func_003.phpt =================================================================== --- php/php-src/branches/PHP_5_3/Zend/tests/call_user_func_003.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/Zend/tests/call_user_func_003.phpt 2009-07-19 16:31:43 UTC (rev 284379) @@ -0,0 +1,31 @@ +--TEST-- +Testing call_user_func() with closures +--FILE-- +<?php + +$foo = function() { + static $instance; + + if (is_null($instance)) { + $instance = function () { + return 'OK!'; + }; + } + + return $instance; +}; + +var_dump(call_user_func(array($foo, '__invoke'))->__invoke()); +var_dump(call_user_func(function() use (&$foo) { return $foo; }, '__invoke')); + +?> +--EXPECTF-- +%unicode|string%(3) "OK!" +object(Closure)#%d (1) { + [%u|b%"static"]=> + array(1) { + [%u|b%"instance"]=> + object(Closure)#%d (0) { + } + } +} Property changes on: php/php-src/branches/PHP_5_3/Zend/tests/call_user_func_003.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Added: php/php-src/trunk/Zend/tests/call_user_func_001.phpt =================================================================== --- php/php-src/trunk/Zend/tests/call_user_func_001.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/call_user_func_001.phpt 2009-07-19 16:31:43 UTC (rev 284379) @@ -0,0 +1,35 @@ +--TEST-- +Testing call_user_func inside namespace +--FILE-- +<?php + +namespace testing { + function foobar($str) { + var_dump($str); + } + + abstract class bar { + protected function prot($str) { + print "Shouldn't be called!\n"; + } + } + class foo extends bar { + private function priv($str) { + print "Shouldn't be called!\n"; + } + } + + call_user_func(__NAMESPACE__ .'\foobar', 'foobar'); + + $class = __NAMESPACE__ .'\foo'; + call_user_func(array(new $class, 'priv'), 'foobar'); + call_user_func(array(new $class, 'prot'), 'foobar'); +} + +?> +--EXPECTF-- +%string|unicode%(6) "foobar" + +Warning: call_user_func() expects parameter 1 to be a valid callback, cannot access private method testing\foo::priv() in %s on line %d + +Warning: call_user_func() expects parameter 1 to be a valid callback, cannot access protected method testing\foo::prot() in %s on line %d Property changes on: php/php-src/trunk/Zend/tests/call_user_func_001.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Added: php/php-src/trunk/Zend/tests/call_user_func_002.phpt =================================================================== --- php/php-src/trunk/Zend/tests/call_user_func_002.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/call_user_func_002.phpt 2009-07-19 16:31:43 UTC (rev 284379) @@ -0,0 +1,29 @@ +--TEST-- +Testing call_user_func() with autoload and passing invalid params +--FILE-- +<?php + +function __autoload($class) { + var_dump($class); +} + +call_user_func(array('foo', 'bar')); +call_user_func(array('', 'bar')); +call_user_func(array($foo, 'bar')); +call_user_func(array($foo, '')); + +?> +--EXPECTF-- +%unicode|string%(3) "foo" + +Warning: call_user_func() expects parameter 1 to be a valid callback, class 'foo' not found in %s on line %d + +Warning: call_user_func() expects parameter 1 to be a valid callback, class '' not found in %s on line %d + +Notice: Undefined variable: foo in %s on line %d + +Warning: call_user_func() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in %s on line %d + +Notice: Undefined variable: foo in %s on line %d + +Warning: call_user_func() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in %s on line %d Property changes on: php/php-src/trunk/Zend/tests/call_user_func_002.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Added: php/php-src/trunk/Zend/tests/call_user_func_003.phpt =================================================================== --- php/php-src/trunk/Zend/tests/call_user_func_003.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/call_user_func_003.phpt 2009-07-19 16:31:43 UTC (rev 284379) @@ -0,0 +1,31 @@ +--TEST-- +Testing call_user_func() with closures +--FILE-- +<?php + +$foo = function() { + static $instance; + + if (is_null($instance)) { + $instance = function () { + return 'OK!'; + }; + } + + return $instance; +}; + +var_dump(call_user_func(array($foo, '__invoke'))->__invoke()); +var_dump(call_user_func(function() use (&$foo) { return $foo; }, '__invoke')); + +?> +--EXPECTF-- +%unicode|string%(3) "OK!" +object(Closure)#%d (1) { + [%u|b%"static"]=> + array(1) { + [%u|b%"instance"]=> + object(Closure)#%d (0) { + } + } +} Property changes on: php/php-src/trunk/Zend/tests/call_user_func_003.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php