withoutVite(); $isSignupEnabled = null; $this->app->bind(SignupHelper::class, function () use (&$isSignupEnabled) { $mock = Mockery::mock(SignupHelper::class)->makePartial(); $mock->shouldReceive('isEnabled')->andReturn($isSignupEnabled); return $mock; }); $isSignupEnabled = true; $response = $this->get('/register'); $response->assertStatus(Response::HTTP_OK); $isSignupEnabled = false; $response = $this->get('/register'); $response->assertStatus(Response::HTTP_FORBIDDEN); $response->assertSeeText('Registration is currently disabled'); } #[Test] public function new_users_can_register(): void { $isSignupEnabled = null; $this->app->bind(SignupHelper::class, function () use (&$isSignupEnabled) { $mock = Mockery::mock(SignupHelper::class)->makePartial(); $mock->shouldReceive('isEnabled')->andReturn($isSignupEnabled); return $mock; }); $data = [ 'first_name' => 'Test', 'last_name' => 'User', 'email' => 'test@example.com', 'password' => 'Password$123', 'password_confirmation' => 'Password$123', 'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature(), ]; $isSignupEnabled = false; $response = $this->post('/register', $data); $response->assertStatus(Response::HTTP_FORBIDDEN); $response->assertSeeText('Registration is currently disabled'); $isSignupEnabled = true; $response = $this->post('/register', $data); $this->assertAuthenticated(); $response->assertRedirect('/vaults'); } }