Mock MessageComponent common access
Updated class to match the WAMP component
This commit is contained in:
parent
6be16bea4a
commit
47e7059ed6
@ -41,7 +41,7 @@ class IOServerComponentTest extends \PHPUnit_Framework_TestCase {
|
||||
$master = $this->getMasterConnection();
|
||||
|
||||
$this->_server->onOpen($master);
|
||||
$clone = $this->_decorated->_conn_open;
|
||||
$clone = $this->_decorated->last['onOpen'][0];
|
||||
|
||||
$this->assertEquals($master->resourceId + 1, $clone->resourceId);
|
||||
}
|
||||
@ -54,12 +54,12 @@ class IOServerComponentTest extends \PHPUnit_Framework_TestCase {
|
||||
// that way can mimic the TCP fragmentation/buffer situation
|
||||
|
||||
$this->_server->onOpen($master);
|
||||
$clone = $this->_decorated->_conn_open;
|
||||
$clone = $this->_decorated->last['onOpen'][0];
|
||||
|
||||
// $this->_server->run($this->_catalyst);
|
||||
$msg = 'Hello World!';
|
||||
$this->_server->onMessage($clone, $msg);
|
||||
|
||||
$this->assertEquals($msg, $this->_decorated->_msg_recv);
|
||||
$this->assertEquals($msg, $this->_decorated->last['onMessage'][1]);
|
||||
}
|
||||
}
|
@ -5,38 +5,25 @@ use Ratchet\Tests\Mock\Socket as MockSocket;
|
||||
use Ratchet\Resource\ConnectionInterface;
|
||||
|
||||
class Component implements MessageComponentInterface {
|
||||
public $_app;
|
||||
|
||||
public $_conn_open;
|
||||
|
||||
public $_conn_recv;
|
||||
public $_msg_recv;
|
||||
|
||||
public $_conn_close;
|
||||
|
||||
public $_conn_error;
|
||||
public $_excep_error;
|
||||
public $last = array();
|
||||
|
||||
public function __construct(ComponentInterface $app = null) {
|
||||
// probably should make this null app
|
||||
$this->_app = $app;
|
||||
$this->last[__FUNCTION__] = func_get_args();
|
||||
}
|
||||
|
||||
public function onOpen(ConnectionInterface $conn) {
|
||||
$this->_conn_open = $conn;
|
||||
$this->last[__FUNCTION__] = func_get_args();
|
||||
}
|
||||
|
||||
public function onMessage(ConnectionInterface $from, $msg) {
|
||||
$this->_conn_recv = $from;
|
||||
$this->_msg_recv = $msg;
|
||||
$this->last[__FUNCTION__] = func_get_args();
|
||||
}
|
||||
|
||||
public function onClose(ConnectionInterface $conn) {
|
||||
$this->_conn_close = $conn;
|
||||
$this->last[__FUNCTION__] = func_get_args();
|
||||
}
|
||||
|
||||
public function onError(ConnectionInterface $conn, \Exception $e) {
|
||||
$this->_conn_error = $conn;
|
||||
$this->_excep_error = $e;
|
||||
$this->last[__FUNCTION__] = func_get_args();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user