'Broker', 'guard_name' => 'web', 'reg_prefix' => 'M', 'can_be_invited' => true, 'reg_start_number' => 10000001, ]); $response = $this->get('/reg/m'); $response->assertOk(); }); test('registration landing page returns 404 for invalid role', function () { $response = $this->get('/reg/invalid'); $response->assertNotFound(); }); test('registration requires valid code in session', function () { $response = Volt::test('auth.register') ->set('name', 'Test User') ->set('email', 'test@example.com') ->set('password', 'password') ->set('password_confirmation', 'password') ->call('register'); $response->assertHasErrors('registration_code'); }); test('new users can register with valid registration code', function () { $code = RegistrationCode::create([ 'code' => 'M10000001', 'role' => 'broker', 'name' => 'Test Makler', 'status' => RegistrationCode::STATUS_AVAILABLE, ]); session([ 'registration_code_id' => $code->id, 'registration_role' => 'broker', ]); $response = Volt::test('auth.register') ->set('name', 'Test User') ->set('email', 'test@example.com') ->set('password', 'password') ->set('password_confirmation', 'password') ->call('register'); $response ->assertHasNoErrors() ->assertRedirect(route('dashboard', absolute: false)); $this->assertAuthenticated(); expect(User::where('email', 'test@example.com')->exists())->toBeTrue(); expect($code->fresh()->status)->toBe(RegistrationCode::STATUS_USED); });