|
4 | 4 |
|
5 | 5 | use Monolog\Logger; |
6 | 6 | use Monolog\Handler\TestHandler; |
| 7 | +use React\Socket\ConnectionInterface; |
7 | 8 |
|
8 | 9 | class ChatrouletteTest extends \PHPUnit_Framework_TestCase |
9 | 10 | { |
@@ -46,15 +47,20 @@ public function connectingTwoUsersShouldPairThemUp() |
46 | 47 | $this->chatroulette->connect($alice); |
47 | 48 | $this->chatroulette->connect($bob); |
48 | 49 |
|
| 50 | + $this->emitConnectionData($alice, 'Hallo Bob, wie geht es dir?'); |
| 51 | + $this->emitConnectionData($bob, 'Je ne comprends pas!'); |
| 52 | + |
49 | 53 | $this->assertConnectionData($alice, [ |
50 | 54 | 'Hello Alice!', |
51 | 55 | 'Please wait until a partner connects.', |
52 | 56 | 'You are now talking to Bob.', |
| 57 | + 'Je ne comprends pas!', |
53 | 58 | ]); |
54 | 59 |
|
55 | 60 | $this->assertConnectionData($bob, [ |
56 | 61 | 'Hello Bob!', |
57 | 62 | 'You are now talking to Alice.', |
| 63 | + 'Hallo Bob, wie geht es dir?', |
58 | 64 | ]); |
59 | 65 |
|
60 | 66 | $this->assertLogs([ |
@@ -103,13 +109,18 @@ private function createAliceAndBob() |
103 | 109 | return array($alice, $bob); |
104 | 110 | } |
105 | 111 |
|
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) |
107 | 118 | { |
108 | 119 | $this->assertFalse($conn->isReadable()); |
109 | 120 | $this->assertFalse($conn->isWritable()); |
110 | 121 | } |
111 | 122 |
|
112 | | - private function assertConnectionData($conn, $expected) |
| 123 | + private function assertConnectionData(ConnectionInterface $conn, $expected) |
113 | 124 | { |
114 | 125 | $data = implode("\n", $expected)."\n"; |
115 | 126 | $this->assertSame($data, $conn->data); |
|
0 commit comments