mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Continue setting up testing.
This commit is contained in:
+2
-16
@@ -20,24 +20,11 @@ return [
|
||||
|
||||
'prefix' => [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Route Name Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value will set a prefix for all Filament route names.
|
||||
|
|
||||
*/
|
||||
|
||||
'name' => 'filament.',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Route Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value will set a prefix for all Filament routes.
|
||||
|
|
||||
*/
|
||||
|
||||
'route' => 'filament',
|
||||
@@ -47,8 +34,6 @@ return [
|
||||
| Component Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value will set a prefix for all Filament components.
|
||||
|
|
||||
| If set with the default "filament", for example, you can reference components like:
|
||||
|
|
||||
| <x-filament-alert />
|
||||
@@ -87,7 +72,8 @@ return [
|
||||
|
||||
'livewire' => [
|
||||
'login' => Filament\Http\Livewire\Auth\Login::class,
|
||||
'forgot-password' => Filament\Http\Livewire\Auth\ForgotPassword::class,
|
||||
// 'forgot-password' => Filament\Http\Livewire\Auth\ForgotPassword::class,
|
||||
'dashboard' => Filament\Http\Livewire\Dashboard::class,
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<div>
|
||||
Dashboard
|
||||
</div>
|
||||
+10
-7
@@ -6,13 +6,11 @@ use Filament\Http\Controllers\{
|
||||
AssetController,
|
||||
};
|
||||
|
||||
$routeNamePrefix = config('filament.prefix.name', 'filament.');
|
||||
|
||||
Route::group([
|
||||
'prefix' => config('filament.prefix.route'),
|
||||
'middleware' => config('filament.middleware', ['web']),
|
||||
'as' => $routeNamePrefix,
|
||||
], function () use ($routeNamePrefix) {
|
||||
'as' => 'filament.',
|
||||
], function () {
|
||||
// Assets
|
||||
Route::name('assets.')->group(function () {
|
||||
Route::get('filament.css', [AssetController::class, 'css'])->name('css');
|
||||
@@ -23,10 +21,14 @@ Route::group([
|
||||
|
||||
// Auth
|
||||
Route::get('/login', config('filament.livewire.login'))->name('login');
|
||||
Route::get('/forgot-password', config('filament.livewire.forgot-password'))->name('password.forgot');
|
||||
// Route::get('/forgot-password', config('filament.livewire.forgot-password'))->name('password.forgot');
|
||||
|
||||
// Authenticated routes
|
||||
Route::group(['middleware' => ['auth', 'verified']], function () {
|
||||
// Dashboard
|
||||
Route::get('/', config('filament.livewire.dashboard'))->name('dashboard');
|
||||
|
||||
/*
|
||||
// User profile
|
||||
Route::get('/profile', config('filament.livewire.profile'))->name('profile');
|
||||
|
||||
@@ -37,12 +39,13 @@ Route::group([
|
||||
Route::get('/user/{user}', config('filament.livewire.user'))->name('show');
|
||||
});
|
||||
}
|
||||
*/
|
||||
});
|
||||
});
|
||||
|
||||
// Conditional route login alias
|
||||
if (!Route::has('login')) {
|
||||
Route::get('/login', function () use ($routeNamePrefix) {
|
||||
return redirect()->route("{$routeNamePrefix}login");
|
||||
Route::get('/login', function () {
|
||||
return redirect()->route("filament.login");
|
||||
})->name('login');
|
||||
}
|
||||
@@ -2,10 +2,9 @@
|
||||
|
||||
namespace Filament\Http\Livewire\Auth;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Livewire\Component;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
use Filament\Traits\ThrottlesLogins;
|
||||
|
||||
class Login extends Component
|
||||
@@ -34,7 +33,7 @@ class Login extends Component
|
||||
}
|
||||
|
||||
if (Auth::attempt($data, (bool) $this->remember)) {
|
||||
return redirect()->intended(RouteServiceProvider::HOME);
|
||||
return redirect()->intended(route('filament.dashboard'));
|
||||
}
|
||||
|
||||
// If the login attempt was unsuccessful we will increment the number of attempts
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Http\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class Dashboard extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
return view('filament::livewire.dashboard')
|
||||
->layout('filament::layouts.auth');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tests\Database\Factories;
|
||||
|
||||
use Filament\Tests\Database\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = User::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->name,
|
||||
'email' => $this->faker->unique()->safeEmail,
|
||||
'email_verified_at' => now(),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Tests\Database\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Filament\Tests\Database\Factories\UserFactory;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* Disable Laravel's mass assignment protection
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new factory instance for the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
*/
|
||||
protected static function newFactory()
|
||||
{
|
||||
return UserFactory::new();
|
||||
}
|
||||
}
|
||||
@@ -2,27 +2,24 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Filament\Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
use App\Models\User;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Filament\Tests\TestCase;
|
||||
use Filament\Tests\Database\Models\User;
|
||||
use Filament\Http\Livewire\Auth\Login;
|
||||
|
||||
|
||||
class LoginTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_can_see_login_form()
|
||||
{
|
||||
$this->withoutExceptionHandling();
|
||||
$this->get('/filament/login')
|
||||
// $this->withoutExceptionHandling();
|
||||
$this->get(route('filament.login'))
|
||||
->assertSuccessful()
|
||||
->assertSee(trans('filament::auth.signin'));
|
||||
}
|
||||
|
||||
/*
|
||||
public function test_existing_user_can_log_in()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
@@ -31,12 +28,11 @@ class LoginTest extends TestCase
|
||||
->set('email', $user->email)
|
||||
->set('password', 'password')
|
||||
->call('login')
|
||||
->assertRedirect(RouteServiceProvider::HOME);
|
||||
->assertRedirect(route('filament.dashboard'));
|
||||
|
||||
$this->assertAuthenticated();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
public function test_email_is_required()
|
||||
{
|
||||
|
||||
@@ -24,6 +24,8 @@ abstract class TestCase extends OrchestraTestCase
|
||||
});
|
||||
|
||||
parent::setUp();
|
||||
$this->loadLaravelMigrations(['--database' => 'testbench']);
|
||||
$this->artisan('migrate', ['--database' => 'testbench'])->run();
|
||||
Facade::setFacadeApplication(app());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user