-
Notifications
You must be signed in to change notification settings - Fork 11.2k
/
Copy pathAssertsStatusCodes.php
253 lines (225 loc) · 5.19 KB
/
AssertsStatusCodes.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<?php
namespace Illuminate\Testing\Concerns;
use Illuminate\Testing\Assert as PHPUnit;
trait AssertsStatusCodes
{
/**
* Assert that the response has a 200 "OK" status code.
*
* @return $this
*/
public function assertOk()
{
return $this->assertStatus(200);
}
/**
* Assert that the response has a 201 "Created" status code.
*
* @return $this
*/
public function assertCreated()
{
return $this->assertStatus(201);
}
/**
* Assert that the response has a 202 "Accepted" status code.
*
* @return $this
*/
public function assertAccepted()
{
return $this->assertStatus(202);
}
/**
* Assert that the response has the given status code and no content.
*
* @param int $status
* @return $this
*/
public function assertNoContent($status = 204)
{
$this->assertStatus($status);
PHPUnit::assertEmpty($this->getContent(), 'Response content is not empty.');
return $this;
}
/**
* Assert that the response has a 301 "Moved Permanently" status code.
*
* @return $this
*/
public function assertMovedPermanently()
{
return $this->assertStatus(301);
}
/**
* Assert that the response has a 302 "Found" status code.
*
* @return $this
*/
public function assertFound()
{
return $this->assertStatus(302);
}
/**
* Assert that the response has a 304 "Not Modified" status code.
*
* @return $this
*/
public function assertNotModified()
{
return $this->assertStatus(304);
}
/**
* Assert that the response has a 307 "Temporary Redirect" status code.
*
* @return $this
*/
public function assertTemporaryRedirect()
{
return $this->assertStatus(307);
}
/**
* Assert that the response has a 308 "Permanent Redirect" status code.
*
* @return $this
*/
public function assertPermanentRedirect()
{
return $this->assertStatus(308);
}
/**
* Assert that the response has a 400 "Bad Request" status code.
*
* @return $this
*/
public function assertBadRequest()
{
return $this->assertStatus(400);
}
/**
* Assert that the response has a 401 "Unauthorized" status code.
*
* @return $this
*/
public function assertUnauthorized()
{
return $this->assertStatus(401);
}
/**
* Assert that the response has a 402 "Payment Required" status code.
*
* @return $this
*/
public function assertPaymentRequired()
{
return $this->assertStatus(402);
}
/**
* Assert that the response has a 403 "Forbidden" status code.
*
* @return $this
*/
public function assertForbidden()
{
return $this->assertStatus(403);
}
/**
* Assert that the response has a 404 "Not Found" status code.
*
* @return $this
*/
public function assertNotFound()
{
return $this->assertStatus(404);
}
/**
* Assert that the response has a 405 "Method Not Allowed" status code.
*
* @return $this
*/
public function assertMethodNotAllowed()
{
return $this->assertStatus(405);
}
/**
* Assert that the response has a 406 "Not Acceptable" status code.
*
* @return $this
*/
public function assertNotAcceptable()
{
return $this->assertStatus(406);
}
/**
* Assert that the response has a 408 "Request Timeout" status code.
*
* @return $this
*/
public function assertRequestTimeout()
{
return $this->assertStatus(408);
}
/**
* Assert that the response has a 409 "Conflict" status code.
*
* @return $this
*/
public function assertConflict()
{
return $this->assertStatus(409);
}
/**
* Assert that the response has a 410 "Gone" status code.
*
* @return $this
*/
public function assertGone()
{
return $this->assertStatus(410);
}
/**
* Assert that the response has a 415 "Unsupported Media Type" status code.
*
* @return $this
*/
public function assertUnsupportedMediaType()
{
return $this->assertStatus(415);
}
/**
* Assert that the response has a 422 "Unprocessable Content" status code.
*
* @return $this
*/
public function assertUnprocessable()
{
return $this->assertStatus(422);
}
/**
* Assert that the response has a 429 "Too Many Requests" status code.
*
* @return $this
*/
public function assertTooManyRequests()
{
return $this->assertStatus(429);
}
/**
* Assert that the response has a 500 "Internal Server Error" status code.
*
* @return $this
*/
public function assertInternalServerError()
{
return $this->assertStatus(500);
}
/**
* Assert that the response has a 503 "Service Unavailable" status code.
*
* @return $this
*/
public function assertServiceUnavailable()
{
return $this->assertStatus(503);
}
}