opnform/tests/Feature/SettingsTest.php

32 lines
855 B
PHP
Raw Normal View History

2022-09-20 19:59:52 +00:00
<?php
use App\Models\User;
use Illuminate\Support\Facades\Hash;
2024-02-23 10:54:12 +00:00
it('update profile info', function () {
$this->actingAs($user = User::factory()->create())
->patchJson('/settings/profile', [
2022-09-20 19:59:52 +00:00
'name' => 'Test User',
'email' => 'test@test.app',
2024-02-23 10:54:12 +00:00
])
->assertSuccessful()
->assertJsonStructure(['id', 'name', 'email']);
$this->assertDatabaseHas('users', [
'id' => $user->id,
'name' => 'Test User',
'email' => 'test@test.app',
]);
2022-09-20 19:59:52 +00:00
});
2024-02-23 10:54:12 +00:00
it('update password', function () {
$this->actingAs($user = User::factory()->create())
->patchJson('/settings/password', [
'password' => 'updated',
'password_confirmation' => 'updated',
])
->assertSuccessful();
2022-09-20 19:59:52 +00:00
2024-02-23 10:54:12 +00:00
$this->assertTrue(Hash::check('updated', $user->password));
2022-09-20 19:59:52 +00:00
});