]> granicus.if.org Git - php/commitdiff
- MFH Add new tests
authorMarcus Boerger <helly@php.net>
Sat, 20 May 2006 09:08:35 +0000 (09:08 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 20 May 2006 09:08:35 +0000 (09:08 +0000)
Zend/tests/catch_002.phpt [new file with mode: 0755]
Zend/tests/catch_003.phpt [new file with mode: 0755]
Zend/tests/catch_004.phpt [new file with mode: 0755]

diff --git a/Zend/tests/catch_002.phpt b/Zend/tests/catch_002.phpt
new file mode 100755 (executable)
index 0000000..11d736a
--- /dev/null
@@ -0,0 +1,33 @@
+--TEST--
+Catching an exception in a constructor
+--FILE--
+<?php
+
+class MyObject
+{
+       function __construct()
+       {
+               throw new Exception();
+               echo __METHOD__ . "() Must not be reached\n";
+       }
+
+       function __destruct()
+       {
+               echo __METHOD__ . "() Must not be called\n";
+       }
+}
+
+try
+{
+       new MyObject();
+}
+catch(Exception $e)
+{
+       echo "Caught\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+Caught
+===DONE===
diff --git a/Zend/tests/catch_003.phpt b/Zend/tests/catch_003.phpt
new file mode 100755 (executable)
index 0000000..414d50f
--- /dev/null
@@ -0,0 +1,38 @@
+--TEST--
+Catching an exception in a constructor fired form a static method
+--FILE--
+<?php
+
+class MyObject
+{
+       function fail()
+       {
+               throw new Exception();
+       }
+
+       function __construct()
+       {
+               self::fail();
+               echo __METHOD__ . "() Must not be reached\n";
+       }
+
+       function __destruct()
+       {
+               echo __METHOD__ . "() Must not be called\n";
+       }
+}
+
+try
+{
+       new MyObject();
+}
+catch(Exception $e)
+{
+       echo "Caught\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+Caught
+===DONE===
diff --git a/Zend/tests/catch_004.phpt b/Zend/tests/catch_004.phpt
new file mode 100755 (executable)
index 0000000..f91da60
--- /dev/null
@@ -0,0 +1,41 @@
+--TEST--
+Catching an exception in a constructor inside a static method
+--FILE--
+<?php
+
+class MyObject
+{
+       function fail()
+       {
+               throw new Exception();
+       }
+
+       function __construct()
+       {
+               self::fail();
+               echo __METHOD__ . "() Must not be reached\n";
+       }
+
+       function __destruct()
+       {
+               echo __METHOD__ . "() Must not be called\n";
+       }
+       
+       function test()
+       {
+               try
+               {
+                       new MyObject();
+               }
+               catch(Exception $e)
+               {
+                       echo "Caught\n";
+               }
+       }
+}
+
+?>
+===DONE===
+--EXPECT--
+Caught
+===DONE===