From 099115d6135d1c882388f5fd7cf00e0b24b59fa3 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Thu, 22 Jul 2021 18:53:31 +0200 Subject: [PATCH] tests/Feature/ProfileTest.php: test that user can not set an empty password hash. --- tests/Feature/ProfileTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/Feature/ProfileTest.php b/tests/Feature/ProfileTest.php index f0c45f0..b13ffc2 100644 --- a/tests/Feature/ProfileTest.php +++ b/tests/Feature/ProfileTest.php @@ -85,6 +85,26 @@ class ProfileTest extends TestCase ]); } + public function test_user_can_not_set_empty_password_hash() + { + $user = User::factory()->create([ 'password' => NULL ]); + + $response = $this->actingAs($user) + ->post(route('profile.update'), [ + 'username' => $user->username, + 'current_password' => '', + 'password' => '', + 'password_confirmation' => '' + ]); + + $response->assertRedirect(route('profile.index')); + + $this->assertDatabaseHas('users', [ + 'id' => $user->id, + 'password' => NULL + ]); + } + public function test_guest_can_not_update() { $response = $this->post(route('profile.update'), [