]> granicus.if.org Git - php/commitdiff
- New tests for new feature
authorFelipe Pena <felipe@php.net>
Tue, 14 Jun 2011 02:05:37 +0000 (02:05 +0000)
committerFelipe Pena <felipe@php.net>
Tue, 14 Jun 2011 02:05:37 +0000 (02:05 +0000)
Zend/tests/indirect_call_array_001.phpt [new file with mode: 0644]
Zend/tests/indirect_call_array_002.phpt [new file with mode: 0644]
Zend/tests/indirect_call_array_003.phpt [new file with mode: 0644]
Zend/tests/indirect_call_array_004.phpt [new file with mode: 0644]

diff --git a/Zend/tests/indirect_call_array_001.phpt b/Zend/tests/indirect_call_array_001.phpt
new file mode 100644 (file)
index 0000000..56675b8
--- /dev/null
@@ -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
diff --git a/Zend/tests/indirect_call_array_002.phpt b/Zend/tests/indirect_call_array_002.phpt
new file mode 100644 (file)
index 0000000..013fa55
--- /dev/null
@@ -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
diff --git a/Zend/tests/indirect_call_array_003.phpt b/Zend/tests/indirect_call_array_003.phpt
new file mode 100644 (file)
index 0000000..498c580
--- /dev/null
@@ -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) {
+}
+
diff --git a/Zend/tests/indirect_call_array_004.phpt b/Zend/tests/indirect_call_array_004.phpt
new file mode 100644 (file)
index 0000000..350f720
--- /dev/null
@@ -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