Skip to content

Commit 58c1b94

Browse files
committed
wip
1 parent 88776d1 commit 58c1b94

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

http-tests.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- [Available Assertions](#available-assertions)
1616
- [Response Assertions](#response-assertions)
1717
- [Authentication Assertions](#authentication-assertions)
18+
- [Validation Assertions](#validation-assertions)
1819

1920
<a name="introduction"></a>
2021
## Introduction
@@ -1287,3 +1288,33 @@ Assert that a user is not authenticated:
12871288
Assert that a specific user is authenticated:
12881289

12891290
$this->assertAuthenticatedAs($user, $guard = null);
1291+
1292+
<a name="validation-assertions"></a>
1293+
## Validation Assertions
1294+
1295+
Laravel provides two primary validation related assertions that you may use to ensure the data provided in your request was either valid or invalid.
1296+
1297+
<a name="validation-assert-valid"></a>
1298+
#### assertValid
1299+
1300+
Assert that the response has no validation errors for the given keys. This method may be used for asserting against responses where the validation errors are returned as a JSON structure or where the validation errors have been flashed to the session:
1301+
1302+
// Assert that no validation errors are present...
1303+
$response->assertValid();
1304+
1305+
// Assert that the given keys do not have validation errors...
1306+
$response->assertValid(['name', 'email']);
1307+
1308+
<a name="validation-assert-invalid"></a>
1309+
#### assertInvalid
1310+
1311+
Assert that the response has validation errors for the given keys. This method may be used for asserting against responses where the validation errors are returned as a JSON structure or where the validation errors have been flashed to the session:
1312+
1313+
$response->assertInvalid(['name', 'email']);
1314+
1315+
You may also assert that a given key has a particular validation error message. When doing so, you may provide the entire message or only a small portion of the message:
1316+
1317+
$response->assertInvalid([
1318+
'name' => 'The name field is required.',
1319+
'email' => 'valid email address',
1320+
]);

0 commit comments

Comments
 (0)