-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResponseTest.php
More file actions
65 lines (58 loc) · 1.75 KB
/
Copy pathResponseTest.php
File metadata and controls
65 lines (58 loc) · 1.75 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
<?php
namespace bdk\Test\HttpMessage;
use bdk\HttpMessage\Message;
use bdk\HttpMessage\Response;
/**
* @covers \bdk\HttpMessage\AssertionTrait
* @covers \bdk\HttpMessage\Response
*/
class ResponseTest extends TestCase
{
public function testConstruct()
{
$response = new Response();
$this->assertTrue($response instanceof Response);
$this->assertTrue($response instanceof Message);
}
/**
* @param mixed $code status code to test
* @param mixed $phrase phrase to test
* @param string $phraseExpect expected phrase
*
* @dataProvider statusPhrases
*/
public function testStatusPhrases($code, $phrase, $phraseExpect)
{
$response = $this->createResponse($code, $phrase);
$response->withStatus($code, $phrase);
$this->assertSame((int) $code, $response->getStatusCode());
$this->assertSame($phraseExpect, $response->getReasonPhrase());
}
/*
Exceptions
*/
/**
* @param mixed $statusCode status code to test
*
* @dataProvider invalidStatusCodes
*/
public function testRejectInvalidStatusCode($statusCode)
{
self::assertExceptionOrTypeError(function () use ($statusCode) {
$response = $this->createResponse();
$response->withStatus($statusCode, 'Custom reason phrase');
});
}
/**
* @param mixed $reasonPhrase reason phrase to test
*
* @dataProvider invalidReasonPhrases
*/
public function testRejectInvalidReasonPhrase($reasonPhrase)
{
self::assertExceptionOrTypeError(function () use ($reasonPhrase) {
$response = $this->createResponse();
$response->withStatus(200, $reasonPhrase);
});
}
}