Skip to content

Commit a2b2ccd

Browse files
authored
Merge pull request #18 from clue-labs/socket
Forward compatibility with upcoming Socket v1.0 and v0.8
2 parents 92eada0 + 9cf9ea5 commit a2b2ccd

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"require": {
1717
"php": ">=5.3",
18-
"react/socket": "^0.7",
18+
"react/socket": "^1.0 || ^0.8 || ^0.7",
1919
"react/event-loop": "^0.4 || ^0.3",
2020
"react/promise": "^2.1 || ^1.2",
2121
"react/promise-timer": "^1.1"

src/ConnectionManagerTimeout.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use React\Socket\ConnectorInterface;
66
use React\EventLoop\LoopInterface;
77
use React\Promise\Timer;
8-
use Exception;
98

109
class ConnectionManagerTimeout implements ConnectorInterface
1110
{

tests/ConnectionManagerTimeoutTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
use ConnectionManager\Extra\ConnectionManagerReject;
44

5-
use React\Stream\Stream;
65
use ConnectionManager\Extra\ConnectionManagerDelay;
76
use ConnectionManager\Extra\ConnectionManagerTimeout;
87
use React\Promise\Promise;
9-
use React\Promise\Timer;
108

119
class ConnectionManagerTimeoutTest extends TestCase
1210
{
@@ -31,7 +29,7 @@ public function testTimeoutOkay()
3129

3230
public function testTimeoutExpire()
3331
{
34-
$will = $this->createConnectionManagerMock(new Stream(fopen('php://temp', 'r+'), $this->loop));
32+
$will = $this->createConnectionManagerMock(true);
3533
$wont = new ConnectionManagerDelay($will, 0.2, $this->loop);
3634

3735
$cm = new ConnectionManagerTimeout($wont, 0.1, $this->loop);
@@ -58,12 +56,12 @@ public function testTimeoutAbort()
5856

5957
public function testWillEndConnectionIfConnectionResolvesDespiteTimeout()
6058
{
61-
$stream = $this->getMockBuilder('React\Stream\DuplexStreamInterface')->disableOriginalConstructor()->getMock();
59+
$stream = $this->getMockBuilder('React\Socket\ConnectionInterface')->getMock();
6260
$stream->expects($this->once())->method('end');
6361

6462
$loop = $this->loop;
6563
$promise = new Promise(function ($resolve) use ($loop, $stream) {
66-
$loop->addTimer(0.002, function () use ($resolve, $stream) {
64+
$loop->addTimer(0.01, function () use ($resolve, $stream) {
6765
$resolve($stream);
6866
});
6967
});

tests/Multiple/ConnectionManagerSelectiveTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
use React\Stream\Stream;
4-
53
use ConnectionManager\Extra\Multiple\ConnectionManagerSelective;
64
use ConnectionManager\Extra\ConnectionManagerReject;
75

@@ -140,7 +138,7 @@ public function testNotMatchingDomainWillReject()
140138

141139
public function testReject()
142140
{
143-
$will = $this->createConnectionManagerMock(new Stream(fopen('php://temp', 'r+'), $this->createLoopMock()));
141+
$will = $this->createConnectionManagerMock(true);
144142

145143
$cm = new ConnectionManagerSelective(array(
146144
'www.google.com:443' => $will,
@@ -157,7 +155,7 @@ public function testReject()
157155
public function testFirstEntryWinsIfMultipleMatch()
158156
{
159157
$wont = new ConnectionManagerReject();
160-
$will = $this->createConnectionManagerMock(new Stream(fopen('php://temp', 'r+'), $this->createLoopMock()));
158+
$will = $this->createConnectionManagerMock(true);
161159

162160
$cm = new ConnectionManagerSelective(array(
163161
'www.google.com:443' => $will,
@@ -170,7 +168,7 @@ public function testFirstEntryWinsIfMultipleMatch()
170168

171169
public function testWildcardsMatch()
172170
{
173-
$will = $this->createConnectionManagerMock(new Stream(fopen('php://temp', 'r+'), $this->createLoopMock()));
171+
$will = $this->createConnectionManagerMock(true);
174172

175173
$cm = new ConnectionManagerSelective(array(
176174
'*.com' => $will,

0 commit comments

Comments
 (0)