Skip to content
This repository was archived by the owner on Feb 18, 2023. It is now read-only.

Commit 0eaec46

Browse files
author
joselfonseca
committed
add one more test
1 parent 8460875 commit 0eaec46

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/Feature/Auth/RegisterTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,19 @@ public function test_it_validates_input_for_registration()
5656
]);
5757
Event::assertNotDispatched(Registered::class);
5858
}
59+
60+
public function test_it_returns_422_on_validation_error()
61+
{
62+
Event::fake([Registered::class]);
63+
$response = $this->json('POST', 'api/register', [
64+
'name' => 'Some User',
65+
]);
66+
$response->assertStatus(422);
67+
$this->assertEquals('{"message":"The given data was invalid.","status_code":422,"errors":{"email":["The email field is required."],"password":["The password field is required."]}}', $response->getContent());
68+
$this->assertDatabaseMissing('users', [
69+
'name' => 'Some User',
70+
'email' => '[email protected]',
71+
]);
72+
Event::assertNotDispatched(Registered::class);
73+
}
5974
}

0 commit comments

Comments
 (0)