| 3 |
liveuser |
1 |
<?php
|
|
|
2 |
namespace Ratchet\Application\Server;
|
|
|
3 |
use Ratchet\Server\IoConnection;
|
|
|
4 |
|
|
|
5 |
/**
|
|
|
6 |
* @covers Ratchet\Server\IoConnection
|
|
|
7 |
*/
|
|
|
8 |
class IoConnectionTest extends \PHPUnit_Framework_TestCase {
|
|
|
9 |
protected $sock;
|
|
|
10 |
protected $conn;
|
|
|
11 |
|
|
|
12 |
public function setUp() {
|
|
|
13 |
$this->sock = $this->getMock('\\React\\Socket\\ConnectionInterface');
|
|
|
14 |
$this->conn = new IoConnection($this->sock);
|
|
|
15 |
}
|
|
|
16 |
|
|
|
17 |
public function testCloseBubbles() {
|
|
|
18 |
$this->sock->expects($this->once())->method('end');
|
|
|
19 |
$this->conn->close();
|
|
|
20 |
}
|
|
|
21 |
|
|
|
22 |
public function testSendBubbles() {
|
|
|
23 |
$msg = '6 hour rides are productive';
|
|
|
24 |
|
|
|
25 |
$this->sock->expects($this->once())->method('write')->with($msg);
|
|
|
26 |
$this->conn->send($msg);
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
public function testSendReturnsSelf() {
|
|
|
30 |
$this->assertSame($this->conn, $this->conn->send('fluent interface'));
|
|
|
31 |
}
|
|
|
32 |
}
|