Archived
1
0
Fork 0
This repository has been archived on 2026-06-16. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
heritage-wow/tests/Feature/UserTest.php
2021-06-28 17:33:29 +01:00

55 lines
1.3 KiB
PHP

<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
use App\Models\User;
class UserTest extends TestCase
{
use RefreshDatabase;
public function test_user_can_view_profile()
{
$user = User::factory()->create();
$response = $this->actingAs($user)->get(route('user.index'));
$response->assertStatus(200);
}
public function test_guest_can_not_view_profile()
{
$response = $this->get(route('user.index'));
$response->assertRedirect(route('auth.login'));
}
public function test_user_can_update()
{
$user = User::factory()->create();
$response = $this->actingAs($user)
->post(route('user.update'), [
'current_password' => 'password',
'password' => 'newpassword',
'password_confirmation' => 'newpassword'
]);
$response->assertRedirect(route('user.index'));
}
public function test_guest_can_not_update()
{
$response = $this->post(route('user.update'), [
'current_password' => 'password',
'password' => 'newpassword',
'password_confirmation' => 'newpassword'
]);
$response->assertRedirect(route('auth.login'));
}
}