Skip to content

Commit

Permalink
Merge pull request #164 from clue-labs/tests
Browse files Browse the repository at this point in the history
Fix failing test on PHP 7.4 with code coverage when skipping some tests
  • Loading branch information
WyriHaximus authored Jul 22, 2020
2 parents 1f66dfd + af398a8 commit 8f85634
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/FunctionalResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use React\Dns\RecordNotFoundException;
use React\Dns\Model\Message;

class FunctionalTest extends TestCase
class FunctionalResolverTest extends TestCase
{
/**
* @before
Expand Down Expand Up @@ -171,6 +171,7 @@ public function testResolveCachedShouldNotCauseGarbageReferencesWhenUsingInvalid
$this->resolver = $factory->createCached('255.255.255.255', $this->loop);

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

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

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

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

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

$promise = $this->resolver->resolve('google.com');
$promise->cancel();
Expand Down
1 change: 1 addition & 0 deletions tests/Query/CoopExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public function testCancelQueryShouldNotCauseGarbageReferences()
$connector = new CoopExecutor($base);

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

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

Expand Down
6 changes: 6 additions & 0 deletions tests/Query/RetryExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ public function queryShouldNotCauseGarbageReferencesOnTimeoutErrors()
$retryExecutor = new RetryExecutor($executor, 0);

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

$query = new Query('igor.io', Message::TYPE_A, Message::CLASS_IN);
$retryExecutor->query($query);

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

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

$query = new Query('igor.io', Message::TYPE_A, Message::CLASS_IN);
$promise = $retryExecutor->query($query);
$promise->cancel();
Expand Down Expand Up @@ -311,6 +315,8 @@ public function queryShouldNotCauseGarbageReferencesOnNonTimeoutErrors()
$retryExecutor = new RetryExecutor($executor, 2);

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

$query = new Query('igor.io', Message::TYPE_A, Message::CLASS_IN);
$retryExecutor->query($query);

Expand Down
6 changes: 6 additions & 0 deletions tests/Query/SelectiveTransportExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ public function testCancelPromiseShouldNotCreateAnyGarbageReferences()
}));

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

$promise = $this->executor->query($query);
$promise->cancel();
unset($promise);
Expand Down Expand Up @@ -190,6 +192,8 @@ public function testCancelPromiseAfterTruncatedResponseShouldNotCreateAnyGarbage
}));

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

$promise = $this->executor->query($query);
$deferred->reject(new \RuntimeException('', defined('SOCKET_EMSGSIZE') ? SOCKET_EMSGSIZE : 90));
$promise->cancel();
Expand All @@ -215,6 +219,8 @@ public function testRejectedPromiseAfterTruncatedResponseShouldNotCreateAnyGarba
->willReturn(\React\Promise\reject(new \RuntimeException()));

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

$promise = $this->executor->query($query);
unset($promise);

Expand Down

0 comments on commit 8f85634

Please sign in to comment.