Skip to content

Commit 27b1f09

Browse files
committed
Fix Travis config to test against legacy PHP 5.3 again
1 parent 94e98bb commit 27b1f09

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ matrix:
1818
include:
1919
- php: 5.3
2020
dist: precise
21-
include:
2221
- os: osx
2322
language: generic
2423
php: 7.0 # just to look right on travis

src/TcpConnector.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ private function waitForStreamOnce($stream)
116116
$loop->removeWriteStream($stream);
117117
fclose($stream);
118118

119+
// @codeCoverageIgnoreStart
120+
// legacy PHP 5.3 sometimes requires a second close call (see tests)
121+
if (PHP_VERSION_ID < 50400 && is_resource($stream)) {
122+
fclose($stream);
123+
}
124+
// codeCoverageIgnoreEnd
125+
119126
$resolve = $reject = $progress = null;
120127
throw new RuntimeException('Cancelled while waiting for TCP/IP connection to be established');
121128
});

tests/TcpConnectorTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ public function cancellingConnectionShouldRemoveResourceFromLoopAndCloseResource
221221
$connector = new TcpConnector($loop);
222222

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

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

238+
// ensure that this was a valid resource during the removeWriteStream() call
237239
$this->assertTrue($valid);
240+
241+
// ensure that this resource should now be closed after the cancel() call
242+
$this->assertInternalType('resource', $resource);
238243
$this->assertFalse(is_resource($resource));
239244
}
240245

0 commit comments

Comments
 (0)