presseportale/tests/Feature/Auth/RegistrationTest.php
Kevin Adametz 31da9ea8b6
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run
livewire: Volt entfernt — Komponenten als Livewire-4-Single-File-Components, Route::livewire(), Livewire::test(); livewire/volt deinstalliert
- 83 Komponenten: Livewire\Volt\Component → Livewire\Component
- 73 Routen (admin, auth, customer): Volt::route() → Route::livewire()
- 88 Testdateien: Volt::test/actingAs → Livewire::test/actingAs
- VoltServiceProvider gelöscht; composer remove livewire/volt
- config/livewire.php auf v4-Schlüssel (component_layout, component_placeholder,
  component_locations, make_command: SFC ohne ⚡). Der alte Schlüssel layout war
  wirkungslos; alle gerouteten Komponenten setzen ihr Layout selbst.
- CLAUDE.md, AGENTS.md, boost.json, .cursorrules, Skill volt-development
- Roadmap: erledigt; Larastan erfasst SFCs weiterhin nicht (Blade-Dateien)

Suite 2.325 grün, einer übersprungen; Larastan und Pint ohne Meldung;
route:cache und view:cache laufen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 13:59:36 +00:00

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\Livewire;
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();
Livewire::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 */
Livewire::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();
});