From fc9401f04a3aca5abb22f87ebc210de8afe11d32 Mon Sep 17 00:00:00 2001 From: marvin-borner@live.com Date: Tue, 10 Apr 2018 21:50:16 +0200 Subject: Initial Commit --- .../Ratchet/AbstractMessageComponentTestCase.php | 50 ++++++++++++++++++++++ .../tests/helpers/Ratchet/Mock/Component.php | 35 +++++++++++++++ .../tests/helpers/Ratchet/Mock/Connection.php | 20 +++++++++ .../helpers/Ratchet/Mock/ConnectionDecorator.php | 22 ++++++++++ .../tests/helpers/Ratchet/Mock/WampComponent.php | 43 +++++++++++++++++++ .../tests/helpers/Ratchet/NullComponent.php | 28 ++++++++++++ .../Ratchet/Wamp/Stub/WsWampServerInterface.php | 7 +++ .../WebSocket/Stub/WsMessageComponentInterface.php | 7 +++ 8 files changed, 212 insertions(+) create mode 100644 assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php create mode 100644 assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/Component.php create mode 100644 assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/Connection.php create mode 100644 assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/ConnectionDecorator.php create mode 100644 assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/WampComponent.php create mode 100644 assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/NullComponent.php create mode 100644 assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Wamp/Stub/WsWampServerInterface.php create mode 100644 assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/WebSocket/Stub/WsMessageComponentInterface.php (limited to 'assets/php/vendor/cboden/ratchet/tests/helpers') diff --git a/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php b/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php new file mode 100644 index 0000000..8c298e5 --- /dev/null +++ b/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php @@ -0,0 +1,50 @@ +_app = $this->getMock($this->getComponentClassString()); + $decorator = $this->getDecoratorClassString(); + $this->_serv = new $decorator($this->_app); + $this->_conn = $this->getMock('\Ratchet\ConnectionInterface'); + + $this->doOpen($this->_conn); + } + + protected function doOpen($conn) { + $this->_serv->onOpen($conn); + } + + public function isExpectedConnection() { + return new \PHPUnit_Framework_Constraint_IsInstanceOf($this->getConnectionClassString()); + } + + public function testOpen() { + $this->_app->expects($this->once())->method('onOpen')->with($this->isExpectedConnection()); + $this->doOpen($this->getMock('\Ratchet\ConnectionInterface')); + } + + public function testOnClose() { + $this->_app->expects($this->once())->method('onClose')->with($this->isExpectedConnection()); + $this->_serv->onClose($this->_conn); + } + + public function testOnError() { + $e = new \Exception('Whoops!'); + $this->_app->expects($this->once())->method('onError')->with($this->isExpectedConnection(), $e); + $this->_serv->onError($this->_conn, $e); + } + + public function passthroughMessageTest($value) { + $this->_app->expects($this->once())->method('onMessage')->with($this->isExpectedConnection(), $value); + $this->_serv->onMessage($this->_conn, $value); + } +} diff --git a/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/Component.php b/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/Component.php new file mode 100644 index 0000000..e152988 --- /dev/null +++ b/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/Component.php @@ -0,0 +1,35 @@ +last[__FUNCTION__] = func_get_args(); + } + + public function onOpen(ConnectionInterface $conn) { + $this->last[__FUNCTION__] = func_get_args(); + } + + public function onMessage(ConnectionInterface $from, $msg) { + $this->last[__FUNCTION__] = func_get_args(); + } + + public function onClose(ConnectionInterface $conn) { + $this->last[__FUNCTION__] = func_get_args(); + } + + public function onError(ConnectionInterface $conn, \Exception $e) { + $this->last[__FUNCTION__] = func_get_args(); + } + + public function getSubProtocols() { + return $this->protocols; + } +} diff --git a/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/Connection.php b/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/Connection.php new file mode 100644 index 0000000..5918296 --- /dev/null +++ b/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/Connection.php @@ -0,0 +1,20 @@ + '' + , 'close' => false + ); + + public $remoteAddress = '127.0.0.1'; + + public function send($data) { + $this->last[__FUNCTION__] = $data; + } + + public function close() { + $this->last[__FUNCTION__] = true; + } +} diff --git a/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/ConnectionDecorator.php b/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/ConnectionDecorator.php new file mode 100644 index 0000000..5570c07 --- /dev/null +++ b/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/ConnectionDecorator.php @@ -0,0 +1,22 @@ + '' + , 'end' => false + ); + + public function send($data) { + $this->last[__FUNCTION__] = $data; + + $this->getConnection()->send($data); + } + + public function close() { + $this->last[__FUNCTION__] = true; + + $this->getConnection()->close(); + } +} diff --git a/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/WampComponent.php b/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/WampComponent.php new file mode 100644 index 0000000..cd526cb --- /dev/null +++ b/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/Mock/WampComponent.php @@ -0,0 +1,43 @@ +protocols; + } + + public function onCall(ConnectionInterface $conn, $id, $procURI, array $params) { + $this->last[__FUNCTION__] = func_get_args(); + } + + public function onSubscribe(ConnectionInterface $conn, $topic) { + $this->last[__FUNCTION__] = func_get_args(); + } + + public function onUnSubscribe(ConnectionInterface $conn, $topic) { + $this->last[__FUNCTION__] = func_get_args(); + } + + public function onPublish(ConnectionInterface $conn, $topic, $event, array $exclude, array $eligible) { + $this->last[__FUNCTION__] = func_get_args(); + } + + public function onOpen(ConnectionInterface $conn) { + $this->last[__FUNCTION__] = func_get_args(); + } + + public function onClose(ConnectionInterface $conn) { + $this->last[__FUNCTION__] = func_get_args(); + } + + public function onError(ConnectionInterface $conn, \Exception $e) { + $this->last[__FUNCTION__] = func_get_args(); + } +} diff --git a/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/NullComponent.php b/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/NullComponent.php new file mode 100644 index 0000000..90def21 --- /dev/null +++ b/assets/php/vendor/cboden/ratchet/tests/helpers/Ratchet/NullComponent.php @@ -0,0 +1,28 @@ +