Skip to content

Commit a23f639

Browse files
author
Alex
committed
Fixed random message assertion
1 parent f6b298a commit a23f639

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tests/ServerTest.php

+13-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private function makeClient()
8686
]
8787
]);
8888

89-
sleep(3); // prevent receiving previous messages from queue
89+
usleep(100); // keep queue for more real case
9090

9191
return stream_socket_client('ssl://localhost:' . static::PORT, $errorNumber, $errorString, null, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $context);
9292
}
@@ -204,9 +204,18 @@ public function testConnector()
204204
socket_write($socket, Frame::encode('connector:hello'));
205205
socket_close($socket);
206206

207-
$data = Frame::decode($client);
208-
$this->assertArrayHasKey('payload', $data);
209-
$this->assertEquals('connector:hello', $data['payload']);
207+
$found = false;
208+
209+
while (!$found) {
210+
$data = Frame::decode($client);
211+
$this->assertArrayHasKey('payload', $data);
212+
213+
if ($data['payload'] == 'connector:hello') {
214+
$found = true;
215+
}
216+
}
217+
218+
$this->assertTrue($found);
210219

211220
fclose($client);
212221
}

0 commit comments

Comments
 (0)