mivita/tests/Feature/AboAdminDeleteTest.php
Kevin 671022a28d Abo: Kreditkarte aktualisieren (CRM, Portal, Berater-Link) + Admin-Abo-Löschung
- Karten-Update ohne Abbuchung via PAYONE creditcardcheck/pseudocardpan
  (AboPaymentMethodService, CardUpdateResult/CreditCardCheckData-DTOs)
- Eingabe nur durch Abo-Inhaber: CRM- und Portal-Formular + zeitlich
  begrenzter Berater→Kunde-Link (AboCardUpdateLink + Mail)
- Änderungshistorie in user_abo_card_changes, Anzeige im Admin-Abo-Detail
- Admin: Abo löschen (destroy) inkl. Test
- Portal-Fix: myOrderCreate wirft 404 statt TypeError bei ungültiger ID
- VIP-Sichtbarkeitstests für Einmalartikel-Fenster ergänzt
- Enthält bereits die Freeze-Guards für den Stripe-Notbetrieb (Folge-Commit)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-08 15:56:19 +00:00

59 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use App\Http\Controllers\Admin\AboController;
use App\Models\UserAbo;
use App\Repositories\AboRepository;
use App\User;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Hash;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Tests\TestCase;
uses(TestCase::class, RefreshDatabase::class);
function adminDeleteUser(): User
{
return User::forceCreate([
'email' => 'admin-abo-delete-'.uniqid().'@test.com',
'password' => Hash::make('secret'),
'admin' => 2,
'lang' => 'de',
]);
}
function makeUserAbo(): UserAbo
{
return UserAbo::create([
'user_id' => 1,
'shopping_user_id' => 1,
'is_for' => 'me',
'email' => 'kunde@example.com',
'payone_userid' => 123456,
'clearingtype' => 'cc',
'active' => true,
'status' => 2,
'abo_interval' => 5,
'next_date' => now()->addDays(10),
]);
}
it('löscht ein Abo soft über deleted_at', function () {
$this->actingAs(adminDeleteUser());
$abo = makeUserAbo();
try {
(new AboController(app(AboRepository::class)))->destroy($abo->id);
} catch (RouteNotFoundException $e) {
// Domain-spezifische Routen sind im Test-Kontext nicht registriert – erwartet.
}
expect(UserAbo::find($abo->id))->toBeNull();
expect(UserAbo::withTrashed()->find($abo->id)->deleted_at)->not->toBeNull();
});
it('wirft eine Not-Found-Exception für ein nicht existierendes Abo', function () {
$this->actingAs(adminDeleteUser());
(new AboController(app(AboRepository::class)))->destroy(999999);
})->throws(ModelNotFoundException::class);