]> granicus.if.org Git - php/commitdiff
- Add/fix tests
authorMarcus Boerger <helly@php.net>
Fri, 16 Dec 2005 22:19:02 +0000 (22:19 +0000)
committerMarcus Boerger <helly@php.net>
Fri, 16 Dec 2005 22:19:02 +0000 (22:19 +0000)
Zend/tests/bug29210.phpt
Zend/tests/bug32290.phpt
ext/spl/tests/spl_autoload_007.phpt [new file with mode: 0755]
ext/standard/tests/general_functions/bug32647.phpt
tests/classes/bug27504.phpt

index 294685499c6d2f77595f3a3e4a96f41d59ed2d23..16e6e6db162dbd914fe44beb1480c855c0fc240f 100644 (file)
@@ -89,10 +89,14 @@ if (is_callable(array('test_class','test_func4'))) {
 $object = new foo();
 $object->test();
 ?>
---EXPECT--
+--EXPECTF--
 test_func1
 test_func2
+
+Strict Standards: Non-static method test_class::test_func3() canot be called statically, assuming $this from compatible context test_class in %sbug29210.php on line %d
 test_func3
+
+Strict Standards: Non-static method test_class::test_func4() canot be called statically, assuming $this from compatible context test_class in %sbug29210.php on line %d
 test_func4
 test_func1 isn't callable from outside
 test_func2 isn't callable from outside
@@ -100,5 +104,9 @@ test_func3 isn't callable from outside
 test_func4 isn't callable from outside
 test_func1 isn't callable from child
 test_func2
+
+Strict Standards: Non-static method test_class::test_func3() canot be called statically, assuming $this from compatible context foo in %sbug29210.php on line %d
 test_func3 isn't callable from child
+
+Strict Standards: Non-static method test_class::test_func4() canot be called statically, assuming $this from compatible context foo in %sbug29210.php on line %d
 test_func4
index f754275ccff490b103083903b2441a5988932c08..6038da54ba174862bf260766bc613fddcc393180 100755 (executable)
@@ -7,7 +7,31 @@ class TestA
 {
        public function doSomething($i)
        {
-               echo __METHOD__ . "($this)\n";
+               echo __METHOD__ . "($i)\n";
+               return --$i;
+       }
+
+       public function doSomethingThis($i)
+       {
+               echo __METHOD__ . "($i)\n";
+               return --$i;
+       }
+
+       public function doSomethingParent($i)
+       {
+               echo __METHOD__ . "($i)\n";
+               return --$i;
+       }
+
+       public function doSomethingParentThis($i)
+       {
+               echo __METHOD__ . "($i)\n";
+               return --$i;
+       }
+
+       public static function doSomethingStatic($i)
+       {
+               echo __METHOD__ . "($i)\n";
                return --$i;
        }
 }
@@ -16,20 +40,87 @@ class TestB extends TestA
 {
        public function doSomething($i)
        {
-               echo __METHOD__ . "($this)\n";
+               echo __METHOD__ . "($i)\n";
+               $i++;
+               if ($i >= 5) return 5;
+               return call_user_func_array(array("TestA", "doSomething"), array($i));
+       }
+
+       public function doSomethingThis($i)
+       {
+               echo __METHOD__ . "($i)\n";
+               $i++;
+               if ($i >= 5) return 5;
+               return call_user_func_array(array($this, "TestA::doSomethingThis"), array($i));
+       }
+
+       public function doSomethingParent($i)
+       {
+               echo __METHOD__ . "($i)\n";
+               $i++;
+               if ($i >= 5) return 5;
+               return call_user_func_array(array("parent", "doSomethingParent"), array($i));
+       }
+
+       public function doSomethingParentThis($i)
+       {
+               echo __METHOD__ . "($i)\n";
                $i++;
                if ($i >= 5) return 5;
-               return call_user_func_array(array("TestA","doSomething"), array($i));
+               return call_user_func_array(array($this, "parent::doSomethingParentThis"), array($i));
+       }
+
+       public static function doSomethingStatic($i)
+       {
+               echo __METHOD__ . "($i)\n";
+               $i++;
+               if ($i >= 5) return 5;
+               return call_user_func_array(array("TestA", "doSomethingStatic"), array($i));
        }
 }
 
 $x = new TestB();
+echo "===A===\n";
 var_dump($x->doSomething(1));
+echo "\n===B===\n";
+var_dump($x->doSomethingThis(1));
+echo "\n===C===\n";
+var_dump($x->doSomethingParent(1));
+echo "\n===D===\n";
+var_dump($x->doSomethingParentThis(1));
+echo "\n===E===\n";
+var_dump($x->doSomethingStatic(1));
 
 ?>
 ===DONE===
+<?php exit(0); ?>
 --EXPECTF--
-TestB::doSomething(Object id #%d)
-TestA::doSomething(Object id #%d)
+===A===
+TestB::doSomething(1)
+
+Strict Standards: Non-static method TestA::doSomething() canot be called statically, assuming $this from compatible context TestB in %sbug32290.php on line %d
+TestA::doSomething(2)
+int(1)
+
+===B===
+TestB::doSomethingThis(1)
+TestA::doSomethingThis(2)
+int(1)
+
+===C===
+TestB::doSomethingParent(1)
+
+Strict Standards: Non-static method TestA::doSomethingParent() canot be called statically, assuming $this from compatible context TestB in %sbug32290.php on line %d
+TestA::doSomethingParent(2)
+int(1)
+
+===D===
+TestB::doSomethingParentThis(1)
+TestA::doSomethingParentThis(2)
+int(1)
+
+===E===
+TestB::doSomethingStatic(1)
+TestA::doSomethingStatic(2)
 int(1)
 ===DONE===
diff --git a/ext/spl/tests/spl_autoload_007.phpt b/ext/spl/tests/spl_autoload_007.phpt
new file mode 100755 (executable)
index 0000000..40b4b61
--- /dev/null
@@ -0,0 +1,138 @@
+--TEST--
+SPL: spl_autoload() with inaccessible methods
+--INI--
+include_path=.
+--FILE--
+<?php
+
+class MyAutoLoader {
+
+        static protected function noAccess($className) {
+               echo __METHOD__ . "($className)\n";
+        }
+
+        static function autoLoad($className) {
+               echo __METHOD__ . "($className)\n";
+        }
+
+        function dynaLoad($className) {
+               echo __METHOD__ . "($className)\n";
+        }
+}
+
+$obj = new MyAutoLoader;
+
+$funcs = array(
+       'MyAutoLoader::notExist',
+       'MyAutoLoader::noAccess',
+       'MyAutoLoader::autoLoad',
+       'MyAutoLoader::dynaLoad',
+       array('MyAutoLoader', 'notExist'),
+       array('MyAutoLoader', 'noAccess'),
+       array('MyAutoLoader', 'autoLoad'),
+       array('MyAutoLoader', 'dynaLoad'),
+       array($obj, 'notExist'),
+       array($obj, 'noAccess'),
+       array($obj, 'autoLoad'),
+       array($obj, 'dynaLoad'),
+);
+
+foreach($funcs as $idx => $func)
+{
+       if ($idx) echo "\n";
+       try
+       {
+               var_dump($func);
+               spl_autoload_register($func);
+               echo "ok\n";
+       }
+       catch (Exception $e)
+       {
+               echo $e->getMessage() . "\n";
+       }
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+string(22) "MyAutoLoader::notExist"
+Function 'MyAutoLoader::notExist' not found
+
+string(22) "MyAutoLoader::noAccess"
+Function 'MyAutoLoader::noAccess' not callable
+
+string(22) "MyAutoLoader::autoLoad"
+ok
+
+string(22) "MyAutoLoader::dynaLoad"
+Function 'MyAutoLoader::dynaLoad' not callable
+
+array(2) {
+  [0]=>
+  string(12) "MyAutoLoader"
+  [1]=>
+  string(8) "notExist"
+}
+Passed array does not specify an existing static method
+
+array(2) {
+  [0]=>
+  string(12) "MyAutoLoader"
+  [1]=>
+  string(8) "noAccess"
+}
+Passed array does not specify a callable static method
+
+array(2) {
+  [0]=>
+  string(12) "MyAutoLoader"
+  [1]=>
+  string(8) "autoLoad"
+}
+ok
+
+array(2) {
+  [0]=>
+  string(12) "MyAutoLoader"
+  [1]=>
+  string(8) "dynaLoad"
+}
+Passed array specifies a non static method but no object
+
+array(2) {
+  [0]=>
+  object(MyAutoLoader)#%d (0) {
+  }
+  [1]=>
+  string(8) "notExist"
+}
+Passed array does not specify an existing method
+
+array(2) {
+  [0]=>
+  object(MyAutoLoader)#%d (0) {
+  }
+  [1]=>
+  string(8) "noAccess"
+}
+Passed array does not specify a callable method
+
+array(2) {
+  [0]=>
+  object(MyAutoLoader)#%d (0) {
+  }
+  [1]=>
+  string(8) "autoLoad"
+}
+ok
+
+array(2) {
+  [0]=>
+  object(MyAutoLoader)#%d (0) {
+  }
+  [1]=>
+  string(8) "dynaLoad"
+}
+ok
+===DONE===
index ca98f429a735bed2b3127c542c0a4eff7c076396..2e82012077f0ed76a77eb0bfe9c8fe95336219db 100644 (file)
@@ -1,14 +1,14 @@
 --TEST--
 Bug #32647 (Using register_shutdown_function() with invalid callback can crash PHP)
 --INI--
-error_reporting=2047
+error_reporting=4095
 display_errors=1
 --FILE--
 <?php
 
 function foo()
 {
-  echo "joo!\n";
+  echo "foo!\n";
 }
 
 class bar
@@ -23,9 +23,9 @@ register_shutdown_function(array($obj,"some string")); // Invalid
 register_shutdown_function(array(0,""));               // Invalid
 register_shutdown_function(array('bar','foo'));        // Invalid
 register_shutdown_function(array(0,"some string"));    // Invalid
-register_shutdown_function('bar');                     // Valid
+register_shutdown_function('bar');                     // Invalid
 register_shutdown_function('foo');                     // Valid
-register_shutdown_function(array('bar','barfoo'));     // Valid
+register_shutdown_function(array('bar','barfoo'));     // Invalid
 
 $obj = new bar;
 register_shutdown_function(array($obj,'foobar'));      // Invalid
@@ -45,11 +45,13 @@ Warning: register_shutdown_function(): Invalid shutdown callback 'Array' passed
 
 Warning: register_shutdown_function(): Invalid shutdown callback 'Array' passed in %s on line %d
 
-Warning: (Registered shutdown functions) Unable to call bar::foo() - function does not exist in Unknown on line 0
+Strict Standards: Non-static method bar::barfoo() cannot be called statically in %sbug32647.php on line %d
 
-Warning: (Registered shutdown functions) Unable to call bar() - function does not exist in Unknown on line 0
-joo!
-bar!
+Warning: register_shutdown_function(): Invalid shutdown callback 'bar::foobar' passed in %sbug32647.php on line %d
+foo!
+
+Strict Standards: Non-static method bar::barfoo() cannot be called statically in Unknown on line 0
 
-Warning: (Registered shutdown functions) Unable to call bar::foobar() - function does not exist in Unknown on line 0
+Strict Standards: Non-static method bar::barfoo() cannot be called statically in Unknown on line 0
+bar!
 bar!
index 64d68ba8aeb8452ac4538e34f6facfa91650c62d..ca13990c9364dab02cde64f8d2859d57feddb9e2 100644 (file)
@@ -20,5 +20,6 @@ Bug #27504 (call_user_func_array allows calling of private/protected methods)
 --EXPECTF--
 Called function foo:bar(%d)
 
-Fatal error: Call to private method foo::bar() from context '' in %s on line 13
+Warning: call_user_func_array(): First argument is expected to be a valid callback, 'foo::bar' was given in %sbug27504.php on line %d
 
+Fatal error: Call to private method foo::bar() from context '' in %s on line %d