@@ -14,7 +14,8 @@ public function testAwaitThrowsExceptionWhenPromiseIsRejectedWithException()
14
14
throw new \Exception ('test ' );
15
15
});
16
16
17
- $ this ->setExpectedException ('Exception ' , 'test ' );
17
+ $ this ->expectException (\Exception::class);
18
+ $ this ->expectExceptionMessage ('test ' );
18
19
React \Async \await ($ promise );
19
20
}
20
21
@@ -28,7 +29,8 @@ public function testAwaitThrowsUnexpectedValueExceptionWhenPromiseIsRejectedWith
28
29
$ reject (false );
29
30
});
30
31
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 ' );
32
34
React \Async \await ($ promise );
33
35
}
34
36
@@ -42,20 +44,20 @@ public function testAwaitThrowsUnexpectedValueExceptionWhenPromiseIsRejectedWith
42
44
$ reject (null );
43
45
});
44
46
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 ' );
46
49
React \Async \await ($ promise );
47
50
}
48
51
49
- /**
50
- * @requires PHP 7
51
- */
52
52
public function testAwaitThrowsErrorWhenPromiseIsRejectedWithError ()
53
53
{
54
54
$ promise = new Promise (function ($ _ , $ reject ) {
55
55
throw new \Error ('Test ' , 42 );
56
56
});
57
57
58
- $ this ->setExpectedException ('Error ' , 'Test ' , 42 );
58
+ $ this ->expectException (\Error::class);
59
+ $ this ->expectExceptionMessage ('Test ' );
60
+ $ this ->expectExceptionCode (42 );
59
61
React \Async \await ($ promise );
60
62
}
61
63
@@ -84,8 +86,8 @@ public function testAwaitReturnsValueWhenPromiseIsFulfilledEvenWhenOtherTimerSto
84
86
85
87
public function testAwaitShouldNotCreateAnyGarbageReferencesForResolvedPromise ()
86
88
{
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 ' );
89
91
}
90
92
91
93
gc_collect_cycles ();
@@ -126,8 +128,8 @@ public function testAwaitShouldNotCreateAnyGarbageReferencesForPromiseRejectedWi
126
128
$ this ->markTestSkipped ('Promises must be rejected with a \Throwable instance since Promise v3 ' );
127
129
}
128
130
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 ' );
131
133
}
132
134
133
135
gc_collect_cycles ();
@@ -144,21 +146,4 @@ public function testAwaitShouldNotCreateAnyGarbageReferencesForPromiseRejectedWi
144
146
145
147
$ this ->assertEquals (0 , gc_collect_cycles ());
146
148
}
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
- }
164
149
}
0 commit comments