forked from ratchetphp/Ratchet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpRequestParserTest.php
More file actions
56 lines (44 loc) · 1.78 KB
/
HttpRequestParserTest.php
File metadata and controls
56 lines (44 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace Ratchet\Http;
use PHPUnit\Framework\TestCase;
/**
* @covers Ratchet\Http\HttpRequestParser
*/
class HttpRequestParserTest extends TestCase {
protected $parser;
public function setUp() {
$this->parser = new HttpRequestParser;
}
public function headersProvider() {
return array(
array(false, "GET / HTTP/1.1\r\nHost: socketo.me\r\n")
, array(true, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\n")
, array(true, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\n1")
, array(true, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\nHixie✖")
, array(true, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\nHixie✖\r\n\r\n")
, array(true, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\nHixie\r\n")
);
}
/**
* @dataProvider headersProvider
*/
public function testIsEom($expected, $message) {
$this->assertEquals($expected, $this->parser->isEom($message));
}
public function testBufferOverflowResponse() {
$conn = $this->getMockBuilder('Ratchet\ConnectionInterface')->getMock();
$this->parser->maxSize = 20;
$this->assertNull($this->parser->onMessage($conn, "GET / HTTP/1.1\r\n"));
if (method_exists($this, 'expectException')) {
$this->expectException('OverflowException');
} else {
$this->setExpectedException('OverflowException');
}
$this->parser->onMessage($conn, "Header-Is: Too Big");
}
public function testReturnTypeIsRequest() {
$conn = $this->getMockBuilder('Ratchet\ConnectionInterface')->getMock();
$return = $this->parser->onMessage($conn, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\n");
$this->assertInstanceOf('Psr\Http\Message\RequestInterface', $return);
}
}