Skip to content

Commit

Permalink
Updated test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
cboden committed Feb 20, 2016
1 parent bbc7818 commit 49cfd1e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ratchet/rfc6455",
"type": "library",
"description": "RFC6455 protocol handler",
"description": "RFC6455 WebSocket protocol handler",
"keywords": ["WebSockets", "websocket", "RFC6455"],
"homepage": "http://socketo.me",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Handshake/ResponseVerifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use Ratchet\RFC6455\Handshake\ResponseVerifier;

/**
* @covers Ratchet\WebSocket\Version\RFC6455\ResponseVerifier
* @covers Ratchet\RFC6455\Handshake\ResponseVerifier
*/
class ResponseVerifierTest extends \PHPUnit_Framework_TestCase {
/**
Expand Down Expand Up @@ -31,4 +31,4 @@ public static function subProtocolsProvider() {
public function testVerifySubProtocol($expected, $response, $request) {
$this->assertEquals($expected, $this->_v->verifySubProtocol($response, $request));
}
}
}
94 changes: 47 additions & 47 deletions tests/unit/Messaging/FrameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use Ratchet\RFC6455\Messaging\Frame;

/**
* @covers Ratchet\RFC6455\MessagingFrame
* @covers Ratchet\RFC6455\Messaging\Frame
* @todo getMaskingKey, getPayloadStartingByte don't have tests yet
* @todo Could use some clean up in general, I had to rush to fix a bug for a deadline, sorry.
*/
Expand Down Expand Up @@ -73,15 +73,15 @@ public static function underflowProvider() {
/**
* @dataProvider underflowProvider
*
* covers Ratchet\WebSocket\Version\RFC6455\Frame::isFinal
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getRsv1
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getRsv2
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getRsv3
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getOpcode
* covers Ratchet\WebSocket\Version\RFC6455\Frame::isMasked
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getPayloadLength
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getMaskingKey
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getPayload
* @covers Ratchet\RFC6455\Messaging\Frame::isFinal
* @covers Ratchet\RFC6455\Messaging\Frame::getRsv1
* @covers Ratchet\RFC6455\Messaging\Frame::getRsv2
* @covers Ratchet\RFC6455\Messaging\Frame::getRsv3
* @covers Ratchet\RFC6455\Messaging\Frame::getOpcode
* @covers Ratchet\RFC6455\Messaging\Frame::isMasked
* @covers Ratchet\RFC6455\Messaging\Frame::getPayloadLength
* @covers Ratchet\RFC6455\Messaging\Frame::getMaskingKey
* @covers Ratchet\RFC6455\Messaging\Frame::getPayload
*/
public function testUnderflowExceptionFromAllTheMethodsMimickingBuffering($method, $bin) {
$this->setExpectedException('\UnderflowException');
Expand Down Expand Up @@ -110,7 +110,7 @@ public static function firstByteProvider() {

/**
* @dataProvider firstByteProvider
* covers Ratchet\WebSocket\Version\RFC6455\Frame::isFinal
* covers Ratchet\RFC6455\Messaging\Frame::isFinal
*/
public function testFinCodeFromBits($fin, $rsv1, $rsv2, $rsv3, $opcode, $bin) {
$this->_frame->addBuffer(static::encode($bin));
Expand All @@ -119,9 +119,9 @@ public function testFinCodeFromBits($fin, $rsv1, $rsv2, $rsv3, $opcode, $bin) {

/**
* @dataProvider firstByteProvider
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getRsv1
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getRsv2
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getRsv3
* covers Ratchet\RFC6455\Messaging\Frame::getRsv1
* covers Ratchet\RFC6455\Messaging\Frame::getRsv2
* covers Ratchet\RFC6455\Messaging\Frame::getRsv3
*/
public function testGetRsvFromBits($fin, $rsv1, $rsv2, $rsv3, $opcode, $bin) {
$this->_frame->addBuffer(static::encode($bin));
Expand All @@ -132,7 +132,7 @@ public function testGetRsvFromBits($fin, $rsv1, $rsv2, $rsv3, $opcode, $bin) {

/**
* @dataProvider firstByteProvider
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getOpcode
* covers Ratchet\RFC6455\Messaging\Frame::getOpcode
*/
public function testOpcodeFromBits($fin, $rsv1, $rsv2, $rsv3, $opcode, $bin) {
$this->_frame->addBuffer(static::encode($bin));
Expand All @@ -141,7 +141,7 @@ public function testOpcodeFromBits($fin, $rsv1, $rsv2, $rsv3, $opcode, $bin) {

/**
* @dataProvider UnframeMessageProvider
* covers Ratchet\WebSocket\Version\RFC6455\Frame::isFinal
* covers Ratchet\RFC6455\Messaging\Frame::isFinal
*/
public function testFinCodeFromFullMessage($msg, $encoded) {
$this->_frame->addBuffer(base64_decode($encoded));
Expand All @@ -150,7 +150,7 @@ public function testFinCodeFromFullMessage($msg, $encoded) {

/**
* @dataProvider UnframeMessageProvider
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getOpcode
* covers Ratchet\RFC6455\Messaging\Frame::getOpcode
*/
public function testOpcodeFromFullMessage($msg, $encoded) {
$this->_frame->addBuffer(base64_decode($encoded));
Expand All @@ -170,8 +170,8 @@ public static function payloadLengthDescriptionProvider() {

/**
* @dataProvider payloadLengthDescriptionProvider
* covers Ratchet\WebSocket\Version\RFC6455\Frame::addBuffer
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getFirstPayloadVal
* covers Ratchet\RFC6455\Messaging\Frame::addBuffer
* covers Ratchet\RFC6455\Messaging\Frame::getFirstPayloadVal
*/
public function testFirstPayloadDesignationValue($bits, $bin) {
$this->_frame->addBuffer(static::encode($this->_firstByteFinText));
Expand All @@ -183,7 +183,7 @@ public function testFirstPayloadDesignationValue($bits, $bin) {
}

/**
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getFirstPayloadVal
* covers Ratchet\RFC6455\Messaging\Frame::getFirstPayloadVal
*/
public function testFirstPayloadValUnderflow() {
$ref = new \ReflectionClass($this->_frame);
Expand All @@ -195,7 +195,7 @@ public function testFirstPayloadValUnderflow() {

/**
* @dataProvider payloadLengthDescriptionProvider
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getNumPayloadBits
* covers Ratchet\RFC6455\Messaging\Frame::getNumPayloadBits
*/
public function testDetermineHowManyBitsAreUsedToDescribePayload($expected_bits, $bin) {
$this->_frame->addBuffer(static::encode($this->_firstByteFinText));
Expand All @@ -207,7 +207,7 @@ public function testDetermineHowManyBitsAreUsedToDescribePayload($expected_bits,
}

/**
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getNumPayloadBits
* covers Ratchet\RFC6455\Messaging\Frame::getNumPayloadBits
*/
public function testgetNumPayloadBitsUnderflow() {
$ref = new \ReflectionClass($this->_frame);
Expand All @@ -226,7 +226,7 @@ public function secondByteProvider() {
}
/**
* @dataProvider secondByteProvider
* covers Ratchet\WebSocket\Version\RFC6455\Frame::isMasked
* covers Ratchet\RFC6455\Messaging\Frame::isMasked
*/
public function testIsMaskedReturnsExpectedValue($masked, $payload_length, $bin) {
$this->_frame->addBuffer(static::encode($this->_firstByteFinText));
Expand All @@ -236,7 +236,7 @@ public function testIsMaskedReturnsExpectedValue($masked, $payload_length, $bin)

/**
* @dataProvider UnframeMessageProvider
* covers Ratchet\WebSocket\Version\RFC6455\Frame::isMasked
* covers Ratchet\RFC6455\Messaging\Frame::isMasked
*/
public function testIsMaskedFromFullMessage($msg, $encoded) {
$this->_frame->addBuffer(base64_decode($encoded));
Expand All @@ -245,7 +245,7 @@ public function testIsMaskedFromFullMessage($msg, $encoded) {

/**
* @dataProvider secondByteProvider
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getPayloadLength
* covers Ratchet\RFC6455\Messaging\Frame::getPayloadLength
*/
public function testGetPayloadLengthWhenOnlyFirstFrameIsUsed($masked, $payload_length, $bin) {
$this->_frame->addBuffer(static::encode($this->_firstByteFinText));
Expand All @@ -255,7 +255,7 @@ public function testGetPayloadLengthWhenOnlyFirstFrameIsUsed($masked, $payload_l

/**
* @dataProvider UnframeMessageProvider
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getPayloadLength
* covers Ratchet\RFC6455\Messaging\Frame::getPayloadLength
* @todo Not yet testing when second additional payload length descriptor
*/
public function testGetPayloadLengthFromFullMessage($msg, $encoded) {
Expand All @@ -274,7 +274,7 @@ public function maskingKeyProvider() {

/**
* @dataProvider maskingKeyProvider
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getMaskingKey
* covers Ratchet\RFC6455\Messaging\Frame::getMaskingKey
* @todo I I wrote the dataProvider incorrectly, skipping for now
*/
public function testGetMaskingKey($mask) {
Expand All @@ -285,7 +285,7 @@ public function testGetMaskingKey($mask) {
}

/**
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getMaskingKey
* covers Ratchet\RFC6455\Messaging\Frame::getMaskingKey
*/
public function testGetMaskingKeyOnUnmaskedPayload() {
$frame = new Frame('Hello World!');
Expand All @@ -294,7 +294,7 @@ public function testGetMaskingKeyOnUnmaskedPayload() {

/**
* @dataProvider UnframeMessageProvider
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getPayload
* covers Ratchet\RFC6455\Messaging\Frame::getPayload
* @todo Move this test to bottom as it requires all methods of the class
*/
public function testUnframeFullMessage($unframed, $base_framed) {
Expand All @@ -310,7 +310,7 @@ public static function messageFragmentProvider() {

/**
* @dataProvider UnframeMessageProvider
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getPayload
* covers Ratchet\RFC6455\Messaging\Frame::getPayload
*/
public function testCheckPiecingTogetherMessage($msg, $encoded) {
$framed = base64_decode($encoded);
Expand All @@ -321,9 +321,9 @@ public function testCheckPiecingTogetherMessage($msg, $encoded) {
}

/**
* covers Ratchet\WebSocket\Version\RFC6455\Frame::__construct
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getPayloadLength
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getPayload
* covers Ratchet\RFC6455\Messaging\Frame::__construct
* covers Ratchet\RFC6455\Messaging\Frame::getPayloadLength
* covers Ratchet\RFC6455\Messaging\Frame::getPayload
*/
public function testLongCreate() {
$len = 65525;
Expand All @@ -337,17 +337,17 @@ public function testLongCreate() {
}

/**
* covers Ratchet\WebSocket\Version\RFC6455\Frame::__construct
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getPayloadLength
* covers Ratchet\RFC6455\Messaging\Frame::__construct
* covers Ratchet\RFC6455\Messaging\Frame::getPayloadLength
*/
public function testReallyLongCreate() {
$len = 65575;
$frame = new Frame($this->generateRandomString($len));
$this->assertEquals($len, $frame->getPayloadLength());
}
/**
* covers Ratchet\WebSocket\Version\RFC6455\Frame::__construct
* covers Ratchet\WebSocket\Version\RFC6455\Frame::extractOverflow
* covers Ratchet\RFC6455\Messaging\Frame::__construct
* covers Ratchet\RFC6455\Messaging\Frame::extractOverflow
*/
public function testExtractOverflow() {
$string1 = $this->generateRandomString();
Expand All @@ -365,7 +365,7 @@ public function testExtractOverflow() {
}

/**
* covers Ratchet\WebSocket\Version\RFC6455\Frame::extractOverflow
* covers Ratchet\RFC6455\Messaging\Frame::extractOverflow
*/
public function testEmptyExtractOverflow() {
$string = $this->generateRandomString();
Expand All @@ -376,7 +376,7 @@ public function testEmptyExtractOverflow() {
}

/**
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getContents
* covers Ratchet\RFC6455\Messaging\Frame::getContents
*/
public function testGetContents() {
$msg = 'The quick brown fox jumps over the lazy dog.';
Expand All @@ -388,7 +388,7 @@ public function testGetContents() {
}

/**
* covers Ratchet\WebSocket\Version\RFC6455\Frame::maskPayload
* covers Ratchet\RFC6455\Messaging\Frame::maskPayload
*/
public function testMasking() {
$msg = 'The quick brown fox jumps over the lazy dog.';
Expand All @@ -399,7 +399,7 @@ public function testMasking() {
}

/**
* covers Ratchet\WebSocket\Version\RFC6455\Frame::unMaskPayload
* covers Ratchet\RFC6455\Messaging\Frame::unMaskPayload
*/
public function testUnMaskPayload() {
$string = $this->generateRandomString();
Expand All @@ -410,7 +410,7 @@ public function testUnMaskPayload() {
}

/**
* covers Ratchet\WebSocket\Version\RFC6455\Frame::generateMaskingKey
* covers Ratchet\RFC6455\Messaging\Frame::generateMaskingKey
*/
public function testGenerateMaskingKey() {
$dupe = false;
Expand All @@ -427,15 +427,15 @@ public function testGenerateMaskingKey() {
}

/**
* covers Ratchet\WebSocket\Version\RFC6455\Frame::maskPayload
* covers Ratchet\RFC6455\Messaging\Frame::maskPayload
*/
public function testGivenMaskIsValid() {
$this->setExpectedException('InvalidArgumentException');
$this->_frame->maskPayload('hello world');
}

/**
* covers Ratchet\WebSocket\Version\RFC6455\Frame::maskPayload
* covers Ratchet\RFC6455\Messaging\Frame::maskPayload
*/
public function testGivenMaskIsValidAscii() {
if (!extension_loaded('mbstring')) {
Expand Down Expand Up @@ -471,8 +471,8 @@ protected function generateRandomString($length = 10, $addSpaces = true, $addNum
*
* This is fixed by setting the defPayLen back to -1 before the underflow exception is thrown.
*
* covers Ratchet\WebSocket\Version\RFC6455\Frame::getPayloadLength
* covers Ratchet\WebSocket\Version\RFC6455\Frame::extractOverflow
* covers Ratchet\RFC6455\Messaging\Frame::getPayloadLength
* covers Ratchet\RFC6455\Messaging\Frame::extractOverflow
*/
public function testFrameDeliveredOneByteAtATime() {
$startHeader = "\x01\x7e\x01\x00"; // header for a text frame of 256 - non-final
Expand All @@ -498,4 +498,4 @@ public function testFrameDeliveredOneByteAtATime() {
// make sure the overflow is good
$this->assertEquals($rawOverflow, $frame->extractOverflow());
}
}
}

0 comments on commit 49cfd1e

Please sign in to comment.