diff --git a/CHANGELOG.md b/CHANGELOG.md index e0771e2..cada583 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,9 @@ CHANGELOG * 0.3.0 (2013-xx-xx) - * BC: Require hostname and do Origin HTTP header check against it by default, helping prevent CSRF attacks - * Added HTTP Router component to allowing for a single Ratchet server to handle multiple apps - * BC: Decoupled HTTP from WebSocket component + * Added Symfony/2.2 based HTTP Router component to allowing for a single Ratchet server to handle multiple apps -> Ratchet\Http\Router + * BC: Decoupled HTTP from WebSocket component -> Ratchet\Http\HttpServer + * Updated dependency to React/0.3 * 0.2.5 (2013-04-01) diff --git a/Makefile b/Makefile index d5e12a2..3a1ac95 100644 --- a/Makefile +++ b/Makefile @@ -8,10 +8,8 @@ cover: phpunit --coverage-text --coverage-html=reports/coverage abtests: - ulimit -n 2048 && php tests/AutobahnTestSuite/bin/fuzzingserver-libevent.php 8002 & - ulimit -n 2048 && php tests/AutobahnTestSuite/bin/fuzzingserver-stream.php 8001 & - ulimit -n 2048 && php tests/AutobahnTestSuite/bin/fuzzingserver-libev.php 8004 & - ulimit -n 2048 && php tests/AutobahnTestSuite/bin/fuzzingserver-libuv.php 8005 & + ulimit -n 2048 && php tests/AutobahnTestSuite/bin/fuzzingserver-libevent.php 8001 & + ulimit -n 2048 && php tests/AutobahnTestSuite/bin/fuzzingserver-stream.php 8002 & ulimit -n 2048 && php tests/AutobahnTestSuite/bin/fuzzingserver-noutf8.php 8003 & wstest -m testeeserver -w ws://localhost:8000 & wstest -m fuzzingclient -s tests/AutobahnTestSuite/fuzzingclient-all.json diff --git a/README.md b/README.md index 3f78953..aa60b78 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,10 @@ Shell access is required and root access is recommended. To avoid proxy/firewall blockage it's recommended WebSockets are run on port 80, which requires root access. In order to do this, along with your sync web stack, you can either use a proxy or two separate machines. You can find more details in the [server conf docs](http://socketo.me/docs/deploy#sconf). -PHP 5.3.3 (or higher) is required. If you have access, PHP 5.4 is *highly* recommended for its performance improvements. Cookies from your domain will be passed to the socket server, allowing you to identify users. Accessing your website's session data in Ratchet requires you to use [Symfony2 Sessions](http://symfony.com/doc/master/components/http_foundation/sessions.html) on your website. +PHP 5.3.9 (or higher) is required. If you have access, PHP 5.4 is *highly* recommended for its performance improvements. ### Documentation diff --git a/composer.lock b/composer.lock index f7408e1..e12161a 100644 --- a/composer.lock +++ b/composer.lock @@ -46,17 +46,17 @@ }, { "name": "guzzle/common", - "version": "v3.4.1", + "version": "v3.4.3", "target-dir": "Guzzle/Common", "source": { "type": "git", "url": "https://github.com/guzzle/common.git", - "reference": "v3.4.1" + "reference": "v3.4.3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/common/zipball/v3.4.1", - "reference": "v3.4.1", + "url": "https://api.github.com/repos/guzzle/common/zipball/v3.4.3", + "reference": "v3.4.3", "shasum": "" }, "require": { @@ -66,7 +66,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -86,21 +86,21 @@ "event", "exception" ], - "time": "2013-04-16 20:56:26" + "time": "2013-04-30 20:30:19" }, { "name": "guzzle/http", - "version": "v3.4.1", + "version": "v3.4.3", "target-dir": "Guzzle/Http", "source": { "type": "git", "url": "https://github.com/guzzle/http.git", - "reference": "v3.4.1" + "reference": "v3.4.3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/http/zipball/v3.4.1", - "reference": "v3.4.1", + "url": "https://api.github.com/repos/guzzle/http/zipball/v3.4.3", + "reference": "v3.4.3", "shasum": "" }, "require": { @@ -115,7 +115,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -143,21 +143,21 @@ "http", "http client" ], - "time": "2013-04-16 20:27:11" + "time": "2013-04-30 20:30:19" }, { "name": "guzzle/parser", - "version": "v3.4.1", + "version": "v3.4.3", "target-dir": "Guzzle/Parser", "source": { "type": "git", "url": "https://github.com/guzzle/parser.git", - "reference": "v3.4.1" + "reference": "v3.4.3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/parser/zipball/v3.4.1", - "reference": "v3.4.1", + "url": "https://api.github.com/repos/guzzle/parser/zipball/v3.4.3", + "reference": "v3.4.3", "shasum": "" }, "require": { @@ -166,7 +166,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -187,21 +187,21 @@ "message", "url" ], - "time": "2013-03-07 22:13:59" + "time": "2013-04-26 15:47:38" }, { "name": "guzzle/stream", - "version": "v3.4.1", + "version": "v3.4.3", "target-dir": "Guzzle/Stream", "source": { "type": "git", "url": "https://github.com/guzzle/stream.git", - "reference": "v3.4.1" + "reference": "v3.4.3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/stream/zipball/v3.4.1", - "reference": "v3.4.1", + "url": "https://api.github.com/repos/guzzle/stream/zipball/v3.4.3", + "reference": "v3.4.3", "shasum": "" }, "require": { @@ -214,7 +214,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -240,7 +240,7 @@ "component", "stream" ], - "time": "2013-04-06 18:28:51" + "time": "2013-04-26 15:47:38" }, { "name": "react/event-loop", diff --git a/tests/Ratchet/Tests/AbFuzzyServer.php b/src/Ratchet/Server/EchoServer.php similarity index 83% rename from tests/Ratchet/Tests/AbFuzzyServer.php rename to src/Ratchet/Server/EchoServer.php index 025cb4b..3f5069b 100644 --- a/tests/Ratchet/Tests/AbFuzzyServer.php +++ b/src/Ratchet/Server/EchoServer.php @@ -1,9 +1,9 @@ 1 ? $argv[1] : 8000; $sock->listen($port, '0.0.0.0'); diff --git a/tests/AutobahnTestSuite/bin/fuzzingserver-libevent.php b/tests/AutobahnTestSuite/bin/fuzzingserver-libevent.php index ea1fbad..729e7d7 100644 --- a/tests/AutobahnTestSuite/bin/fuzzingserver-libevent.php +++ b/tests/AutobahnTestSuite/bin/fuzzingserver-libevent.php @@ -4,7 +4,7 @@ $loop = new React\EventLoop\LibEventLoop; $sock = new React\Socket\Server($loop); - $app = new Ratchet\Http\HttpServer(new Ratchet\WebSocket\WsServer(new Ratchet\Tests\AbFuzzyServer)); + $app = new Ratchet\Http\HttpServer(new Ratchet\WebSocket\WsServer(new Ratchet\Server\EchoServer)); $port = $argc > 1 ? $argv[1] : 8000; $sock->listen($port, '0.0.0.0'); diff --git a/tests/AutobahnTestSuite/bin/fuzzingserver-libuv.php b/tests/AutobahnTestSuite/bin/fuzzingserver-libuv.php index fb6d03f..b3dec26 100644 --- a/tests/AutobahnTestSuite/bin/fuzzingserver-libuv.php +++ b/tests/AutobahnTestSuite/bin/fuzzingserver-libuv.php @@ -4,7 +4,7 @@ $loop = new React\EventLoop\LibEvLoop; $sock = new React\Socket\Server($loop); - $app = new Ratchet\Http\HttpServer(new Ratchet\WebSocket\WsServer(new Ratchet\Tests\AbFuzzyServer)); + $app = new Ratchet\Http\HttpServer(new Ratchet\WebSocket\WsServer(new Ratchet\Server\EchoServer)); $port = $argc > 1 ? $argv[1] : 8000; $sock->listen($port, '0.0.0.0'); diff --git a/tests/AutobahnTestSuite/bin/fuzzingserver-noutf8.php b/tests/AutobahnTestSuite/bin/fuzzingserver-noutf8.php index b20b3a1..01205f5 100644 --- a/tests/AutobahnTestSuite/bin/fuzzingserver-noutf8.php +++ b/tests/AutobahnTestSuite/bin/fuzzingserver-noutf8.php @@ -4,7 +4,7 @@ $loop = new React\EventLoop\StreamSelectLoop; $sock = new React\Socket\Server($loop); - $web = new Ratchet\WebSocket\WsServer(new Ratchet\Tests\AbFuzzyServer); + $web = new Ratchet\WebSocket\WsServer(new Ratchet\Server\EchoServer); $app = new Ratchet\Http\HttpServer($web); $web->setEncodingChecks(false); diff --git a/tests/AutobahnTestSuite/bin/fuzzingserver-stream.php b/tests/AutobahnTestSuite/bin/fuzzingserver-stream.php index 98b4448..b10dc10 100644 --- a/tests/AutobahnTestSuite/bin/fuzzingserver-stream.php +++ b/tests/AutobahnTestSuite/bin/fuzzingserver-stream.php @@ -4,7 +4,7 @@ $loop = new React\EventLoop\StreamSelectLoop; $sock = new React\Socket\Server($loop); - $app = new Ratchet\Http\HttpServer(new Ratchet\WebSocket\WsServer(new Ratchet\Tests\AbFuzzyServer)); + $app = new Ratchet\Http\HttpServer(new Ratchet\WebSocket\WsServer(new Ratchet\Server\EchoyServer)); $port = $argc > 1 ? $argv[1] : 8000; $sock->listen($port, '0.0.0.0'); diff --git a/tests/AutobahnTestSuite/fuzzingclient-all.json b/tests/AutobahnTestSuite/fuzzingclient-all.json index 8ebe6d8..5dbd204 100644 --- a/tests/AutobahnTestSuite/fuzzingclient-all.json +++ b/tests/AutobahnTestSuite/fuzzingclient-all.json @@ -3,11 +3,9 @@ , "outdir": "reports/ab" , "servers": [ - {"agent": "Ratchet/0.2.5 libevent", "url": "ws://localhost:8002", "options": {"version": 18}} - , {"agent": "Ratchet/0.2.5 libuv", "url": "ws://localhost:8005", "options": {"version": 18}} - , {"agent": "Ratchet/0.2.5 libev", "url": "ws://localhost:8004", "options": {"version": 18}} - , {"agent": "Ratchet/0.2.5 -utf8", "url": "ws://localhost:8003", "options": {"version": 18}} - , {"agent": "Ratchet/0.2.5 streams", "url": "ws://localhost:8001", "options": {"version": 18}} + {"agent": "Ratchet/0.3 libevent", "url": "ws://localhost:8001", "options": {"version": 18}} + , {"agent": "Ratchet/0.3 streams", "url": "ws://localhost:8002", "options": {"version": 18}} + , {"agent": "Ratchet/0.3 -utf8", "url": "ws://localhost:8003", "options": {"version": 18}} , {"agent": "AutobahnTestSuite/0.5.9", "url": "ws://localhost:8000", "options": {"version": 18}} ] diff --git a/tests/Ratchet/Tests/Server/EchoServerTest.php b/tests/Ratchet/Tests/Server/EchoServerTest.php new file mode 100644 index 0000000..4910dad --- /dev/null +++ b/tests/Ratchet/Tests/Server/EchoServerTest.php @@ -0,0 +1,26 @@ +_conn = $this->getMock('\Ratchet\ConnectionInterface'); + $this->_comp = new EchoServer; + } + + public function testMessageEchod() { + $message = 'Tillsonburg, my back still aches when I hear that word.'; + $this->_conn->expects($this->once())->method('send')->with($message); + $this->_comp->onMessage($this->_conn, $message); + } + + public function testErrorClosesConnection() { + ob_start(); + $this->_conn->expects($this->once())->method('close'); + $this->_comp->onError($this->_conn, new \Exception); + ob_end_clean(); + } +} diff --git a/tests/Ratchet/Tests/Wamp/TopicManagerTest.php b/tests/Ratchet/Tests/Wamp/TopicManagerTest.php index 8388550..3c00cd1 100644 --- a/tests/Ratchet/Tests/Wamp/TopicManagerTest.php +++ b/tests/Ratchet/Tests/Wamp/TopicManagerTest.php @@ -7,12 +7,20 @@ use Ratchet\Wamp\TopicManager; */ class TopicManagerTest extends \PHPUnit_Framework_TestCase { private $mock; + + /** + * @var \Ratchet\Wamp\TopicManager + */ private $mngr; + + /** + * @var \Ratchet\ConnectionInterface + */ private $conn; public function setUp() { - $this->conn = $this->getMock('Ratchet\\ConnectionInterface'); - $this->mock = $this->getMock('Ratchet\\Wamp\\WampServerInterface'); + $this->conn = $this->getMock('\Ratchet\ConnectionInterface'); + $this->mock = $this->getMock('\Ratchet\Wamp\\WampServerInterface'); $this->mngr = new TopicManager($this->mock); $this->conn->WAMP = new \StdClass;