Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Travis config to test against legacy PHP 5.3 again #162

Merged
merged 1 commit into from
May 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ matrix:
include:
- php: 5.3
dist: precise
include:
- os: osx
language: generic
php: 7.0 # just to look right on travis
Expand Down
7 changes: 7 additions & 0 deletions src/TcpConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ private function waitForStreamOnce($stream)
$loop->removeWriteStream($stream);
fclose($stream);

// @codeCoverageIgnoreStart
// legacy PHP 5.3 sometimes requires a second close call (see tests)
if (PHP_VERSION_ID < 50400 && is_resource($stream)) {
fclose($stream);
}
// @codeCoverageIgnoreEnd

$resolve = $reject = $progress = null;
throw new RuntimeException('Cancelled while waiting for TCP/IP connection to be established');
});
Expand Down
5 changes: 5 additions & 0 deletions tests/TcpConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public function cancellingConnectionShouldRemoveResourceFromLoopAndCloseResource
$connector = new TcpConnector($loop);

$server = new TcpServer(0, $loop);
$server->on('connection', $this->expectCallableNever());

$loop->expects($this->once())->method('addWriteStream');
$promise = $connector->connect($server->getAddress());
Expand All @@ -234,7 +235,11 @@ public function cancellingConnectionShouldRemoveResourceFromLoopAndCloseResource
}));
$promise->cancel();

// ensure that this was a valid resource during the removeWriteStream() call
$this->assertTrue($valid);

// ensure that this resource should now be closed after the cancel() call
$this->assertInternalType('resource', $resource);
$this->assertFalse(is_resource($resource));
}

Expand Down