@@ -30,23 +30,23 @@ public function throws($throws = null, $message = false): self
3030
3131 try {
3232 call_user_func ($ this ->actual );
33- } catch (Throwable $ e ) {
33+ } catch (Throwable $ exception ) {
3434 if (!$ throws ) {
3535 return $ this ; // it throws
3636 }
3737
38- $ actualThrows = get_class ($ e );
39- $ actualMessage = $ e ->getMessage ();
38+ $ actualThrows = get_class ($ exception );
39+ $ actualMessage = $ exception ->getMessage ();
4040
41- Assert::assertSame ($ throws , $ actualThrows , " exception ' $ throws ' was expected, but ' $ actualThrows ' was thrown " );
41+ Assert::assertSame ($ throws , $ actualThrows , sprintf ( ' exception \' %s \ ' was expected, but \' %s \ ' was thrown ' , $ throws , $ actualThrows ) );
4242
4343 if ($ message ) {
44- Assert::assertSame ($ message , $ actualMessage , " exception message ' $ message ' was expected, but ' $ actualMessage ' was received " );
44+ Assert::assertSame ($ message , $ actualMessage , sprintf ( ' exception message \' %s \ ' was expected, but \' %s \ ' was received ' , $ message , $ actualMessage ) );
4545 }
4646 }
4747
48- if (!isset ($ e )) {
49- throw new ExpectationFailedException (" exception ' $ throws ' was not thrown as expected " );
48+ if (!isset ($ exception )) {
49+ throw new ExpectationFailedException (sprintf ( ' exception \' %s \ ' was not thrown as expected ' , $ throws ) );
5050 }
5151
5252 return $ this ;
@@ -66,23 +66,24 @@ public function doesNotThrow($throws = null, $message = false): self
6666
6767 try {
6868 call_user_func ($ this ->actual );
69- } catch (Throwable $ e ) {
69+ } catch (Throwable $ exception ) {
7070 if (!$ throws ) {
7171 throw new ExpectationFailedException ('exception was not expected to be thrown ' );
7272 }
7373
74- $ actualThrows = get_class ($ e );
75- $ actualMessage = $ e ->getMessage ();
74+ $ actualThrows = get_class ($ exception );
75+ $ actualMessage = $ exception ->getMessage ();
7676
7777 if ($ throws !== $ actualThrows ) {
7878 return $ this ;
7979 }
80+
8081 if (!$ message ) {
81- throw new ExpectationFailedException (" exception ' $ throws ' was not expected to be thrown " );
82+ throw new ExpectationFailedException (sprintf ( ' exception \' %s \ ' was not expected to be thrown ' , $ throws ) );
8283 }
8384
8485 if ($ message === $ actualMessage ) {
85- throw new ExpectationFailedException (" exception ' $ throws ' with message ' $ message ' was not expected to be thrown " );
86+ throw new ExpectationFailedException (sprintf ( ' exception \' %s \ ' with message \' %s \ ' was not expected to be thrown ' , $ throws , $ message ) );
8687 }
8788 }
8889
0 commit comments