@@ -545,6 +545,8 @@ function destroyTemporaryMongoInstance($id = NULL)
545545
546546function severityToString ($ type ) {
547547 switch ($ type ) {
548+ case E_RECOVERABLE_ERROR :
549+ return "E_RECOVERABLE_ERROR " ;
548550 case E_WARNING :
549551 return "E_WARNING " ;
550552 case E_NOTICE :
@@ -590,26 +592,33 @@ function raises($function, $type, $infunction = null) {
590592function throws ($ function , $ exceptionname , $ infunction = null ) {
591593 try {
592594 $ function ();
595+ } catch (Throwable $ e ) {
593596 } catch (Exception $ e ) {
594- $ message = str_replace (array ("\n" , "\r" ), ' ' , $ e ->getMessage ());
595- if ($ e instanceof $ exceptionname ) {
596- if ($ infunction ) {
597- $ trace = $ e ->getTrace ();
598- $ function = $ trace [0 ]["function " ];
599- if (strcasecmp ($ function , $ infunction ) == 0 ) {
600- printf ("OK: Got %s thrown from %s \n" , $ exceptionname , $ infunction );
601- } else {
602- printf ("ALMOST: Got %s - but was thrown in %s, not %s (%s) \n" , $ exceptionname , $ function , $ infunction , $ message );
603- }
604- return $ e ->getMessage ();
597+ }
598+
599+ if ($ e === null ) {
600+ echo "FAILED: Expected $ exceptionname thrown, but no exception thrown! \n" ;
601+ return ;
602+ }
603+
604+ $ message = str_replace (array ("\n" , "\r" ), ' ' , $ e ->getMessage ());
605+ if ($ e instanceof $ exceptionname ) {
606+ if ($ infunction ) {
607+ $ trace = $ e ->getTrace ();
608+ $ function = $ trace [0 ]["function " ];
609+ if (strcasecmp ($ function , $ infunction ) == 0 ) {
610+ printf ("OK: Got %s thrown from %s \n" , $ exceptionname , $ infunction );
611+ } else {
612+ printf ("ALMOST: Got %s - but was thrown in %s, not %s (%s) \n" , $ exceptionname , $ function , $ infunction , $ message );
605613 }
606- printf ("OK: Got %s \n" , $ exceptionname );
607- } else {
608- printf ("ALMOST: Got %s (%s) - expected %s \n" , get_class ($ e ), $ message , $ exceptionname );
614+ return $ e ->getMessage ();
609615 }
610- return $ e ->getMessage ();
616+ printf ("OK: Got %s \n" , $ exceptionname );
617+ } else {
618+ printf ("ALMOST: Got %s (%s) - expected %s \n" , get_class ($ e ), $ message , $ exceptionname );
611619 }
612- echo "FAILED: Expected $ exceptionname thrown, but no exception thrown! \n" ;
620+
621+ return $ e ->getMessage ();
613622}
614623
615624function printServer (Server $ server )
0 commit comments