Subversion Repositories php-qbpwcf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 liveuser 1
<?php
2
namespace Ratchet\Server;
3
use Ratchet\Server\EchoServer;
4
 
5
class EchoServerTest extends \PHPUnit_Framework_TestCase {
6
    protected $_conn;
7
    protected $_comp;
8
 
9
    public function setUp() {
10
        $this->_conn = $this->getMock('\Ratchet\ConnectionInterface');
11
        $this->_comp = new EchoServer;
12
    }
13
 
14
    public function testMessageEchod() {
15
        $message = 'Tillsonburg, my back still aches when I hear that word.';
16
        $this->_conn->expects($this->once())->method('send')->with($message);
17
        $this->_comp->onMessage($this->_conn, $message);
18
    }
19
 
20
    public function testErrorClosesConnection() {
21
        ob_start();
22
        $this->_conn->expects($this->once())->method('close');
23
        $this->_comp->onError($this->_conn, new \Exception);
24
        ob_end_clean();
25
    }
26
}