Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit acefd6c

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

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-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

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,10 @@
2525
"psr-4": {
2626
"React\\Tests\\Socket\\": "tests"
2727
}
28+
},
29+
"config": {
30+
"platform": {
31+
"php": "5.3.29"
32+
}
2833
}
2934
}

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)