presseportale/tests/Feature/PressReleaseQuotaTest.php
Kevin Adametz a000238ca8 User Panel: Phase-8-Abschluss, Titelbild/Lizenzen/Zeitzonen und KI-Pruef-Pipeline
Phase 8 (Rest) + Umbauten vom 10./11.06.:
- Ein Titelbild pro PM (Cover 1280x580), SVG-Platzhalter-Set + Picker,
  PressReleaseCoverImage-Resolver
- Lizenz-/Rechteformular nach "Lizenztyp Bildupload" (7 Lizenztypen,
  Personen-/Sachrechte-Status, bedingte Pflichtfelder, Risikohinweise)
- Veroeffentlichungs-Box vereinfacht (Embargo aus der Form-UI entfernt),
  geplante Termine in Europe/Berlin (Speicherung UTC, DISPLAY_TIMEZONE)
- Quota-Stub (users.press_release_quota) + monatlicher Reset-Command
- Einreichungs-Modal einheitlich in Show/Create/Edit; Ghost-Buttons auf
  filled; PM-Editor-Layout responsive entkoppelt (.pr-editor-layout)

KI-Pruef-Pipeline (Phasen 1-5 des Entwicklungsplans):
- API-Haertung: status nicht mehr per API setzbar, eigene Submit-Route
  durch denselben Funnel (Blacklist, Quota, Status-Log)
- Klassifikation Rot/Gelb/Gruen asynchron (Queue classification,
  OpenAI-Treiber + deterministischer Fallback), ki_audits-Audit-Log
- Routing: Rot -> rejected + Mail, Gelb -> Review-Queue, Gruen ->
  Auto-Publish; Scheduler publiziert nur gruene faellige PMs
- Content-Score 0-100 -> Stufe (Standard/Geprueft/Hochwertig) inkl.
  Editor-Panel und Badges; Re-Klassifikation/-Score bei Aenderung
- Admin: KI-Badge + Filter, On-Demand-Pruefung mit Anbieter-Override

Suite: 442 passed, 4 skipped.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 08:30:13 +00:00

57 lines
1.9 KiB
PHP

<?php
use App\Console\Commands\ResetMonthlyPressReleaseQuota;
use App\Models\Category;
use App\Models\Company;
use App\Models\PressRelease;
use App\Models\User;
use App\Services\PressRelease\PressReleaseService;
use Database\Seeders\RolesAndPermissionsSeeder;
use Tests\TestCase;
beforeEach(function (): void {
/** @var TestCase $this */
$this->seed(RolesAndPermissionsSeeder::class);
});
test('remaining quota reflects the used counter', function () {
$user = User::factory()->create([
'press_release_quota' => 3,
'press_release_quota_used_this_month' => 1,
]);
expect($user->pressReleaseQuotaRemaining())->toBe(2);
});
test('submitting a press release for review increments the monthly quota usage', function () {
$user = User::factory()->create([
'press_release_quota' => 3,
'press_release_quota_used_this_month' => 0,
]);
$user->assignRole('customer');
$company = Company::factory()->presseecho()->create();
$user->companies()->attach($company->id, ['role' => 'owner']);
$pr = PressRelease::factory()->create([
'user_id' => $user->id,
'company_id' => $company->id,
'category_id' => Category::factory()->create()->id,
'portal' => $company->portal->value,
'status' => 'draft',
]);
app(PressReleaseService::class)->submitForReview($pr);
expect($user->fresh()->press_release_quota_used_this_month)->toBe(1);
});
test('monthly reset command zeroes the used counter', function () {
User::factory()->count(2)->create(['press_release_quota_used_this_month' => 2]);
$untouched = User::factory()->create(['press_release_quota_used_this_month' => 0]);
$this->artisan(ResetMonthlyPressReleaseQuota::class)->assertSuccessful();
expect(User::where('press_release_quota_used_this_month', '>', 0)->count())->toBe(0);
expect($untouched->fresh()->press_release_quota_used_this_month)->toBe(0);
});