mivita/tests/Feature/AboAdminDeleteTest.php
Kevin ac3bd6e8ea Statistiken/Abo: Kundenfeedback 2026-07-24 komplett umgesetzt + Steuern: DATEV-Fixes 08+09/2025 (Sammel-Commit Branch-WIP)
Feedback-Umsetzung (dev/2026-07-22/feedback-analyse-2026-07-24.md, alle 10 Punkte):
- VIP-Statistik: eigener Berater ('ich', Linie 0) in Neue-Kundenabos- und beiden Top-10-Listen; Top-10-Umsatz sortiert nach abgerechneten Ist-Punkten + Abo-Anzahl-Spalte; Fußnote nicht-payline-wirksame Punkte (SalesVolumePoints::nonPaylinePoints)
- Führungskräfte-Liste: beide Sichten 'direkt' (an nächster FK abgeschnitten, additiv) und 'gesamt' (komplette Downline), Gesamt-Spalte nach Kundenzählweise
- Team-Abos: je Ebene 'abgerechnet (Monat)' und 'bis zum 25. erwartet'; Payline-Karte mit Teamabo-/Kundenabo-Zählern
- Incentive-Live-Ranking: Qualifizierte zuerst nummeriert (fixt auch isWinner rank<=max_winners)
- Porto: Netto-/Brutto-Kennzeichnung (Berater netto, Endkunden inkl. MwSt., portal_view-Flag; auch CRM-/Shop-Warenkorb + Checkout), Yard::shipping_tax-Fix
- Struktur-Ansicht: Abo-Badges 'A' (eigenes Abo) und '(n)' (Kundenabos) je Teampartner, gebatcht
- Abo-Löschung: Softdelete setzt active=0 (UserAbo deleting-Hook) + Bereinigungs-Migration für gelöschte-aber-aktive Abos
- Doku: technische Analyse + Kundinnen-Feedback-Dokument unter dev/2026-07-22/
- Tests: IncentiveRankingTest, TeamStructureAboBadgesTest, YardShippingTaxTest (neu); BackofficeStatisticsListsTest, TeamAboOverviewTest, PaylineForecastServiceTest, AboAdminDeleteTest, AboOneTimeViewTest erweitert

Außerdem enthalten (Branch-WIP vor dem Feedback): DATEV-Abgleich-Fixes 08+09/2025, USt-ID-Live-Validierung sowie restliche unkommittete Stände (u. a. Abo-Pause-Sprachkeys).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 13:56:02 +00:00

75 lines
2.2 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('setzt beim Softdelete auch active auf false', function () {
$this->actingAs(adminDeleteUser());
$abo = makeUserAbo();
expect($abo->active)->toBeTrue();
try {
(new AboController(app(AboRepository::class)))->destroy($abo->id);
} catch (RouteNotFoundException $e) {
// Domain-spezifische Routen sind im Test-Kontext nicht registriert – erwartet.
}
$trashed = UserAbo::withTrashed()->find($abo->id);
expect($trashed->deleted_at)->not->toBeNull();
expect($trashed->active)->toBeFalse();
});
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);