F
Filamentβ€’7mo ago
nostrodamned

Having issues with Test using laravel-modules and FilamentPHP

Hi all, I am trying to run this test
test('can register User', function () {
livewire(CreateUser::class)
->fillForm([
'name' => 'John Ford',
'email' => '[email protected]',
'password' => 'password',
'passwordConfirmation' => 'password'
])
->call('create')
->assertHasNoErrors(['name', 'email', 'password', 'passwordConfirmation']);

$this->assertDatabaseHas('users',[
'name' => 'John Doe',
'email' => '[email protected]',
]);
});
test('can register User', function () {
livewire(CreateUser::class)
->fillForm([
'name' => 'John Ford',
'email' => '[email protected]',
'password' => 'password',
'passwordConfirmation' => 'password'
])
->call('create')
->assertHasNoErrors(['name', 'email', 'password', 'passwordConfirmation']);

$this->assertDatabaseHas('users',[
'name' => 'John Doe',
'email' => '[email protected]',
]);
});
to test a user registering I am getting this error if i try the UserCreate class
Modules\Auth\tests\Feature\RegistrationTest > can register User ViewException
Route [filament.admin.resources.users.index] not defined. (View: /Users/craigvonchamier/Herd/TAC/vendor/filament/filament/resources/views/components/page/index.blade.php) (View: /Users/craigvonchamier/Herd/TAC/vendor/filament/filament/resources/views/components/page/index.blade.php) (View: /Users/craigvonchamier/Herd/TAC/vendor/filament/filament/resources/views/components/page/index.blade.php)
Modules\Auth\tests\Feature\RegistrationTest > can register User ViewException
Route [filament.admin.resources.users.index] not defined. (View: /Users/craigvonchamier/Herd/TAC/vendor/filament/filament/resources/views/components/page/index.blade.php) (View: /Users/craigvonchamier/Herd/TAC/vendor/filament/filament/resources/views/components/page/index.blade.php) (View: /Users/craigvonchamier/Herd/TAC/vendor/filament/filament/resources/views/components/page/index.blade.php)
and this if i use the UserClass
FAILED Modules\Auth\tests\Feature\RegistrationTest > can register User ComponentNotFoundException
Unable to find component: [Modules\User\Models\User]
FAILED Modules\Auth\tests\Feature\RegistrationTest > can register User ComponentNotFoundException
Unable to find component: [Modules\User\Models\User]
Anyone any ideas please? Thanks in advance!
5 Replies
nostrodamned
nostrodamnedOPβ€’7mo ago
ok getting closer I now get this Modules\Auth\tests\Feature\RegistrationTest > can register User ViewException
Missing required parameter for [Route: filament.admin.resources.users.index] [URI: admin/users] [Missing parameter: tenant]. (View: /Users/craigvonchamier/Herd/TAC/vendor/filament/filament/resources/views/components/page/index.blade.php) (View: /Users/craigvonchamier/Herd/TAC/vendor/filament/filament/resources/views/components/page/index.blade.php) (View: /Users/craigvonchamier/Herd/TAC/vendor/filament/filament/resources/views/components/page/index.blade.php) Using the User::class but the tenant isnt created yet?
Dennis Koch
Dennis Kochβ€’7mo ago
You need to set a tenant via Filament::setTenant()
nostrodamned
nostrodamnedOPβ€’7mo ago
but this is the user registration - before the tenant creation? @Dennis Koch
Dennis Koch
Dennis Kochβ€’7mo ago
Good point. But it seems to load ListUsers page? Maybe a redirect?
nostrodamned
nostrodamnedOPβ€’7mo ago
mmm it would be the default registration page for filament so the Users class may not make sense? ahh getting somewhere
test('can register User', function () {

livewire(Register::class)
->fillForm([
'name' => 'John Ford',
'email' => '[email protected]',
'password' => 'password',
'passwordConfirmation' => 'password'
])
->call('register')
->assertHasNoErrors(['name', 'email', 'password', 'passwordConfirmation']);

$this->assertDatabaseHas('users',[
'name' => 'John Doe',
'email' => '[email protected]',
]);
});
test('can register User', function () {

livewire(Register::class)
->fillForm([
'name' => 'John Ford',
'email' => '[email protected]',
'password' => 'password',
'passwordConfirmation' => 'password'
])
->call('register')
->assertHasNoErrors(['name', 'email', 'password', 'passwordConfirmation']);

$this->assertDatabaseHas('users',[
'name' => 'John Doe',
'email' => '[email protected]',
]);
});
GOT IT!! πŸ™‚ it has to use the register class from filament πŸ™‚ @Dennis Koch you pointed me in right direction Thanks!
Want results from more Discord servers?
Add your server