user = User::create([ 'msnv' => 5001, 'name' => 'Test User', 'mail' => 'test@example.com', 'pass' => md5('password123'), 'departments' => 1, 'role' => User::ROLE_MEMBER, 'status' => User::STATUS_ACTIVE, 'card' => 10, 'flag_send' => User::FLAG_SEND_ENABLED, 'first_login' => User::FIRST_LOGIN_TRUE, ]); } public function test_password_change_requires_fields(): void { $res = $this->actingAs($this->user) ->post(route('user.update_password'), [ 'password' => '', 'password_confirmation' => '', ]); $res->assertSessionHasErrors([ 'password' => 'Mật khẩu mới không được để trống.', ]); } public function test_password_change_requires_minimum_length(): void { $res = $this->actingAs($this->user) ->post(route('user.update_password'), [ 'password' => '123', 'password_confirmation' => '123', ]); $res->assertSessionHasErrors([ 'password' => 'Mật khẩu mới phải có ít nhất 6 ký tự.', ]); } public function test_password_change_requires_confirmation_match(): void { $res = $this->actingAs($this->user) ->post(route('user.update_password'), [ 'password' => 'newpassword123', 'password_confirmation' => 'differentpassword', ]); $res->assertSessionHasErrors([ 'password' => 'Mật khẩu xác nhận không trùng khớp.', ]); } }