From 067056878972fb045b5dea5a6f978c2c6881ad11 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Sun, 20 Nov 2011 22:36:14 -0500 Subject: [PATCH] Unit Tests and fixes Set some incomplete tests to pass Updated an interface bug found from unit tests --- lib/Ratchet/Resource/Connection.php | 2 +- .../WebSocket/Version/HyBi10/FrameTest.php | 17 ++++++++--------- tests/Ratchet/Tests/Resource/ConnectionTest.php | 3 ++- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/Ratchet/Resource/Connection.php b/lib/Ratchet/Resource/Connection.php index 3c47865..28e6196 100644 --- a/lib/Ratchet/Resource/Connection.php +++ b/lib/Ratchet/Resource/Connection.php @@ -49,7 +49,7 @@ class Connection { * @return mixed * @throws \InvalidArgumentException */ - public function &__get($name) { + public function __get($name) { if (!$this->__isset($name)) { throw new \InvalidArgumentException("Attribute '{$name}' not found in Connection {$this->getID()}"); } diff --git a/tests/Ratchet/Tests/Application/WebSocket/Version/HyBi10/FrameTest.php b/tests/Ratchet/Tests/Application/WebSocket/Version/HyBi10/FrameTest.php index 0dbd13b..aea8c99 100644 --- a/tests/Ratchet/Tests/Application/WebSocket/Version/HyBi10/FrameTest.php +++ b/tests/Ratchet/Tests/Application/WebSocket/Version/HyBi10/FrameTest.php @@ -240,17 +240,16 @@ class FrameTest extends \PHPUnit_Framework_TestCase { } /** - * @dataProvider messageFragmentProvider + * @dataProvider UnframeMessageProvider */ - public function testCheckPiecingTogetherMessage($coalesced, $first_bin, $secnd_bin, $mask, $payload1, $payload2) { - return $this->markTestIncomplete('Ran out of time, had to attend to something else, come finish me!'); + public function testCheckPiecingTogetherMessage($msg, $encoded) { +// return $this->markTestIncomplete('Ran out of time, had to attend to something else, come finish me!'); - $this->_frame->addBuffer(static::convert($first_bin)); - $this->_frame->addBuffer(static::convert($second_bin)); - // mask? -// $this->_frame->addBuffer( -// $this->_frame->addBuffer( + $framed = base64_decode($encoded); + for ($i = 0, $len = strlen($framed);$i < $len; $i++) { + $this->_frame->addBuffer(substr($framed, $i, 1)); + } - $this->assertEquals($coalesced, $this->_frame->isCoalesced()); + $this->assertEquals($msg, $this->_frame->getPayload()); } } \ No newline at end of file diff --git a/tests/Ratchet/Tests/Resource/ConnectionTest.php b/tests/Ratchet/Tests/Resource/ConnectionTest.php index 490e3e2..1e25a0e 100644 --- a/tests/Ratchet/Tests/Resource/ConnectionTest.php +++ b/tests/Ratchet/Tests/Resource/ConnectionTest.php @@ -39,7 +39,8 @@ class ConnectionTest extends \PHPUnit_Framework_TestCase { } public function testLambdaReturnValueOnGet() { - $this->markTestIncomplete(); + $this->_c->lambda = function() { return 'Hello World!'; }; + $this->assertEquals('Hello World!', $this->_c->lambda); } /**