-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResponseTest.php
More file actions
42 lines (37 loc) · 1.25 KB
/
Copy pathResponseTest.php
File metadata and controls
42 lines (37 loc) · 1.25 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
<?php
namespace bdk\Test\HttpMessage\Utility;
use bdk\HttpMessage\Response;
use bdk\HttpMessage\Stream;
use bdk\HttpMessage\Utility\ContentType;
use bdk\HttpMessage\Utility\Response as ResponseUtil;
use PHPUnit\Framework\TestCase;
/**
* @covers bdk\HttpMessage\Utility\Response
*
* @phpcs:disable SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys.IncorrectKeyOrder
*/
class ResponseTest extends TestCase
{
public function testEmit()
{
// self::assertSame($expect, UriUtils::isCrossOrigin(new Uri($uri1), new Uri($uri2)));
$body = \json_encode(array(
'foo' => 'bar',
));
$response = new Response(418);
$response = $response->withBody(new Stream($body));
$response = $response->withHeader('Content-Type', ContentType::JSON);
\ob_start();
ResponseUtil::emit($response);
$output = \ob_get_clean();
self::assertSame(array(
array('HTTP/1.1 418 I\'m a teapot', true, 418),
array('Content-Type: ' . ContentType::JSON, false),
), $GLOBALS['collectedHeaders']);
self::assertSame($body, $output);
}
public function testCodePhrase()
{
self::assertSame('I\'m a teapot', ResponseUtil::codePhrase('418'));
}
}