@@ -236,26 +236,25 @@ function throws($function, $exceptionname, $infunction = null) {
236
236
try {
237
237
$ function ();
238
238
} catch (Exception $ e ) {
239
+ $ message = str_replace (array ("\n" , "\r" ), ' ' , $ e ->getMessage ());
239
240
if ($ e instanceof $ exceptionname ) {
240
241
if ($ infunction ) {
241
242
$ trace = $ e ->getTrace ();
242
243
$ function = $ trace [0 ]["function " ];
243
244
if (strcasecmp ($ function , $ infunction ) == 0 ) {
244
245
printf ("OK: Got %s thrown from %s \n" , $ exceptionname , $ infunction );
245
246
} else {
246
- $ message = str_replace (array ("\n" , "\r" ), ' ' , $ e ->getMessage ());
247
247
printf ("ALMOST: Got %s - but was thrown in %s, not %s (%s) \n" , $ exceptionname , $ function , $ infunction , $ message );
248
248
}
249
249
return $ e ->getMessage ();
250
250
}
251
251
printf ("OK: Got %s \n" , $ exceptionname );
252
252
} else {
253
- $ message = str_replace (array ("\n" , "\r" ), ' ' , $ e ->getMessage ());
254
- printf ("ALMOST: Got %s - expected %s: %s \n" , get_class ($ e ), $ exceptionname , $ message );
253
+ printf ("ALMOST: Got %s (%s) - expected %s \n" , get_class ($ e ), $ message , $ exceptionname );
255
254
}
256
255
return $ e ->getMessage ();
257
256
}
258
- echo "FAILED: Expected $ exceptionname thrown! \n" ;
257
+ echo "FAILED: Expected $ exceptionname thrown, but no exception thrown ! \n" ;
259
258
}
260
259
function printServer (MongoDB \Driver \Server $ server )
261
260
{
0 commit comments