@@ -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,20 +44,20 @@ 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
49- /**
50- * @requires PHP 7
51- */
5252 public function testAwaitThrowsErrorWhenPromiseIsRejectedWithError ()
5353 {
5454 $ promise = new Promise (function ($ _ , $ reject ) {
5555 throw new \Error ('Test ' , 42 );
5656 });
5757
58- $ this ->setExpectedException ('Error ' , 'Test ' , 42 );
58+ $ this ->expectException (\Error::class);
59+ $ this ->expectExceptionMessage ('Test ' );
60+ $ this ->expectExceptionCode (42 );
5961 React \Async \await ($ promise );
6062 }
6163
@@ -84,8 +86,8 @@ public function testAwaitReturnsValueWhenPromiseIsFulfilledEvenWhenOtherTimerSto
8486
8587 public function testAwaitShouldNotCreateAnyGarbageReferencesForResolvedPromise ()
8688 {
87- if (class_exists ('React\Promise\When ' ) && PHP_VERSION_ID >= 50400 ) {
88- $ this ->markTestSkipped ('Not supported on legacy Promise v1 API with PHP 5.4+ ' );
89+ if (class_exists ('React\Promise\When ' )) {
90+ $ this ->markTestSkipped ('Not supported on legacy Promise v1 API ' );
8991 }
9092
9193 gc_collect_cycles ();
@@ -126,8 +128,8 @@ public function testAwaitShouldNotCreateAnyGarbageReferencesForPromiseRejectedWi
126128 $ this ->markTestSkipped ('Promises must be rejected with a \Throwable instance since Promise v3 ' );
127129 }
128130
129- if (class_exists ('React\Promise\When ' ) && PHP_VERSION_ID >= 50400 ) {
130- $ this ->markTestSkipped ('Not supported on legacy Promise v1 API with PHP 5.4+ ' );
131+ if (class_exists ('React\Promise\When ' )) {
132+ $ this ->markTestSkipped ('Not supported on legacy Promise v1 API ' );
131133 }
132134
133135 gc_collect_cycles ();
@@ -144,21 +146,4 @@ public function testAwaitShouldNotCreateAnyGarbageReferencesForPromiseRejectedWi
144146
145147 $ this ->assertEquals (0 , gc_collect_cycles ());
146148 }
147-
148- public function setExpectedException ($ exception , $ exceptionMessage = '' , $ exceptionCode = null )
149- {
150- if (method_exists ($ this , 'expectException ' )) {
151- // PHPUnit 5+
152- $ this ->expectException ($ exception );
153- if ($ exceptionMessage !== '' ) {
154- $ this ->expectExceptionMessage ($ exceptionMessage );
155- }
156- if ($ exceptionCode !== null ) {
157- $ this ->expectExceptionCode ($ exceptionCode );
158- }
159- } else {
160- // legacy PHPUnit 4
161- parent ::setExpectedException ($ exception , $ exceptionMessage , $ exceptionCode );
162- }
163- }
164149}
0 commit comments