presseportale/tests/Feature/CustomerProfileSecurityTest.php
Kevin Adametz 301bca3a90 auth: automatische Firmenrechte mit Herkunft und Entzug, Nachweis vor Sicherheitsaktionen (Audit Block 1, Deploy C)
F10: company_user.granted_via unterscheidet automatisch vergebene
Rechte (E-Mail-Sync) von manuellen und aus dem Altbestand. Beim Login
senkt der Sync automatische responsible-Rechte ohne aktuellen E-Mail-
Treffer auf member (E2) — Mitarbeiterwechsel nehmen den Schreibzugriff
mit, Lesezugriff bleibt. Das Admin-Formular markiert nur neue oder
geänderte Zeilen als manual, unveränderte behalten ihre Herkunft.

Bestandsprüfung: php artisan company-memberships:audit listet
responsible-Zuordnungen ohne E-Mail-Grundlage (Tabelle ab Go-Live, CSV
vollständig) und markiert mit --classify die erklärbaren als auto. Auf
Live nach der Migration einmal mit --classify laufen lassen; nicht
erklärbare Zeilen bleiben manual und damit geschützt.

F03 (E3): Zwei-Faktor deaktivieren, Wiederherstellungs-Codes erneuern
und die E-Mail-Änderung verlangen einen aktuellen App-Code oder einen
Wiederherstellungs-Code (der dabei verbraucht wird); ohne 2FA das
Passwort. Reine Magic-Link-Konten ohne Passwort (der Altbestand) können
die Adresse weiter ändern — die neue Adresse muss ihren Bestätigungslink
ohnehin einlösen. Fünf Fehlversuche pro Minute.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-18 10:19:28 +00:00

691 lines
25 KiB
PHP

<?php
use App\Enums\Portal;
use App\Enums\PressReleaseStatus;
use App\Mail\EmailChangeConfirmation;
use App\Models\Category;
use App\Models\Company;
use App\Models\Contact;
use App\Models\LegacyInvoice;
use App\Models\PressRelease;
use App\Models\PressReleaseStatusLog;
use App\Models\User;
use Database\Seeders\RolesAndPermissionsSeeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\URL;
use Livewire\Features\SupportLockedProperties\CannotUpdateLockedPropertyException;
use Livewire\Volt\Volt as LivewireVolt;
use PragmaRX\Google2FA\Google2FA;
use Tests\TestCase;
test('customer can update own profile fields', function () {
/** @var TestCase $this */
$customer = User::factory()->create([
'is_active' => true,
'name' => 'Original Name',
'language' => 'de',
]);
$this->actingAs($customer);
LivewireVolt::test('customer.profile')
->assertSee('Rechnungsadresse')
->assertSee('Agentur-Angaben')
->set('name', 'Neuer Anzeigename')
->set('agencyName', 'Muster Presseverteiler')
->set('firstName', 'Max')
->set('lastName', 'Mustermann')
->set('language', 'en')
->set('address', 'Musterfirma GmbH, Musterstrasse 1, 10115 Berlin')
->set('countryCode', 'AT')
->set('billingCompany', 'Musterfirma GmbH')
->set('billingFirstName', 'Max')
->set('billingLastName', 'Mustermann')
->set('billingAddress1', 'Musterstrasse 1')
->set('billingPostalCode', '10115')
->set('billingCity', 'Berlin')
->set('billingCountryCode', 'DE')
->set('taxIdNumber', 'DE123456789')
->set('showStats', true)
->call('saveProfile')
->assertHasNoErrors();
$customer->refresh();
expect($customer->name)->toBe('Neuer Anzeigename');
expect($customer->agency_name)->toBe('Muster Presseverteiler');
expect($customer->language)->toBe('en');
expect($customer->profile?->first_name)->toBe('Max');
expect($customer->profile?->last_name)->toBe('Mustermann');
expect($customer->profile?->address)->toBe('Musterfirma GmbH, Musterstrasse 1, 10115 Berlin');
expect($customer->profile?->country_code)->toBe('AT');
expect($customer->profile?->tax_id_number)->toBe('DE123456789');
expect($customer->profile?->show_stats)->toBeTrue();
expect($customer->billingAddress?->company)->toBe('Musterfirma GmbH');
expect($customer->billingAddress?->first_name)->toBe('Max');
expect($customer->billingAddress?->last_name)->toBe('Mustermann');
expect($customer->billingAddress?->name)->toBe('Max Mustermann');
expect($customer->billingAddress?->address1)->toBe('Musterstrasse 1');
expect($customer->billingAddress?->postal_code)->toBe('10115');
expect($customer->billingAddress?->city)->toBe('Berlin');
expect($customer->billingAddress?->country_code)->toBe('DE');
expect($customer->billingAddress?->vat_id)->toBe('DE123456789');
});
test('an incomplete billing address reports each missing field exactly once', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$this->actingAs($customer);
LivewireVolt::test('customer.profile')
->set('billingCompany', 'Nur Firma GmbH')
->call('saveProfile')
->assertHasErrors(['billingLastName', 'billingAddress1', 'billingPostalCode', 'billingCity']);
});
test('every profile panel offers a save button', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$this->actingAs($customer);
// 6 Panels (Persönliche Daten, Konto & Sicherheit, Rechnungsadresse,
// Agentur-Angaben, E-Mail-Benachrichtigungen, Einstellungen) — jedes mit
// eigenem Submit-Button für dasselbe Formular.
$html = LivewireVolt::test('customer.profile')->html();
expect(substr_count($html, 'type="submit"'))->toBe(6);
});
test('a malformed vat id blocks saving with a field error', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$this->actingAs($customer);
LivewireVolt::test('customer.profile')
->set('taxIdNumber', '123-nicht-gueltig')
->call('saveProfile')
->assertHasErrors(['taxIdNumber']);
});
test('the profile data can be copied into the billing address', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$this->actingAs($customer);
LivewireVolt::test('customer.profile')
->set('salutationKey', 'mr')
->set('firstName', 'Kopier')
->set('lastName', 'Kunde')
->set('countryCode', 'AT')
->call('copyProfileToBilling')
->assertSet('billingSalutationKey', 'mr')
->assertSet('billingFirstName', 'Kopier')
->assertSet('billingLastName', 'Kunde')
->assertSet('billingCountryCode', 'AT');
});
test('customer profile keeps company management out of the profile page', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$company = Company::factory()->presseecho()->create([
'owner_user_id' => $customer->id,
'name' => 'Nicht im Profil geladene Firma',
]);
$customer->companies()->attach($company->id, ['role' => 'owner']);
$this->actingAs($customer);
LivewireVolt::test('customer.profile')
->assertSee('Rechnungsadresse')
->assertSee('Persönliche Daten')
->assertSee('Firmen verwalten')
->assertDontSee('Zugeordnete Firmen')
->assertDontSee('Nicht im Profil geladene Firma');
});
test('customer can save profile settings without a billing address', function () {
/** @var TestCase $this */
$customer = User::factory()->create([
'is_active' => true,
'name' => 'Ohne Rechnung',
]);
$this->actingAs($customer);
LivewireVolt::test('customer.profile')
->set('name', 'Nur Profil')
->set('firstName', 'Nur')
->set('lastName', 'Profil')
->call('saveProfile')
->assertHasNoErrors();
expect($customer->refresh()->name)->toBe('Nur Profil');
expect($customer->billingAddress)->toBeNull();
});
test('customer security page renders password and email forms', function () {
/** @var TestCase $this */
$customer = User::factory()->create([
'is_active' => true,
'password' => bcrypt('current-password'),
]);
$this->actingAs($customer);
LivewireVolt::test('customer.security')
->assertSee('Konto-Sicherheit')
->assertSee('Letzter Login')
->assertSee('Aktive Sessions')
->assertSee('Passwort ändern')
->assertSee('E-Mail-Adresse ändern')
->assertSee('Zwei-Faktor-Authentifizierung');
});
test('customer can change own password through security page', function () {
/** @var TestCase $this */
$customer = User::factory()->create([
'is_active' => true,
'password' => bcrypt('current-password'),
]);
$this->actingAs($customer);
LivewireVolt::test('customer.security')
->set('current_password', 'current-password')
->set('password', 'new-strong-password')
->set('password_confirmation', 'new-strong-password')
->call('updatePassword')
->assertHasNoErrors();
$customer->refresh();
expect(Hash::check('new-strong-password', $customer->password))->toBeTrue();
});
test('two factor setup only becomes active after confirming an app code', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$this->actingAs($customer);
$component = LivewireVolt::test('customer.security')
->call('enableTwoFactorAuthentication');
$customer->refresh();
expect($customer->two_factor_secret)->not->toBeNull();
expect($customer->two_factor_confirmed_at)->toBeNull();
expect($customer->hasEnabledTwoFactorAuthentication())->toBeFalse();
$otp = app(Google2FA::class)->getCurrentOtp(decrypt($customer->two_factor_secret));
$component
->set('twoFactorCode', $otp)
->call('confirmTwoFactorAuthentication')
->assertHasNoErrors()
->assertSee('Wiederherstellungs-Codes');
$customer->refresh();
expect($customer->two_factor_confirmed_at)->not->toBeNull();
expect($customer->hasEnabledTwoFactorAuthentication())->toBeTrue();
});
test('an invalid two factor confirmation code is rejected', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$this->actingAs($customer);
LivewireVolt::test('customer.security')
->call('enableTwoFactorAuthentication')
->set('twoFactorCode', '000000')
->call('confirmTwoFactorAuthentication')
->assertHasErrors(['twoFactorCode']);
expect($customer->refresh()->two_factor_confirmed_at)->toBeNull();
});
test('recovery codes stay hidden on a later visit to the security page', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$customer->forceFill([
'two_factor_secret' => encrypt(app(Google2FA::class)->generateSecretKey()),
'two_factor_recovery_codes' => encrypt(json_encode(['geheim-code-eins', 'geheim-code-zwei'])),
'two_factor_confirmed_at' => now(),
])->save();
$this->actingAs($customer);
LivewireVolt::test('customer.security')
->assertDontSee('geheim-code-eins')
->call('regenerateRecoveryCodes')
->assertSee('Wiederherstellungs-Codes');
});
test('changing the email keeps the old address active and mails a confirm link to the new one', function () {
/** @var TestCase $this */
Mail::fake();
$customer = User::factory()->create([
'is_active' => true,
'email' => 'alt@example.com',
'email_verified_at' => now(),
]);
$this->actingAs($customer);
LivewireVolt::test('customer.security')
->set('email', 'neu@example.com')
->set('securityPassword', 'password')
->call('updateEmail')
->assertHasNoErrors();
$customer->refresh();
expect($customer->email)->toBe('alt@example.com');
expect($customer->pending_email)->toBe('neu@example.com');
expect($customer->email_verified_at)->not->toBeNull();
Mail::assertSent(EmailChangeConfirmation::class, function ($mail) {
return $mail->hasTo('neu@example.com') && str_contains($mail->confirmUrl, 'signature=');
});
});
test('the signed link applies the pending email change', function () {
/** @var TestCase $this */
$customer = User::factory()->create([
'is_active' => true,
'email' => 'alt@example.com',
'pending_email' => 'neu@example.com',
]);
$url = URL::temporarySignedRoute('email-change.confirm', now()->addHour(), [
'user' => $customer->id,
'hash' => sha1('neu@example.com'),
]);
$this->actingAs($customer)
->get($url)
->assertRedirect(route('me.security'));
$customer->refresh();
expect($customer->email)->toBe('neu@example.com');
expect($customer->pending_email)->toBeNull();
expect($customer->email_verified_at)->not->toBeNull();
});
test('the email change link of another user is rejected', function () {
/** @var TestCase $this */
$owner = User::factory()->create(['is_active' => true, 'pending_email' => 'neu@example.com']);
$intruder = User::factory()->create(['is_active' => true]);
$url = URL::temporarySignedRoute('email-change.confirm', now()->addHour(), [
'user' => $owner->id,
'hash' => sha1('neu@example.com'),
]);
$this->actingAs($intruder)->get($url)->assertForbidden();
expect($owner->refresh()->email)->not->toBe('neu@example.com');
});
test('an unsigned email change link is rejected', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true, 'pending_email' => 'neu@example.com']);
$this->actingAs($customer)
->get(route('email-change.confirm', ['user' => $customer->id, 'hash' => sha1('neu@example.com')]))
->assertForbidden();
});
test('a pending email change can be discarded', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true, 'pending_email' => 'neu@example.com']);
$this->actingAs($customer);
LivewireVolt::test('customer.security')
->call('cancelPendingEmailChange');
expect($customer->refresh()->pending_email)->toBeNull();
});
test('a pending email that got taken by another account meanwhile is discarded on confirm', function () {
/** @var TestCase $this */
$customer = User::factory()->create([
'is_active' => true,
'email' => 'alt@example.com',
'pending_email' => 'neu@example.com',
]);
User::factory()->create(['email' => 'neu@example.com']);
$url = URL::temporarySignedRoute('email-change.confirm', now()->addHour(), [
'user' => $customer->id,
'hash' => sha1('neu@example.com'),
]);
$this->actingAs($customer)
->get($url)
->assertRedirect(route('me.security'))
->assertSessionHas('security-error');
$customer->refresh();
expect($customer->email)->toBe('alt@example.com');
expect($customer->pending_email)->toBeNull();
});
test('press release policy denies access to other users releases', function () {
/** @var TestCase $this */
$owner = User::factory()->create(['is_active' => true]);
$intruder = User::factory()->create(['is_active' => true]);
$pr = PressRelease::factory()->create([
'user_id' => $owner->id,
'status' => 'draft',
]);
expect($intruder->can('view', $pr))->toBeFalse();
expect($intruder->can('update', $pr))->toBeFalse();
expect($owner->can('view', $pr))->toBeTrue();
expect($owner->can('update', $pr))->toBeTrue();
});
test('me press release routes only resolve own press releases even for admins', function () {
/** @var TestCase $this */
$this->seed(RolesAndPermissionsSeeder::class);
$admin = User::factory()->create(['is_active' => true]);
$admin->assignRole('admin');
$otherUser = User::factory()->create(['is_active' => true]);
$otherPressRelease = PressRelease::factory()->create([
'user_id' => $otherUser->id,
'status' => 'draft',
]);
$this->actingAs($admin);
$this->get(route('me.press-releases.show', $otherPressRelease->id))
->assertNotFound();
$this->get(route('me.press-releases.edit', $otherPressRelease->id))
->assertNotFound();
});
test('customer press releases derive portal from selected company', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$company = Company::factory()->presseecho()->create();
$customer->companies()->attach($company->id, ['role' => 'owner']);
$contact = Contact::factory()->for($company)->create(['portal' => $company->portal->value]);
$this->actingAs($customer);
LivewireVolt::test('customer.press-releases.create')
->set('companyId', $company->id)
->set('portal', Portal::Businessportal24->value)
->set('categoryId', Category::factory()->create()->id)
->set('contactId', $contact->id)
->set('title', 'Neue Meldung fuer Presseecho')
->set('text', str_repeat('Dies ist ein ausreichend langer Testtext. ', 3))
->call('save', 'draft')
->assertHasNoErrors();
$pressRelease = PressRelease::query()->where('user_id', $customer->id)->firstOrFail();
expect($pressRelease->portal)->toBe(Portal::Presseecho);
});
test('customer press release detail shows assigned contacts and status history', function () {
/** @var TestCase $this */
$customer = User::factory()->create([
'is_active' => true,
'name' => 'Kunden Nutzer',
]);
$company = Company::factory()->presseecho()->create([
'name' => 'Alpha GmbH',
]);
$customer->companies()->attach($company->id, ['role' => 'owner']);
$pressRelease = PressRelease::factory()->forPortal(Portal::Presseecho)->create([
'user_id' => $customer->id,
'company_id' => $company->id,
'title' => 'Alpha Detailmeldung',
'status' => PressReleaseStatus::Review->value,
'hits' => 1234,
'keywords' => 'Energie, Wasserstoff',
]);
$contact = Contact::factory()->create([
'company_id' => $company->id,
'portal' => Portal::Presseecho->value,
'first_name' => 'Paula',
'last_name' => 'Presse',
'responsibility' => 'PR Managerin',
'email' => 'paula@example.test',
]);
$pressRelease->contacts()->attach($contact->id);
PressReleaseStatusLog::query()->create([
'press_release_id' => $pressRelease->id,
'changed_by_user_id' => $customer->id,
'from_status' => PressReleaseStatus::Draft->value,
'to_status' => PressReleaseStatus::Review->value,
'reason' => 'Zur Prüfung eingereicht',
'source' => 'customer',
'created_at' => now(),
]);
$this->actingAs($customer);
LivewireVolt::test('customer.press-releases.show', ['id' => $pressRelease->id])
->assertSee('Alpha Detailmeldung')
->assertSee('Status-Workflow')
->assertSee('Firma & Pressekontakt')
->assertSee('Alpha GmbH')
->assertSee('Paula Presse')
->assertSee('paula@example.test')
->assertSee('Status & Verlauf')
->assertSee('In Pruefung')
->assertSee('1.234')
->assertSee('Portal')
->assertSee('Kategorie')
->assertSee('Themen')
->assertSee('Energie')
->assertSee('Wasserstoff')
->assertSee('Zur Prüfung eingereicht')
->assertSee('durch Kunden Nutzer');
});
test('legacy invoice policy denies access to invoices of other users', function () {
/** @var TestCase $this */
$owner = User::factory()->create(['is_active' => true]);
$intruder = User::factory()->create(['is_active' => true]);
$invoice = LegacyInvoice::query()->create([
'legacy_portal' => 'presseecho',
'legacy_id' => 9001,
'user_id' => $owner->id,
'legacy_user_id' => 9001,
'number' => 'RE-OWN-9001',
'amount_cents' => 9900,
'total_cents' => 9900,
'status' => 'paid',
'invoice_date' => now()->subMonth(),
'imported_at' => now(),
]);
expect($owner->can('view', $invoice))->toBeTrue();
expect($intruder->can('view', $invoice))->toBeFalse();
expect($intruder->can('downloadPdf', $invoice))->toBeFalse();
});
test('the fortify profile-information endpoint is switched off (Audit F01)', function () {
/** @var TestCase $this */
$customer = User::factory()->create([
'is_active' => true,
'email' => 'eigene@example.com',
'email_verified_at' => now(),
]);
$this->actingAs($customer)
->put('/user/profile-information', ['name' => $customer->name, 'email' => 'fremd@example.com'])
->assertNotFound();
expect($customer->fresh()->email)->toBe('eigene@example.com');
expect($customer->fresh()->email_verified_at)->not->toBeNull();
});
test('recovery codes cannot be revealed by mutating the component property (Audit F03)', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$customer->forceFill([
'two_factor_secret' => encrypt(app(Google2FA::class)->generateSecretKey()),
'two_factor_recovery_codes' => encrypt(json_encode(['geheim-code-eins', 'geheim-code-zwei'])),
'two_factor_confirmed_at' => now(),
])->save();
$this->actingAs($customer);
LivewireVolt::test('customer.security')
->set('showRecoveryCodes', true)
->assertDontSee('geheim-code-eins');
})->throws(CannotUpdateLockedPropertyException::class);
test('disabling two-factor requires a current app code (Audit F03)', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$secret = app(Google2FA::class)->generateSecretKey();
$customer->forceFill([
'two_factor_secret' => encrypt($secret),
'two_factor_recovery_codes' => encrypt(json_encode(['geheim-code-eins', 'geheim-code-zwei'])),
'two_factor_confirmed_at' => now(),
])->save();
$this->actingAs($customer);
LivewireVolt::test('customer.security')
->call('disableTwoFactorAuthentication')
->assertHasErrors(['securityCode']);
LivewireVolt::test('customer.security')
->set('securityCode', '000000')
->call('disableTwoFactorAuthentication')
->assertHasErrors(['securityCode']);
expect($customer->fresh()->hasEnabledTwoFactorAuthentication())->toBeTrue();
LivewireVolt::test('customer.security')
->set('securityCode', app(Google2FA::class)->getCurrentOtp($secret))
->call('disableTwoFactorAuthentication')
->assertHasNoErrors();
expect($customer->fresh()->hasEnabledTwoFactorAuthentication())->toBeFalse();
});
test('regenerating recovery codes accepts a recovery code as proof and consumes it (Audit F03)', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$customer->forceFill([
'two_factor_secret' => encrypt(app(Google2FA::class)->generateSecretKey()),
'two_factor_recovery_codes' => encrypt(json_encode(['geheim-code-eins', 'geheim-code-zwei'])),
'two_factor_confirmed_at' => now(),
])->save();
$this->actingAs($customer);
LivewireVolt::test('customer.security')
->call('regenerateRecoveryCodes')
->assertHasErrors(['securityCode']);
expect($customer->fresh()->recoveryCodes())->toContain('geheim-code-eins');
LivewireVolt::test('customer.security')
->set('securityCode', 'geheim-code-eins')
->call('regenerateRecoveryCodes')
->assertHasNoErrors()
->assertSee('Wiederherstellungs-Codes');
expect($customer->fresh()->recoveryCodes())->not->toContain('geheim-code-eins')
->and($customer->fresh()->recoveryCodes())->not->toContain('geheim-code-zwei');
});
test('cancelling an unconfirmed two-factor setup needs no proof', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$this->actingAs($customer);
LivewireVolt::test('customer.security')
->call('enableTwoFactorAuthentication')
->call('disableTwoFactorAuthentication')
->assertHasNoErrors();
expect($customer->fresh()->two_factor_secret)->toBeNull();
});
test('changing the email asks for the password, or for the app code once two-factor is active (Audit F03)', function () {
/** @var TestCase $this */
Mail::fake();
$customer = User::factory()->create(['is_active' => true, 'email' => 'alt2@example.com']);
$this->actingAs($customer);
LivewireVolt::test('customer.security')
->set('email', 'neu2@example.com')
->call('updateEmail')
->assertHasErrors(['securityPassword']);
LivewireVolt::test('customer.security')
->set('email', 'neu2@example.com')
->set('securityPassword', 'falsch')
->call('updateEmail')
->assertHasErrors(['securityPassword']);
expect($customer->fresh()->pending_email)->toBeNull();
$secret = app(Google2FA::class)->generateSecretKey();
$customer->forceFill([
'two_factor_secret' => encrypt($secret),
'two_factor_recovery_codes' => encrypt(json_encode(['r-eins'])),
'two_factor_confirmed_at' => now(),
])->save();
LivewireVolt::test('customer.security')
->set('email', 'neu2@example.com')
->set('securityPassword', 'password')
->call('updateEmail')
->assertHasErrors(['securityCode']);
LivewireVolt::test('customer.security')
->set('email', 'neu2@example.com')
->set('securityCode', app(Google2FA::class)->getCurrentOtp($secret))
->call('updateEmail')
->assertHasNoErrors();
expect($customer->fresh()->pending_email)->toBe('neu2@example.com');
});
test('a passwordless magic-link account can still start an email change', function () {
/** @var TestCase $this */
Mail::fake();
$customer = User::factory()->create(['is_active' => true, 'email' => 'magic@example.com']);
// Wie im Altbestand (66.000 Konten): leeres Passwortfeld, kein Hash. Der
// `hashed`-Cast würde auch '' hashen, daher direkt in die Tabelle.
DB::table('users')->where('id', $customer->id)->update(['password' => '']);
$this->actingAs($customer->fresh());
LivewireVolt::test('customer.security')
->set('email', 'magic-neu@example.com')
->call('updateEmail')
->assertHasNoErrors();
expect($customer->fresh()->pending_email)->toBe('magic-neu@example.com');
});