Skip to content

Commit 0bc2dbd

Browse files
committed
Add conversation between alice and bob to tests
1 parent 07261ab commit 0bc2dbd

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/React/Chatroulette/ChatrouletteTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Monolog\Logger;
66
use Monolog\Handler\TestHandler;
7+
use React\Socket\ConnectionInterface;
78

89
class ChatrouletteTest extends \PHPUnit_Framework_TestCase
910
{
@@ -46,15 +47,20 @@ public function connectingTwoUsersShouldPairThemUp()
4647
$this->chatroulette->connect($alice);
4748
$this->chatroulette->connect($bob);
4849

50+
$this->emitConnectionData($alice, 'Hallo Bob, wie geht es dir?');
51+
$this->emitConnectionData($bob, 'Je ne comprends pas!');
52+
4953
$this->assertConnectionData($alice, [
5054
'Hello Alice!',
5155
'Please wait until a partner connects.',
5256
'You are now talking to Bob.',
57+
'Je ne comprends pas!',
5358
]);
5459

5560
$this->assertConnectionData($bob, [
5661
'Hello Bob!',
5762
'You are now talking to Alice.',
63+
'Hallo Bob, wie geht es dir?',
5864
]);
5965

6066
$this->assertLogs([
@@ -103,13 +109,18 @@ private function createAliceAndBob()
103109
return array($alice, $bob);
104110
}
105111

106-
private function assertClosed($conn)
112+
private function emitConnectionData(ConnectionInterface $conn, $data)
113+
{
114+
$conn->emit('data', array($data."\n"));
115+
}
116+
117+
private function assertClosed(ConnectionInterface $conn)
107118
{
108119
$this->assertFalse($conn->isReadable());
109120
$this->assertFalse($conn->isWritable());
110121
}
111122

112-
private function assertConnectionData($conn, $expected)
123+
private function assertConnectionData(ConnectionInterface $conn, $expected)
113124
{
114125
$data = implode("\n", $expected)."\n";
115126
$this->assertSame($data, $conn->data);

0 commit comments

Comments
 (0)