From 3a50530edda2998212fc4452cbf9e53fed7603b1 Mon Sep 17 00:00:00 2001 From: Valentin Sickert <17144397+Lapotor@users.noreply.github.com> Date: Wed, 13 Dec 2023 05:02:11 +0100 Subject: [PATCH] change to put Signed-off-by: Valentin Sickert <17144397+Lapotor@users.noreply.github.com> --- app/Http/Controllers/UserController.php | 4 ++-- routes/api/v1/user.php | 2 +- tests/Feature/Http/Controllers/UserControllerTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index a79372f5..d8522173 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -51,8 +51,8 @@ public function show(User $user) public function update(Request $request, User $user) { $validated = $request->validate([ - 'name' => 'sometimes|required|string', - 'email' => "sometimes|required|email|unique:users,email", + 'name' => 'required|string', + 'email' => 'required|email|unique:users,email', 'password' => 'sometimes|required|min:8|confirmed', ]); diff --git a/routes/api/v1/user.php b/routes/api/v1/user.php index 87b9dd89..2c00c9b3 100644 --- a/routes/api/v1/user.php +++ b/routes/api/v1/user.php @@ -7,6 +7,6 @@ Route::get('/users', [UserController::class, 'index'])->name('api.v1.users.index'); Route::post('/users', [UserController::class, 'store'])->name('api.v1.users.store'); Route::get('/users/{user}', [UserController::class, 'show'])->name('api.v1.users.show'); - Route::patch('/users/{user}', [UserController::class, 'update'])->name('api.v1.users.update'); + Route::put('/users/{user}', [UserController::class, 'update'])->name('api.v1.users.update'); Route::delete('/users/{user}', [UserController::class, 'destroy'])->name('api.v1.users.destroy'); }); diff --git a/tests/Feature/Http/Controllers/UserControllerTest.php b/tests/Feature/Http/Controllers/UserControllerTest.php index fe7ce748..947800ce 100644 --- a/tests/Feature/Http/Controllers/UserControllerTest.php +++ b/tests/Feature/Http/Controllers/UserControllerTest.php @@ -108,7 +108,7 @@ public function test_users_update(): void $newUserData = array_merge($user->toArray(), $userData); // Send a PATCH request to the update endpoint - $response = $this->patch('/api/v1/users/' . $user->id, $userData); + $response = $this->put('/api/v1/users/' . $user->id, $userData); // Assert that the response has a successful status code $response->assertStatus(200);