- 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>
59 lines
1.7 KiB
PHP
59 lines
1.7 KiB
PHP
<?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);
|