Skip to content

Commit f568891

Browse files
committed
Fix forward compatibility with upcoming EventLoop releases in tests
1 parent 5deb19b commit f568891

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"react/promise-timer": "~1.0"
1414
},
1515
"require-dev": {
16-
"clue/block-react": "^1.1",
16+
"clue/block-react": "^1.2",
1717
"phpunit/phpunit": "^5.0 || ^4.8"
1818
},
1919
"autoload": {

tests/TcpServerTest.php

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace React\Tests\Socket;
44

5+
use Clue\React\Block;
56
use React\EventLoop\StreamSelectLoop;
67
use React\Socket\TcpServer;
78
use React\Stream\DuplexResourceStream;
@@ -37,7 +38,8 @@ public function testConnection()
3738
$client = stream_socket_client('tcp://localhost:'.$this->port);
3839

3940
$this->server->on('connection', $this->expectCallableOnce());
40-
$this->loop->tick();
41+
42+
$this->tick();
4143
}
4244

4345
/**
@@ -50,9 +52,9 @@ public function testConnectionWithManyClients()
5052
$client3 = stream_socket_client('tcp://localhost:'.$this->port);
5153

5254
$this->server->on('connection', $this->expectCallableExactly(3));
53-
$this->loop->tick();
54-
$this->loop->tick();
55-
$this->loop->tick();
55+
$this->tick();
56+
$this->tick();
57+
$this->tick();
5658
}
5759

5860
public function testDataEventWillNotBeEmittedWhenClientSendsNoData()
@@ -79,8 +81,8 @@ public function testDataWillBeEmittedWithDataClientSends()
7981
$this->server->on('connection', function ($conn) use ($mock) {
8082
$conn->on('data', $mock);
8183
});
82-
$this->loop->tick();
83-
$this->loop->tick();
84+
$this->tick();
85+
$this->tick();
8486
}
8587

8688
public function testDataWillBeEmittedEvenWhenClientShutsDownAfterSending()
@@ -94,8 +96,8 @@ public function testDataWillBeEmittedEvenWhenClientShutsDownAfterSending()
9496
$this->server->on('connection', function ($conn) use ($mock) {
9597
$conn->on('data', $mock);
9698
});
97-
$this->loop->tick();
98-
$this->loop->tick();
99+
$this->tick();
100+
$this->tick();
99101
}
100102

101103
public function testLoopWillEndWhenServerIsClosed()
@@ -169,9 +171,6 @@ public function testDataWillBeEmittedInMultipleChunksWhenClientSendsExcessiveAmo
169171
$this->assertEquals($bytes, $received);
170172
}
171173

172-
/**
173-
* @covers React\EventLoop\StreamSelectLoop::tick
174-
*/
175174
public function testConnectionDoesNotEndWhenClientDoesNotClose()
176175
{
177176
$client = stream_socket_client('tcp://localhost:'.$this->port);
@@ -181,12 +180,11 @@ public function testConnectionDoesNotEndWhenClientDoesNotClose()
181180
$this->server->on('connection', function ($conn) use ($mock) {
182181
$conn->on('end', $mock);
183182
});
184-
$this->loop->tick();
185-
$this->loop->tick();
183+
$this->tick();
184+
$this->tick();
186185
}
187186

188187
/**
189-
* @covers React\EventLoop\StreamSelectLoop::tick
190188
* @covers React\Socket\Connection::end
191189
*/
192190
public function testConnectionDoesEndWhenClientCloses()
@@ -200,8 +198,8 @@ public function testConnectionDoesEndWhenClientCloses()
200198
$this->server->on('connection', function ($conn) use ($mock) {
201199
$conn->on('end', $mock);
202200
});
203-
$this->loop->tick();
204-
$this->loop->tick();
201+
$this->tick();
202+
$this->tick();
205203
}
206204

207205
public function testCtorAddsResourceToLoop()
@@ -270,4 +268,9 @@ public function tearDown()
270268
$this->server->close();
271269
}
272270
}
271+
272+
private function tick()
273+
{
274+
Block\sleep(0, $this->loop);
275+
}
273276
}

0 commit comments

Comments
 (0)