65 lines
2.3 KiB
PHP
65 lines
2.3 KiB
PHP
<?php
|
|
|
|
use App\Enums\RegistrationType;
|
|
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');
|
|
|
|
// Platzhalter serverseitig übersetzt, nicht als Alpine-Ausdruck
|
|
// (ReferenceError „__ is not defined“, GlitchTip 06.10.2026).
|
|
$response->assertStatus(200)
|
|
->assertSee('placeholder="Vor- und Nachname"', false)
|
|
->assertDontSee(':placeholder="__(', false);
|
|
});
|
|
|
|
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();
|
|
|
|
// Selbst-Registrierungen sind Neukunden — nie der DB-Default `existing_legacy`.
|
|
expect($user->registration_type)->toBe(RegistrationType::Company);
|
|
|
|
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();
|
|
});
|