1
0
Fork 0

Refactor UserController to ProfileController.

This commit is contained in:
Henrik Hautakoski 2021-07-20 15:38:57 +02:00
parent 5117907a4d
commit b76a997948
9 changed files with 23 additions and 23 deletions

View file

@ -43,7 +43,7 @@ class CharacterCreateTest extends TestCase
->set('character.race', 'human')
->set('character.gender', 'F')
->call('save')
->assertRedirect(route('user.index'));
->assertRedirect(route('profile.index'));
// Find character and check the data.
$character = Character::where('name', 'Elise')->first();

View file

@ -57,7 +57,7 @@ class CharacterUpdateTest extends TestCase
->set('character.race', 'dwarf')
->set('character.gender', 'F')
->call('save')
->assertRedirect(route('user.index'));
->assertRedirect(route('profile.index'));
// Check database that character was updated.
$this->assertDatabaseHas('characters', [

View file

@ -9,7 +9,7 @@ use Tests\TestCase;
use App\Models\User;
class UserTest extends TestCase
class ProfileTest extends TestCase
{
use RefreshDatabase;
@ -17,14 +17,14 @@ class UserTest extends TestCase
{
$user = User::factory()->create();
$response = $this->actingAs($user)->get(route('user.index'));
$response = $this->actingAs($user)->get(route('profile.index'));
$response->assertStatus(200);
}
public function test_guest_can_not_view_profile()
{
$response = $this->get(route('user.index'));
$response = $this->get(route('profile.index'));
$response->assertRedirect(route('auth.login'));
}
@ -34,14 +34,14 @@ class UserTest extends TestCase
$user = User::factory()->create();
$response = $this->actingAs($user)
->post(route('user.update'), [
->post(route('profile.update'), [
'username' => 'AnotherUsername',
'current_password' => null,
'password' => null,
'password_confirmation' => null
]);
$response->assertRedirect(route('user.index'));
$response->assertRedirect(route('profile.index'));
$this->assertDatabaseHas('users', [
'id' => $user->id,
@ -69,14 +69,14 @@ class UserTest extends TestCase
->andReturn(true);
$response = $this->actingAs($user)
->post(route('user.update'), [
->post(route('profile.update'), [
'username' => $user->username,
'current_password' => 'password',
'password' => 'newpassword',
'password_confirmation' => 'newpassword'
]);
$response->assertRedirect(route('user.index'));
$response->assertRedirect(route('profile.index'));
$this->assertDatabaseHas('users', [
'id' => $user->id,
@ -87,7 +87,7 @@ class UserTest extends TestCase
public function test_guest_can_not_update()
{
$response = $this->post(route('user.update'), [
$response = $this->post(route('profile.update'), [
'current_password' => 'password',
'password' => 'newpassword',
'password_confirmation' => 'newpassword'