updates for admin area

This commit is contained in:
Mark Gregory
2026-09-12 20:45:05 +01:00
parent 0704924aa8
commit 8c9dbfee08
50 changed files with 1337 additions and 152 deletions
+41
View File
@@ -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();
}
}
+28
View File
@@ -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');
}
}
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
//
}