Task 7 - update forbidden field

This commit is contained in:
PovilasKorop
2021-11-29 15:31:28 +02:00
parent ccb91e35fb
commit ce6827fab8
7 changed files with 109 additions and 0 deletions
+18
View File
@@ -81,4 +81,22 @@ class ValidationTest extends TestCase
]);
$response->assertStatus(200);
}
public function test_update_forbidden_field()
{
$user = User::factory()->create();
// field is_admin should not be possible to update
$updatedUser = [
'name' => 'Updated name',
'email' => 'updated@email.com',
'is_admin' => 1
];
$response = $this->put('users/' . $user->id, $updatedUser);
$response->assertStatus(200);
$user = User::where('name', $updatedUser['name'])->first();
$this->assertNotNull($user);
$this->assertEquals(false, $user->is_admin);
}
}