-
-
Notifications
You must be signed in to change notification settings - Fork 466
Expand file tree
/
Copy pathResponseTest.php
More file actions
71 lines (62 loc) · 2.25 KB
/
ResponseTest.php
File metadata and controls
71 lines (62 loc) · 2.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
declare(strict_types=1);
namespace Sentry\Tests\HttpClient;
use PHPUnit\Framework\TestCase;
use Sentry\HttpClient\Response;
final class ResponseTest extends TestCase
{
public function testResponseSuccess(): void
{
$response = new Response(
200,
[
'Content-Type' => [
'application/json',
],
],
''
);
$this->assertSame(200, $response->getStatusCode());
$this->assertTrue($response->isSuccess());
$this->assertTrue($response->hasHeader('content-type'));
$this->assertSame(['application/json'], $response->getHeader('content-type'));
$this->assertSame(['application/json'], $response->getHeader('Content-Type'));
$this->assertSame('application/json', $response->getHeaderLine('content-type'));
$this->assertSame('application/json', $response->getHeaderLine('Content-Type'));
$this->assertSame('', $response->getError());
$this->assertFalse($response->hasError());
}
public function testResponseFailure(): void
{
$response = new Response(
500,
[],
'Something went wrong!'
);
$this->assertSame(500, $response->getStatusCode());
$this->assertFalse($response->isSuccess());
$this->assertFalse($response->hasHeader('content-type'));
$this->assertSame([], $response->getHeader('content-type'));
$this->assertSame([], $response->getHeader('Content-Type'));
$this->assertSame('', $response->getHeaderLine('content-type'));
$this->assertSame('', $response->getHeaderLine('Content-Type'));
$this->assertSame('Something went wrong!', $response->getError());
$this->assertTrue($response->hasError());
}
public function testResponseMultiValueHeader(): void
{
$response = new Response(
200,
[
'X-Foo' => [
'one',
'two',
'three',
],
],
''
);
$this->assertSame(['one', 'two', 'three'], $response->getHeader('x-foo'));
$this->assertSame('one,two,three', $response->getHeaderLine('x-foo'));
}
}