Subversion Repositories php-qbpwcf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 liveuser 1
<?php
2
namespace Ratchet\Wamp;
3
use Ratchet\AbstractMessageComponentTestCase;
4
 
5
/**
6
 * @covers Ratchet\Wamp\WampServer
7
 */
8
class WampServerTest extends AbstractMessageComponentTestCase {
9
    public function getConnectionClassString() {
10
        return '\Ratchet\Wamp\WampConnection';
11
    }
12
 
13
    public function getDecoratorClassString() {
14
        return 'Ratchet\Wamp\WampServer';
15
    }
16
 
17
    public function getComponentClassString() {
18
        return '\Ratchet\Wamp\WampServerInterface';
19
    }
20
 
21
    public function testOnMessageToEvent() {
22
        $published = 'Client published this message';
23
 
24
        $this->_app->expects($this->once())->method('onPublish')->with(
25
            $this->isExpectedConnection()
26
          , new \PHPUnit_Framework_Constraint_IsInstanceOf('\Ratchet\Wamp\Topic')
27
          , $published
28
          , array()
29
          , array()
30
        );
31
 
32
        $this->_serv->onMessage($this->_conn, json_encode(array(7, 'topic', $published)));
33
    }
34
 
35
    public function testGetSubProtocols() {
36
        // todo: could expand on this
37
        $this->assertInternalType('array', $this->_serv->getSubProtocols());
38
    }
39
 
40
    public function testConnectionClosesOnInvalidJson() {
41
        $this->_conn->expects($this->once())->method('close');
42
        $this->_serv->onMessage($this->_conn, 'invalid json');
43
    }
44
 
45
    public function testConnectionClosesOnProtocolError() {
46
        $this->_conn->expects($this->once())->method('close');
47
        $this->_serv->onMessage($this->_conn, json_encode(array('valid' => 'json', 'invalid' => 'protocol')));
48
    }
49
}