-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHttpTest.php
109 lines (102 loc) · 2.13 KB
/
HttpTest.php
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* @author Pierre-Henry Soria <hi@ph7.me>
* @website https://pH7.me
* @license MIT License
*/
declare(strict_types=1);
namespace PH7\PhpHttpResponseHeader\Tests;
use PH7\PhpHttpResponseHeader\Http;
use PHPUnit\Framework\TestCase;
final class HttpTest extends TestCase
{
/**
* @dataProvider validStatusCodesProvider
*/
public function testValidStatusCode(int $validCode): void
{
$response = Http::getStatusCode($validCode);
$this->assertIsString($response);
}
/**
* @dataProvider invalidStatusCodesProvider
*/
public function testInvalidStatusCode(int $invalidCode): void
{
$response = Http::getStatusCode($invalidCode);
$this->assertFalse($response);
}
public static function validStatusCodesProvider(): array
{
return [
[100],
[101],
[102],
[103],
[200],
[201],
[202],
[203],
[204],
[205],
[206],
[207],
[208],
[226],
[300],
[301],
[302],
[303],
[304],
[305],
[307],
[308],
[400],
[401],
[402],
[403],
[404],
[405],
[406],
[407],
[408],
[409],
[410],
[411],
[412],
[413],
[414],
[415],
[416],
[417],
[422],
[423],
[424],
[425],
[426],
[428],
[429],
[431],
[500],
[501],
[502],
[503],
[504],
[505],
[506],
[507],
[508],
[509],
[510],
[511],
[598],
[599]
];
}
public static function invalidStatusCodesProvider(): array
{
return [
[600, 1000, 0, 1, 1010]
];
}
}