@@ -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,7 +44,8 @@ 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
@@ -52,7 +55,9 @@ public function testAwaitThrowsErrorWhenPromiseIsRejectedWithError()
52
55
throw new \Error ('Test ' , 42 );
53
56
});
54
57
55
- $ this ->setExpectedException ('Error ' , 'Test ' , 42 );
58
+ $ this ->expectException (\Error::class);
59
+ $ this ->expectExceptionMessage ('Test ' );
60
+ $ this ->expectExceptionCode (42 );
56
61
React \Async \await ($ promise );
57
62
}
58
63
@@ -141,21 +146,4 @@ public function testAwaitShouldNotCreateAnyGarbageReferencesForPromiseRejectedWi
141
146
142
147
$ this ->assertEquals (0 , gc_collect_cycles ());
143
148
}
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
- }
161
149
}
0 commit comments