Passing Tests
Finally able to do incomplete tests. Ratchet passes (finally).
This commit is contained in:
parent
e20a52dacc
commit
f766278a14
@ -20,6 +20,17 @@ class FrameTest extends \PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
protected static function convert($in) {
|
||||
if (strlen($in) > 8) {
|
||||
$out = '';
|
||||
|
||||
while (strlen($in) > 8) {
|
||||
$out .= static::convert(substr($in, 0, 8));
|
||||
$in = substr($in, 8);
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
return pack('C', bindec($in));
|
||||
}
|
||||
|
||||
@ -37,6 +48,31 @@ class FrameTest extends \PHPUnit_Framework_TestCase {
|
||||
);
|
||||
}
|
||||
|
||||
public static function underflowProvider() {
|
||||
return array(
|
||||
array('isFinal', '')
|
||||
, array('getOpcode', '')
|
||||
, array('isMasked', '10000001')
|
||||
, array('getPayloadLength', '10000001')
|
||||
, array('getPayloadLength', '1000000111111110')
|
||||
, array('getMaskingKey', '1000000110000111')
|
||||
, array('getPayload', '100000011000000100011100101010101001100111110100')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider underflowProvider
|
||||
*/
|
||||
public function testUnderflowExceptionFromAllTheMethodsMimickingBuffering($method, $bin) {
|
||||
$this->setExpectedException('\UnderflowException');
|
||||
|
||||
if (!empty($bin)) {
|
||||
$this->_frame->addBuffer(static::convert($bin));
|
||||
}
|
||||
|
||||
call_user_func(array($this->_frame, $method));
|
||||
}
|
||||
|
||||
/**
|
||||
* A data provider for testing the first byte of a WebSocket frame
|
||||
* @param bool Given, is the byte indicate this is the final frame
|
||||
@ -53,12 +89,6 @@ class FrameTest extends \PHPUnit_Framework_TestCase {
|
||||
);
|
||||
}
|
||||
|
||||
public function testUnderflowExceptionFromAllTheMethodsMimickingBuffering() {
|
||||
return $this->markTestIncomplete();
|
||||
|
||||
$this->expectException('\UnderflowException');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider firstByteProvider
|
||||
*/
|
||||
|
@ -2,6 +2,7 @@
|
||||
namespace Ratchet\Tests\Application\WebSocket\Version;
|
||||
use Ratchet\Application\WebSocket\Version\RFC6455;
|
||||
use Ratchet\Application\WebSocket\Version\RFC6455\Frame;
|
||||
use Guzzle\Http\Message\RequestFactory;
|
||||
|
||||
/**
|
||||
* @covers Ratchet\Application\WebSocket\Version\RFC6455
|
||||
@ -103,32 +104,25 @@ class RFC6455Test extends \PHPUnit_Framework_TestCase {
|
||||
public static function headerHandshakeProvider() {
|
||||
return array(
|
||||
array(false, "GET /test HTTP/1.0\r\n" . static::getAndSpliceHeader())
|
||||
, array(true, static::$good_rest . "\r\n" . static::getAndSpliceHeader())
|
||||
, array(false, "POST / HTTP:/1.1\r\n" . static::getAndSpliceHeader())
|
||||
, array(false, static::$good_rest . "\r\n" . static::getAndSpliceHeader('Upgrade', 'useless'))
|
||||
, array(false, "GET /ಠ_ಠ HTTP/1.1\r\n" . static::getAndSpliceHeader())
|
||||
, array(true, static::$good_rest . "\r\n" . static::getAndSpliceHeader('Connection', 'Herp, Upgrade, Derp'))
|
||||
);
|
||||
}
|
||||
|
||||
/* RFC example of a good header
|
||||
GET /chat HTTP/1.1
|
||||
Host: server.example.com
|
||||
Upgrade: websocket
|
||||
Connection: Upgrade
|
||||
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
|
||||
Origin: http://example.com
|
||||
Sec-WebSocket-Protocol: chat, superchat
|
||||
Sec-WebSocket-Version: 13
|
||||
*/
|
||||
|
||||
/**
|
||||
* @dataProvider headerHandshakeProvider
|
||||
* @todo Can't finish this test until I rewrite headers
|
||||
*/
|
||||
public function testVariousHeadersToCheckHandshakeTolerance($pass, $header) {
|
||||
return $this->markTestIncomplete();
|
||||
$request = RequestFactory::fromMessage($header);
|
||||
|
||||
if ($pass) {
|
||||
$this->assertTrue(is_array($this->_version->handshake($header)));
|
||||
$this->assertTrue(is_array($this->_version->handshake($request)));
|
||||
} else {
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->_version->handshake($header);
|
||||
$this->_version->handshake($request);
|
||||
}
|
||||
}
|
||||
}
|
@ -8,3 +8,4 @@
|
||||
$app->register();
|
||||
|
||||
$app = new SplClassLoader('Guzzle', dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'guzzle' . DIRECTORY_SEPARATOR . 'src');
|
||||
$app->register();
|
Loading…
Reference in New Issue
Block a user