@@ -14,7 +14,8 @@ public function testAwaitThrowsExceptionWhenPromiseIsRejectedWithException()
1414 throw new \Exception ('test ' );
1515 });
1616
17- $ this ->setExpectedException ('Exception ' , 'test ' );
17+ $ this ->expectException (\Exception::class);
18+ $ this ->expectExceptionMessage ('test ' );
1819 React \Async \await ($ promise );
1920 }
2021
@@ -28,7 +29,8 @@ public function testAwaitThrowsUnexpectedValueExceptionWhenPromiseIsRejectedWith
2829 $ reject (false );
2930 });
3031
31- $ this ->setExpectedException ('UnexpectedValueException ' , 'Promise rejected with unexpected value of type bool ' );
32+ $ this ->expectException (\UnexpectedValueException::class);
33+ $ this ->expectExceptionMessage ('Promise rejected with unexpected value of type bool ' );
3234 React \Async \await ($ promise );
3335 }
3436
@@ -42,7 +44,8 @@ public function testAwaitThrowsUnexpectedValueExceptionWhenPromiseIsRejectedWith
4244 $ reject (null );
4345 });
4446
45- $ this ->setExpectedException ('UnexpectedValueException ' , 'Promise rejected with unexpected value of type NULL ' );
47+ $ this ->expectException (\UnexpectedValueException::class);
48+ $ this ->expectExceptionMessage ('Promise rejected with unexpected value of type NULL ' );
4649 React \Async \await ($ promise );
4750 }
4851
@@ -52,7 +55,9 @@ public function testAwaitThrowsErrorWhenPromiseIsRejectedWithError()
5255 throw new \Error ('Test ' , 42 );
5356 });
5457
55- $ this ->setExpectedException ('Error ' , 'Test ' , 42 );
58+ $ this ->expectException (\Error::class);
59+ $ this ->expectExceptionMessage ('Test ' );
60+ $ this ->expectExceptionCode (42 );
5661 React \Async \await ($ promise );
5762 }
5863
@@ -141,21 +146,4 @@ public function testAwaitShouldNotCreateAnyGarbageReferencesForPromiseRejectedWi
141146
142147 $ this ->assertEquals (0 , gc_collect_cycles ());
143148 }
144-
145- public function setExpectedException ($ exception , $ exceptionMessage = '' , $ exceptionCode = null )
146- {
147- if (method_exists ($ this , 'expectException ' )) {
148- // PHPUnit 5+
149- $ this ->expectException ($ exception );
150- if ($ exceptionMessage !== '' ) {
151- $ this ->expectExceptionMessage ($ exceptionMessage );
152- }
153- if ($ exceptionCode !== null ) {
154- $ this ->expectExceptionCode ($ exceptionCode );
155- }
156- } else {
157- // legacy PHPUnit 4
158- parent ::setExpectedException ($ exception , $ exceptionMessage , $ exceptionCode );
159- }
160- }
161149}
0 commit comments