F
Filamentβ€’2mo 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' => 'test@test.com',
'password' => 'password',
'passwordConfirmation' => 'password'
])
->call('create')
->assertHasNoErrors(['name', 'email', 'password', 'passwordConfirmation']);

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

$this->assertDatabaseHas('users',[
'name' => 'John Doe',
'email' => 'test@test.com',
]);
});
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
nostrodamnedβ€’2mo 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β€’2mo ago
You need to set a tenant via Filament::setTenant()
nostrodamned
nostrodamnedβ€’2mo ago
but this is the user registration - before the tenant creation? @Dennis Koch
Dennis Koch
Dennis Kochβ€’2mo ago
Good point. But it seems to load ListUsers page? Maybe a redirect?
nostrodamned
nostrodamnedβ€’2mo 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' => 'test@test.com',
'password' => 'password',
'passwordConfirmation' => 'password'
])
->call('register')
->assertHasNoErrors(['name', 'email', 'password', 'passwordConfirmation']);

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

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

$this->assertDatabaseHas('users',[
'name' => 'John Doe',
'email' => 'test@test.com',
]);
});
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
More Posts
Disk [tmp-for-tests] does not have a configured driver.I'm not sure why, but the filament is using this drive instead of the public drive. I specified it iUsers other than administrators cannot log in. What is the reason for this?Users other than administrators cannot log in. What is the reason for this? ``` public function canLogs Plugin: Activity Log by Dennis Koch or Logger by ZedoX?Call to undefined method App\Models\OrderLine::orderLines()when i want to edit a order on my website i get this error i don't get directed to the edit page andIs it possible to make select input invisible but send the default value with the form submit ?Is it possible to make select input invisible but send the default value with the form data on submNeed To use Filament media library out of adminI have purchased the media library because we need to implement only upload functionality in our appricheditor is not rendering html```php RichEditor::make('product_benefits_html') ->labelCheckboxList Issue on Custom Livewire pageHi everyone, I'm having an issue using a CheckboxList on a custom Livewire component. I've only impo...\Tables\Columns\Concerns\{closure}(): Return value must be of type ?string, Money\Money returnI made a product model with a price that has been cast by Money Money package. In the front all worAccess/Set repeater or field from (php file)custom Livewire component in a resource create formI have used a custom (scanner) livewire component inside order resource in order to scan qrcode and