From 47e7059ed6dd84aeb91ae9c979a8d2941f99a6b0 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Sun, 29 Apr 2012 12:38:37 -0400 Subject: [PATCH] Mock MessageComponent common access Updated class to match the WAMP component --- .../Server/IOServerComponentTest.php | 6 ++--- tests/Ratchet/Tests/Mock/Component.php | 25 +++++-------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/tests/Ratchet/Tests/Component/Server/IOServerComponentTest.php b/tests/Ratchet/Tests/Component/Server/IOServerComponentTest.php index f0a3389..f217043 100644 --- a/tests/Ratchet/Tests/Component/Server/IOServerComponentTest.php +++ b/tests/Ratchet/Tests/Component/Server/IOServerComponentTest.php @@ -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]); } } \ No newline at end of file diff --git a/tests/Ratchet/Tests/Mock/Component.php b/tests/Ratchet/Tests/Mock/Component.php index 023cc8d..4a1d619 100644 --- a/tests/Ratchet/Tests/Mock/Component.php +++ b/tests/Ratchet/Tests/Mock/Component.php @@ -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(); } } \ No newline at end of file