]> granicus.if.org Git - php/commitdiff
- Add new test
authorMarcus Boerger <helly@php.net>
Mon, 7 Aug 2006 23:12:59 +0000 (23:12 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 7 Aug 2006 23:12:59 +0000 (23:12 +0000)
tests/classes/ctor_visibility.phpt [new file with mode: 0755]

diff --git a/tests/classes/ctor_visibility.phpt b/tests/classes/ctor_visibility.phpt
new file mode 100755 (executable)
index 0000000..afc823c
--- /dev/null
@@ -0,0 +1,69 @@
+--TEST--
+ZE2 A private constructor cannot be called
+--FILE--
+<?php
+
+class Test
+{
+    function __construct()
+    {
+        echo __METHOD__ . "()\n";
+    }
+}
+
+class Derived extends Test
+{
+       function __construct()
+       {
+        echo __METHOD__ . "()\n";
+               parent::__construct();
+       }
+       
+       static function f()
+       {
+               new Derived;
+       }
+}
+
+Derived::f();
+
+class TestPriv
+{
+    private function __construct()
+    {
+        echo __METHOD__ . "()\n";
+    }
+
+       static function f()
+       {
+               new TestPriv;
+       }
+}
+
+TestPriv::f();
+
+class DerivedPriv extends TestPriv
+{
+       function __construct()
+       {
+        echo __METHOD__ . "()\n";
+               parent::__construct();
+       }
+       
+       static function f()
+       {
+               new DerivedPriv;
+       }
+}
+
+DerivedPriv::f();
+
+?>
+===DONE===
+--EXPECTF--
+Derived::__construct()
+Test::__construct()
+TestPriv::__construct()
+DerivedPriv::__construct()
+
+Fatal error: Cannot call private TestPriv::__constrcut() in %sctor_visibility.php on line %d