Deactivated registration

This commit is contained in:
Constantin Graf
2024-12-20 18:44:09 -05:00
committed by Constantin Graf
parent 28904b650e
commit fc0a840ded
44 changed files with 989 additions and 153 deletions

View File

@@ -13,6 +13,7 @@ use App\Providers\RouteServiceProvider;
use App\Service\IpLookup\IpLookupResponseDto;
use App\Service\IpLookup\IpLookupServiceContract;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Event;
use Laravel\Fortify\Features;
use Laravel\Jetstream\Jetstream;
@@ -63,6 +64,31 @@ class RegistrationTest extends TestCase
Event::assertNotDispatched(NewsletterRegistered::class);
}
public function test_user_registration_fails_if_registration_is_deactivated(): void
{
// Arrange
Event::fake([
NewsletterRegistered::class,
]);
Config::set('app.enable_registration', false);
// Act
$response = $this->post('/register', [
'name' => 'Test User',
'email' => 'test@example.com',
'password' => 'password',
'password_confirmation' => 'password',
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature(),
]);
// Assert
$response->assertInvalid([
'email' => 'Registration is disabled.',
]);
$this->assertFalse(User::query()->where('email', 'test@example.com')->exists());
Event::assertNotDispatched(NewsletterRegistered::class);
}
public function test_new_user_can_not_register_with_likely_invalid_domain(): void
{
// Act