@@ -126,8 +126,9 @@ public function testCancellingPendingConnectionWithoutTimeoutShouldNotCreateAnyG
126
126
127
127
$ connector = new Connector (array ('timeout ' => false ));
128
128
129
- gc_collect_cycles ();
130
- gc_collect_cycles (); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
129
+ while (gc_collect_cycles ()) {
130
+ // collect all garbage cycles
131
+ }
131
132
132
133
$ promise = $ connector ->connect ('8.8.8.8:80 ' );
133
134
$ promise ->cancel ();
@@ -144,7 +145,10 @@ public function testCancellingPendingConnectionShouldNotCreateAnyGarbageReferenc
144
145
145
146
$ connector = new Connector (array ());
146
147
147
- gc_collect_cycles ();
148
+ while (gc_collect_cycles ()) {
149
+ // collect all garbage cycles
150
+ }
151
+
148
152
$ promise = $ connector ->connect ('8.8.8.8:80 ' );
149
153
$ promise ->cancel ();
150
154
unset($ promise );
@@ -167,7 +171,9 @@ public function testWaitingForRejectedConnectionShouldNotCreateAnyGarbageReferen
167
171
168
172
$ connector = new Connector (array ('timeout ' => false ));
169
173
170
- gc_collect_cycles ();
174
+ while (gc_collect_cycles ()) {
175
+ // collect all garbage cycles
176
+ }
171
177
172
178
$ wait = true ;
173
179
$ promise = $ connector ->connect ('127.0.0.1:1 ' )->then (
@@ -201,7 +207,9 @@ public function testWaitingForConnectionTimeoutDuringDnsLookupShouldNotCreateAny
201
207
202
208
$ connector = new Connector (array ('timeout ' => 0.001 ));
203
209
204
- gc_collect_cycles ();
210
+ while (gc_collect_cycles ()) {
211
+ // collect all garbage cycles
212
+ }
205
213
206
214
$ wait = true ;
207
215
$ promise = $ connector ->connect ('google.com:80 ' )->then (
@@ -232,7 +240,9 @@ public function testWaitingForConnectionTimeoutDuringTcpConnectionShouldNotCreat
232
240
233
241
$ connector = new Connector (array ('timeout ' => 0.000001 ));
234
242
235
- gc_collect_cycles ();
243
+ while (gc_collect_cycles ()) {
244
+ // collect all garbage cycles
245
+ }
236
246
237
247
$ wait = true ;
238
248
$ promise = $ connector ->connect ('8.8.8.8:53 ' )->then (
@@ -263,7 +273,9 @@ public function testWaitingForInvalidDnsConnectionShouldNotCreateAnyGarbageRefer
263
273
264
274
$ connector = new Connector (array ('timeout ' => false ));
265
275
266
- gc_collect_cycles ();
276
+ while (gc_collect_cycles ()) {
277
+ // collect all garbage cycles
278
+ }
267
279
268
280
$ wait = true ;
269
281
$ promise = $ connector ->connect ('example.invalid:80 ' )->then (
@@ -304,7 +316,9 @@ public function testWaitingForInvalidTlsConnectionShouldNotCreateAnyGarbageRefer
304
316
)
305
317
));
306
318
307
- gc_collect_cycles ();
319
+ while (gc_collect_cycles ()) {
320
+ // collect all garbage cycles
321
+ }
308
322
309
323
$ wait = true ;
310
324
$ promise = $ connector ->connect ('tls://self-signed.badssl.com:443 ' )->then (
@@ -338,7 +352,10 @@ public function testWaitingForSuccessfullyClosedConnectionShouldNotCreateAnyGarb
338
352
339
353
$ connector = new Connector (array ('timeout ' => false ));
340
354
341
- gc_collect_cycles ();
355
+ while (gc_collect_cycles ()) {
356
+ // collect all garbage cycles
357
+ }
358
+
342
359
$ promise = $ connector ->connect ('google.com:80 ' )->then (
343
360
function ($ conn ) {
344
361
$ conn ->close ();
0 commit comments