@@ 14-28 (lines=15) @@ | ||
11 | ||
12 | class HttplugFactoryTest extends TestCase |
|
13 | { |
|
14 | public function testCreateRequest() |
|
15 | { |
|
16 | $factory = new HttplugFactory(); |
|
17 | $r = $factory->createRequest('POST', 'https://nyholm.tech', ['Content-Type' => 'text/html'], 'foobar', '2.0'); |
|
18 | ||
19 | $this->assertEquals('POST', $r->getMethod()); |
|
20 | $this->assertEquals('https://nyholm.tech', $r->getUri()->__toString()); |
|
21 | $this->assertEquals('2.0', $r->getProtocolVersion()); |
|
22 | $this->assertEquals('foobar', $r->getBody()->__toString()); |
|
23 | ||
24 | $headers = $r->getHeaders(); |
|
25 | $this->assertCount(2, $headers); // Including HOST |
|
26 | $this->assertArrayHasKey('Content-Type', $headers); |
|
27 | $this->assertEquals('text/html', $headers['Content-Type'][0]); |
|
28 | } |
|
29 | ||
30 | public function testCreateResponse() |
|
31 | { |
|
@@ 30-44 (lines=15) @@ | ||
27 | $this->assertEquals('text/html', $headers['Content-Type'][0]); |
|
28 | } |
|
29 | ||
30 | public function testCreateResponse() |
|
31 | { |
|
32 | $factory = new HttplugFactory(); |
|
33 | $r = $factory->createResponse(217, 'Perfect', ['Content-Type' => 'text/html'], 'foobar', '2.0'); |
|
34 | ||
35 | $this->assertEquals(217, $r->getStatusCode()); |
|
36 | $this->assertEquals('Perfect', $r->getReasonPhrase()); |
|
37 | $this->assertEquals('2.0', $r->getProtocolVersion()); |
|
38 | $this->assertEquals('foobar', $r->getBody()->__toString()); |
|
39 | ||
40 | $headers = $r->getHeaders(); |
|
41 | $this->assertCount(1, $headers); |
|
42 | $this->assertArrayHasKey('Content-Type', $headers); |
|
43 | $this->assertEquals('text/html', $headers['Content-Type'][0]); |
|
44 | } |
|
45 | ||
46 | public function testCreateStream() |
|
47 | { |