Skip to content

Commit

Permalink
Fix Travis config to test against legacy PHP 5.3 again
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed May 6, 2018
1 parent 94e98bb commit acefd6c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
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
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@
"psr-4": {
"React\\Tests\\Socket\\": "tests"
}
},
"config": {
"platform": {
"php": "5.3.29"
}
}
}
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

0 comments on commit acefd6c

Please sign in to comment.