updates for admin area
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AuthenticationTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_user_can_register(): void
|
||||
{
|
||||
Role::create(['name' => 'client', 'guard_name' => 'web']);
|
||||
|
||||
$response = $this->post('/register', [
|
||||
'name' => 'Test Client',
|
||||
'email' => 'client@example.test',
|
||||
'password' => 'password12345',
|
||||
'password_confirmation' => 'password12345',
|
||||
]);
|
||||
|
||||
$response->assertRedirect('/dashboard');
|
||||
$this->assertAuthenticated();
|
||||
$this->assertDatabaseHas('users', ['email' => 'client@example.test']);
|
||||
}
|
||||
|
||||
public function test_user_can_login_and_logout(): void
|
||||
{
|
||||
$user = User::factory()->create(['password' => 'password12345']);
|
||||
|
||||
$this->post('/login', ['email' => $user->email, 'password' => 'password12345'])
|
||||
->assertRedirect('/dashboard');
|
||||
$this->assertAuthenticatedAs($user);
|
||||
|
||||
$this->post('/logout')->assertRedirect('/');
|
||||
$this->assertGuest();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PublicRoutesTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_public_pages_render(): void
|
||||
{
|
||||
foreach (['/', '/djs', '/login', '/register', '/forgot-password', '/privacy', '/cookies', '/terms', '/up'] as $uri) {
|
||||
$this->get($uri)->assertSuccessful();
|
||||
}
|
||||
}
|
||||
|
||||
public function test_dashboard_redirects_guests_to_login(): void
|
||||
{
|
||||
$this->get('/dashboard')->assertRedirect('/login');
|
||||
}
|
||||
|
||||
public function test_admin_redirects_guests_to_login(): void
|
||||
{
|
||||
$this->get('/admin')->assertRedirect('/login');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
//
|
||||
}
|
||||
Reference in New Issue
Block a user