get('/register')->assertNotFound(); }); test('public registration rejects form and JSON submissions without creating a user', function (bool $json) { $credentials = [ 'name' => 'Public Signup', 'email' => 'signup@example.com', 'password' => 'password', 'password_confirmation' => 'password', ]; $response = $json ? $this->postJson('/register', $credentials) : $this->post('/register', $credentials); $response->assertNotFound(); $this->assertDatabaseMissing('users', ['email' => $credentials['email']]); $this->assertGuest(); })->with(['form' => [false], 'JSON' => [true]]); test('login and welcome views hide their registration links', function () { $registrationLink = 'href="'.url('/register').'"'; $this->get('/login')->assertOk()->assertDontSee($registrationLink, false); $this->view('stylist-theme-frontend::welcome')->assertDontSee($registrationLink, false); }); test('administrators can create users while public registration is disabled', function () { $admin = User::factory()->create(['helpdesk_admin' => true]); $this->actingAs($admin)->post(route('user-management.store'), [ 'name' => 'Provisioned User', 'email' => 'provisioned@example.com', 'password' => 'password', 'password_confirmation' => 'password', ])->assertSessionHasNoErrors()->assertRedirect(); $user = User::query()->where('email', 'provisioned@example.com')->sole(); expect($user->hasVerifiedEmail())->toBeTrue(); $this->assertAuthenticatedAs($admin); });