-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow users to disable registrations
- Loading branch information
1 parent
224800f
commit f52f897
Showing
4 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Auth; | ||
|
||
beforeEach(function () { | ||
config()->set('devdojo.auth.settings.registration_enabled', true); | ||
}); | ||
|
||
it('allows access to registration page when enabled', function () { | ||
Livewire::test('auth.register') | ||
->assertOk() | ||
->assertDontSee('Registrations are currently disabled'); | ||
}); | ||
|
||
it('redirects to login when registrations are disabled', function () { | ||
config()->set('devdojo.auth.settings.registration_enabled', false); | ||
|
||
Livewire::test('auth.register') | ||
->assertRedirect(route('auth.login')); | ||
|
||
expect(session('error'))->toBe( | ||
config('devdojo.auth.language.register.registrations_disabled', 'Registrations are currently disabled.') | ||
); | ||
}); | ||
|
||
it('allows registration when enabled', function () { | ||
$component = Livewire::test('auth.register') | ||
->set('email', '[email protected]') | ||
->set('password', 'password123') | ||
->set('name', 'Test User') | ||
->call('register'); | ||
|
||
expect(Auth::check())->toBeTrue(); | ||
expect(Auth::user()->email)->toBe('[email protected]'); | ||
}); | ||
|
||
it('preserves other registration settings when enabled', function () { | ||
config()->set('devdojo.auth.settings.registration_include_name_field', true); | ||
config()->set('devdojo.auth.settings.registration_show_password_same_screen', true); | ||
|
||
$component = Livewire::test('auth.register'); | ||
|
||
expect($component->get('showNameField'))->toBeTrue(); | ||
expect($component->get('showPasswordField'))->toBeTrue(); | ||
}); |