-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServerTest.php
47 lines (39 loc) · 869 Bytes
/
ServerTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* Created by PhpStorm.
* User: Tomas Sedlacek
* Mail: mail@kedlas.cz
* Date: 08/06/2017
* Time: 06:19
*/
namespace Test\Connect5;
use Connect5\Server;
use PHPUnit\Framework\TestCase;
use Ratchet\ConnectionInterface;
class ServerTest extends TestCase
{
/**
* @var Server
*/
private $server;
/**
* Prepare server instance
*/
public function setUp()
{
$this->server = new Server();
}
/**
* @covers Server::onMessage()
*/
public function testOnMessageInvalidMessage()
{
$conn = $this->createMock(ConnectionInterface::class);
$conn->method('send')->willReturnCallback(function ($msg) {
$msg = json_decode($msg, TRUE);
$this->assertEquals('error', $msg['type']);
$this->assertEquals('Invalid message. Error: Syntax error', $msg['data']['message']);
});
$this->server->onMessage($conn, 'some: invalid JS');
}
}