Limit-Status im Upload-Flow anzeigen (Warnbanner + Sperrzustände).
Upload-Fehlercodes auswerten und freundliche Dialoge zeigen.
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Models\Tenant;
|
||||
use App\Models\TenantPackage;
|
||||
use App\Services\Packages\PackageLimitEvaluator;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PackageLimitEvaluatorTest extends TestCase
|
||||
@@ -125,4 +126,43 @@ class PackageLimitEvaluatorTest extends TestCase
|
||||
|
||||
$this->assertNull($violation);
|
||||
}
|
||||
|
||||
public function test_summarize_event_package_returns_expected_structure(): void
|
||||
{
|
||||
Config::set('package-limits.photo_thresholds', [0.5, 0.9]);
|
||||
Config::set('package-limits.guest_thresholds', [0.5]);
|
||||
Config::set('package-limits.gallery_warning_days', [7, 1]);
|
||||
|
||||
$package = Package::factory()->endcustomer()->create([
|
||||
'max_photos' => 10,
|
||||
'max_guests' => 20,
|
||||
'gallery_days' => 7,
|
||||
]);
|
||||
|
||||
$tenant = Tenant::factory()->create();
|
||||
|
||||
$event = Event::factory()->for($tenant)->create();
|
||||
|
||||
$eventPackage = EventPackage::create([
|
||||
'event_id' => $event->id,
|
||||
'package_id' => $package->id,
|
||||
'purchased_price' => $package->price,
|
||||
'purchased_at' => now()->subDay(),
|
||||
'used_photos' => 5,
|
||||
'used_guests' => 10,
|
||||
'gallery_expires_at' => now()->addDays(3),
|
||||
])->fresh(['package']);
|
||||
|
||||
$summary = $this->evaluator->summarizeEventPackage($eventPackage);
|
||||
|
||||
$this->assertSame(10, $summary['photos']['limit']);
|
||||
$this->assertSame(5, $summary['photos']['used']);
|
||||
$this->assertSame('warning', $summary['photos']['state']);
|
||||
$this->assertSame(20, $summary['guests']['limit']);
|
||||
$this->assertSame(10, $summary['guests']['used']);
|
||||
$this->assertSame('warning', $summary['guests']['state']);
|
||||
$this->assertSame('warning', $summary['gallery']['state']);
|
||||
$this->assertTrue($summary['can_upload_photos']);
|
||||
$this->assertTrue($summary['can_add_guests']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user