Skip to content

Commit 8f85634

Browse files
authored
Merge pull request #164 from clue-labs/tests
Fix failing test on PHP 7.4 with code coverage when skipping some tests
2 parents 1f66dfd + af398a8 commit 8f85634

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

tests/FunctionalResolverTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use React\Dns\RecordNotFoundException;
88
use React\Dns\Model\Message;
99

10-
class FunctionalTest extends TestCase
10+
class FunctionalResolverTest extends TestCase
1111
{
1212
/**
1313
* @before
@@ -171,6 +171,7 @@ public function testResolveCachedShouldNotCauseGarbageReferencesWhenUsingInvalid
171171
$this->resolver = $factory->createCached('255.255.255.255', $this->loop);
172172

173173
gc_collect_cycles();
174+
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
174175

175176
$promise = $this->resolver->resolve('google.com');
176177
unset($promise);
@@ -188,6 +189,7 @@ public function testCancelResolveShouldNotCauseGarbageReferences()
188189
$this->resolver = $factory->create('127.0.0.1', $this->loop);
189190

190191
gc_collect_cycles();
192+
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
191193

192194
$promise = $this->resolver->resolve('google.com');
193195
$promise->cancel();
@@ -206,6 +208,7 @@ public function testCancelResolveCachedShouldNotCauseGarbageReferences()
206208
$this->resolver = $factory->createCached('127.0.0.1', $this->loop);
207209

208210
gc_collect_cycles();
211+
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
209212

210213
$promise = $this->resolver->resolve('google.com');
211214
$promise->cancel();

tests/Query/CoopExecutorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ public function testCancelQueryShouldNotCauseGarbageReferences()
221221
$connector = new CoopExecutor($base);
222222

223223
gc_collect_cycles();
224+
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
224225

225226
$query = new Query('reactphp.org', Message::TYPE_A, Message::CLASS_IN);
226227

tests/Query/RetryExecutorTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ public function queryShouldNotCauseGarbageReferencesOnTimeoutErrors()
251251
$retryExecutor = new RetryExecutor($executor, 0);
252252

253253
gc_collect_cycles();
254+
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
255+
254256
$query = new Query('igor.io', Message::TYPE_A, Message::CLASS_IN);
255257
$retryExecutor->query($query);
256258

@@ -281,6 +283,8 @@ public function queryShouldNotCauseGarbageReferencesOnCancellation()
281283
$retryExecutor = new RetryExecutor($executor, 0);
282284

283285
gc_collect_cycles();
286+
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
287+
284288
$query = new Query('igor.io', Message::TYPE_A, Message::CLASS_IN);
285289
$promise = $retryExecutor->query($query);
286290
$promise->cancel();
@@ -311,6 +315,8 @@ public function queryShouldNotCauseGarbageReferencesOnNonTimeoutErrors()
311315
$retryExecutor = new RetryExecutor($executor, 2);
312316

313317
gc_collect_cycles();
318+
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
319+
314320
$query = new Query('igor.io', Message::TYPE_A, Message::CLASS_IN);
315321
$retryExecutor->query($query);
316322

tests/Query/SelectiveTransportExecutorTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ public function testCancelPromiseShouldNotCreateAnyGarbageReferences()
159159
}));
160160

161161
gc_collect_cycles();
162+
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
163+
162164
$promise = $this->executor->query($query);
163165
$promise->cancel();
164166
unset($promise);
@@ -190,6 +192,8 @@ public function testCancelPromiseAfterTruncatedResponseShouldNotCreateAnyGarbage
190192
}));
191193

192194
gc_collect_cycles();
195+
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
196+
193197
$promise = $this->executor->query($query);
194198
$deferred->reject(new \RuntimeException('', defined('SOCKET_EMSGSIZE') ? SOCKET_EMSGSIZE : 90));
195199
$promise->cancel();
@@ -215,6 +219,8 @@ public function testRejectedPromiseAfterTruncatedResponseShouldNotCreateAnyGarba
215219
->willReturn(\React\Promise\reject(new \RuntimeException()));
216220

217221
gc_collect_cycles();
222+
gc_collect_cycles(); // clear twice to avoid leftovers in PHP 7.4 with ext-xdebug and code coverage turned on
223+
218224
$promise = $this->executor->query($query);
219225
unset($promise);
220226

0 commit comments

Comments
 (0)