File tree Expand file tree Collapse file tree 4 files changed +11
-34
lines changed Expand file tree Collapse file tree 4 files changed +11
-34
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,8 @@ public function connect($uri)
180
180
// either close active connection or cancel pending connection attempt
181
181
$ connecting ->then (function (ConnectionInterface $ stream ) {
182
182
$ stream ->close ();
183
+ }, function () {
184
+ // ignore to avoid reporting unhandled rejection
183
185
});
184
186
$ connecting ->cancel ();
185
187
});
Original file line number Diff line number Diff line change @@ -152,6 +152,8 @@ public function testCreateWithInvalidHostDoesNotConnect()
152
152
$ promise = $ this ->client ->connect (str_repeat ('a ' , '256 ' ) . ':80 ' );
153
153
154
154
$ this ->assertInstanceOf ('\React\Promise\PromiseInterface ' , $ promise );
155
+
156
+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
155
157
}
156
158
157
159
public function testCreateWithInvalidPortDoesNotConnect ()
@@ -163,6 +165,8 @@ public function testCreateWithInvalidPortDoesNotConnect()
163
165
$ promise = $ this ->client ->connect ('some-random-site:some-random-port ' );
164
166
165
167
$ this ->assertInstanceOf ('\React\Promise\PromiseInterface ' , $ promise );
168
+
169
+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
166
170
}
167
171
168
172
public function testConnectorRejectsWillRejectConnection ()
@@ -561,6 +565,9 @@ public function testConnectionErrorShouldNotCreateGarbageCycles()
561
565
gc_collect_cycles (); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
562
566
563
567
$ promise = $ this ->client ->connect ('google.com:80 ' );
568
+
569
+ $ promise ->then (null , $ this ->expectCallableOnce ()); // avoid reporting unhandled rejection
570
+
564
571
$ deferred ->reject (new \RuntimeException ());
565
572
unset($ deferred , $ promise );
566
573
Original file line number Diff line number Diff line change 7
7
use Clue \React \Socks \Server ;
8
8
use React \EventLoop \Loop ;
9
9
use React \Promise \Promise ;
10
+ use React \Socket \ConnectionInterface ;
10
11
use React \Socket \Connector ;
11
12
use React \Socket \SecureConnector ;
12
13
use React \Socket \SocketServer ;
@@ -506,9 +507,7 @@ public function testSecureConnectorInvalidUnboundPortTimeout()
506
507
507
508
private function assertResolveStream ($ promise )
508
509
{
509
- $ this ->expectPromiseResolve ($ promise );
510
-
511
- $ promise ->then (function ($ stream ) {
510
+ $ promise = $ promise ->then (function (ConnectionInterface $ stream ) {
512
511
$ stream ->close ();
513
512
});
514
513
@@ -517,8 +516,6 @@ private function assertResolveStream($promise)
517
516
518
517
private function assertRejectPromise ($ promise , $ message = null , $ code = null )
519
518
{
520
- $ this ->expectPromiseReject ($ promise );
521
-
522
519
if (method_exists ($ this , 'expectException ' )) {
523
520
$ this ->expectException ('Exception ' );
524
521
if ($ message !== null ) {
Original file line number Diff line number Diff line change @@ -55,35 +55,6 @@ protected function createCallableMock()
55
55
return $ this ->getMockBuilder ('stdClass ' )->setMethods (array ('__invoke ' ))->getMock ();
56
56
}
57
57
58
- protected function expectPromiseResolve ($ promise )
59
- {
60
- $ this ->assertInstanceOf ('React\Promise\PromiseInterface ' , $ promise );
61
-
62
- $ that = $ this ;
63
- $ promise ->then (null , function ($ error ) use ($ that ) {
64
- $ that ->assertNull ($ error );
65
- $ that ->fail ('promise rejected ' );
66
- });
67
- $ promise ->then ($ this ->expectCallableOnce (), $ this ->expectCallableNever ());
68
-
69
- return $ promise ;
70
- }
71
-
72
- protected function expectPromiseReject ($ promise )
73
- {
74
- $ this ->assertInstanceOf ('React\Promise\PromiseInterface ' , $ promise );
75
-
76
- $ that = $ this ;
77
- $ promise ->then (function ($ value ) use ($ that ) {
78
- $ that ->assertNull ($ value );
79
- $ that ->fail ('promise resolved ' );
80
- });
81
-
82
- $ promise ->then ($ this ->expectCallableNever (), $ this ->expectCallableOnce ());
83
-
84
- return $ promise ;
85
- }
86
-
87
58
public function setExpectedException ($ exception , $ message = '' , $ code = 0 )
88
59
{
89
60
if (method_exists ($ this , 'expectException ' )) {
You can’t perform that action at this time.
0 commit comments