felipe Tue, 14 Jun 2011 02:05:37 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=312133
Log:
- New tests for new feature
Changed paths:
A php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_001.phpt
A php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_002.phpt
A php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_003.phpt
A php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_004.phpt
A php/php-src/trunk/Zend/tests/indirect_call_array_001.phpt
A php/php-src/trunk/Zend/tests/indirect_call_array_002.phpt
A php/php-src/trunk/Zend/tests/indirect_call_array_003.phpt
A php/php-src/trunk/Zend/tests/indirect_call_array_004.phpt
Added: php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_001.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_001.phpt
(rev 0)
+++ php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_001.phpt
2011-06-14 02:05:37 UTC (rev 312133)
@@ -0,0 +1,11 @@
+--TEST--
+Indirect method call by array - Invalid class name
+--FILE--
+<?php
+
+$arr = array('a', 'b');
+$arr();
+
+?>
+--EXPECTF--
+Fatal error: Class 'a' not found in %s on line %d
Added: php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_002.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_002.phpt
(rev 0)
+++ php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_002.phpt
2011-06-14 02:05:37 UTC (rev 312133)
@@ -0,0 +1,11 @@
+--TEST--
+Indirect method call by array - Invalid method name
+--FILE--
+<?php
+
+$arr = array('stdclass', 'b');
+$arr();
+
+?>
+--EXPECTF--
+Fatal error: Call to undefined method stdClass::b() in %s on line %d
Added: php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_003.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_003.phpt
(rev 0)
+++ php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_003.phpt
2011-06-14 02:05:37 UTC (rev 312133)
@@ -0,0 +1,38 @@
+--TEST--
+Indirect method call by array - Calling __call() and __callStatic()
+--FILE--
+<?php
+
+class foo {
+ public function __call($a, $b) {
+ printf("From %s:\n", __METHOD__);
+ var_dump($a);
+ var_dump($this);
+ }
+ static public function __callStatic($a, $b) {
+ printf("From %s:\n", __METHOD__);
+ var_dump($a);
+ var_dump($this);
+ }
+}
+
+$arr = array('foo', 'abc');
+$arr();
+
+$foo = new foo;
+$arr = array($foo, 'abc');
+$arr();
+
+
+?>
+--EXPECTF--
+From foo::__callStatic:
+string(3) "abc"
+
+Notice: Undefined variable: this in %s on line %d
+NULL
+From foo::__call:
+string(3) "abc"
+object(foo)#%d (0) {
+}
+
Added: php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_004.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_004.phpt
(rev 0)
+++ php/php-src/branches/PHP_5_4/Zend/tests/indirect_call_array_004.phpt
2011-06-14 02:05:37 UTC (rev 312133)
@@ -0,0 +1,71 @@
+--TEST--
+Indirect method call by array - Testing exception and method magics
+--FILE--
+<?php
+
+class foo {
+ static public function abc() {
+ throw new Exception('foo');
+ }
+ public function __call($a, $b) {
+ printf("From %s:\n", __METHOD__);
+ throw new Exception($a);
+ }
+ static public function __callStatic($a, $b) {
+ printf("From %s:\n", __METHOD__);
+ throw new Exception($a);
+ }
+}
+
+
+$arr = array('foo', 'abc');
+
+try {
+ $arr();
+}
+catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+$arr = array('foo', '123');
+
+try {
+ $arr();
+}
+catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+
+echo "------\n";
+
+$foo = new foo;
+$arr = array($foo, 'abc');
+
+try {
+ $arr();
+}
+catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+
+$foo = new foo;
+$arr = array($foo, '123');
+
+try {
+ $arr();
+}
+catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECTF--
+foo
+From foo::__callStatic:
+123
+------
+foo
+From foo::__call:
+123
Added: php/php-src/trunk/Zend/tests/indirect_call_array_001.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/indirect_call_array_001.phpt
(rev 0)
+++ php/php-src/trunk/Zend/tests/indirect_call_array_001.phpt 2011-06-14
02:05:37 UTC (rev 312133)
@@ -0,0 +1,11 @@
+--TEST--
+Indirect method call by array - Invalid class name
+--FILE--
+<?php
+
+$arr = array('a', 'b');
+$arr();
+
+?>
+--EXPECTF--
+Fatal error: Class 'a' not found in %s on line %d
Added: php/php-src/trunk/Zend/tests/indirect_call_array_002.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/indirect_call_array_002.phpt
(rev 0)
+++ php/php-src/trunk/Zend/tests/indirect_call_array_002.phpt 2011-06-14
02:05:37 UTC (rev 312133)
@@ -0,0 +1,11 @@
+--TEST--
+Indirect method call by array - Invalid method name
+--FILE--
+<?php
+
+$arr = array('stdclass', 'b');
+$arr();
+
+?>
+--EXPECTF--
+Fatal error: Call to undefined method stdClass::b() in %s on line %d
Added: php/php-src/trunk/Zend/tests/indirect_call_array_003.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/indirect_call_array_003.phpt
(rev 0)
+++ php/php-src/trunk/Zend/tests/indirect_call_array_003.phpt 2011-06-14
02:05:37 UTC (rev 312133)
@@ -0,0 +1,38 @@
+--TEST--
+Indirect method call by array - Calling __call() and __callStatic()
+--FILE--
+<?php
+
+class foo {
+ public function __call($a, $b) {
+ printf("From %s:\n", __METHOD__);
+ var_dump($a);
+ var_dump($this);
+ }
+ static public function __callStatic($a, $b) {
+ printf("From %s:\n", __METHOD__);
+ var_dump($a);
+ var_dump($this);
+ }
+}
+
+$arr = array('foo', 'abc');
+$arr();
+
+$foo = new foo;
+$arr = array($foo, 'abc');
+$arr();
+
+
+?>
+--EXPECTF--
+From foo::__callStatic:
+string(3) "abc"
+
+Notice: Undefined variable: this in %s on line %d
+NULL
+From foo::__call:
+string(3) "abc"
+object(foo)#%d (0) {
+}
+
Added: php/php-src/trunk/Zend/tests/indirect_call_array_004.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/indirect_call_array_004.phpt
(rev 0)
+++ php/php-src/trunk/Zend/tests/indirect_call_array_004.phpt 2011-06-14
02:05:37 UTC (rev 312133)
@@ -0,0 +1,71 @@
+--TEST--
+Indirect method call by array - Testing exception and method magics
+--FILE--
+<?php
+
+class foo {
+ static public function abc() {
+ throw new Exception('foo');
+ }
+ public function __call($a, $b) {
+ printf("From %s:\n", __METHOD__);
+ throw new Exception($a);
+ }
+ static public function __callStatic($a, $b) {
+ printf("From %s:\n", __METHOD__);
+ throw new Exception($a);
+ }
+}
+
+
+$arr = array('foo', 'abc');
+
+try {
+ $arr();
+}
+catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+$arr = array('foo', '123');
+
+try {
+ $arr();
+}
+catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+
+echo "------\n";
+
+$foo = new foo;
+$arr = array($foo, 'abc');
+
+try {
+ $arr();
+}
+catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+
+$foo = new foo;
+$arr = array($foo, '123');
+
+try {
+ $arr();
+}
+catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECTF--
+foo
+From foo::__callStatic:
+123
+------
+foo
+From foo::__call:
+123
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php