presseportale/tests/Feature/Auth/RegistrationTest.php
Kevin Adametz f02adf1e0c R0.2: gdpr_consent_at bei allen Registrierungspfaden befuellen (DSGVO)
Feld existierte seit der Migration-2026-Erweiterung, wurde aber nirgends
geschrieben. Jetzt gesetzt bei: Volt-Registrierung (bestaetigte AGB-/
Datenschutz-Checkbox), Magic-Link-Provisioning und Google-OAuth (beide
via CustomerAccountProvisioner, Konto-Anlage nutzerinitiiert).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 07:53:41 +00:00

57 lines
1.8 KiB
PHP

<?php
use App\Models\User;
use Illuminate\Auth\Notifications\VerifyEmail;
use Illuminate\Support\Facades\Notification;
use Livewire\Volt\Volt;
use Tests\TestCase;
test('registration screen can be rendered', function () {
/** @var TestCase $this */
$response = $this->get('/register');
$response->assertStatus(200);
});
test('new users register inactive and are sent to the verification notice', function () {
/** @var TestCase $this */
Notification::fake();
Volt::test('auth.register')
->set('name', 'Test User')
->set('email', 'test@example.com')
->set('password', 'password')
->set('password_confirmation', 'password')
->set('terms_accepted', true)
->call('register')
->assertHasNoErrors()
->assertRedirect(route('verification.notice', absolute: false));
$this->assertAuthenticated();
$user = User::where('email', 'test@example.com')->firstOrFail();
// Konto bleibt bis zur Verifizierung inaktiv, rollenlos und unverifiziert.
expect($user->is_active)->toBeFalse();
expect($user->hasVerifiedEmail())->toBeFalse();
expect($user->roles()->count())->toBe(0);
// Die bestätigte AGB-/Datenschutz-Checkbox wird als Einwilligung festgehalten.
expect($user->gdpr_consent_at)->not->toBeNull();
Notification::assertSentTo($user, VerifyEmail::class);
});
test('registration requires accepting the terms', function () {
/** @var TestCase $this */
Volt::test('auth.register')
->set('name', 'Test User')
->set('email', 'terms@example.com')
->set('password', 'password')
->set('password_confirmation', 'password')
->set('terms_accepted', false)
->call('register')
->assertHasErrors(['terms_accepted']);
expect(User::where('email', 'terms@example.com')->exists())->toBeFalse();
});