Fix endcustomer package allocation and event create gating
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-02-06 13:21:11 +01:00
parent 0291d537fb
commit df00deb0df
11 changed files with 409 additions and 14 deletions

View File

@@ -65,6 +65,34 @@ class PackageLimitEvaluatorTest extends TestCase
$this->assertSame(0, $violation['meta']['remaining']);
}
public function test_assess_event_creation_returns_violation_when_all_endcustomer_packages_are_consumed(): void
{
$tenant = Tenant::factory()->create();
$package = Package::factory()->endcustomer()->create();
$tenantPackage = TenantPackage::factory()->for($tenant)->for($package)->create([
'active' => true,
'expires_at' => now()->addMonth(),
]);
$event = Event::factory()->for($tenant)->create();
EventPackage::create([
'event_id' => $event->id,
'package_id' => $package->id,
'tenant_package_id' => $tenantPackage->id,
'purchased_price' => 0,
'purchased_at' => now(),
'gallery_expires_at' => now()->addDays(7),
]);
$violation = $this->evaluator->assessEventCreation($tenant, null);
$this->assertNotNull($violation);
$this->assertSame('event_limit_exceeded', $violation['code']);
$this->assertSame('endcustomer_packages', $violation['meta']['source']);
$this->assertSame(0, $violation['meta']['remaining']);
}
public function test_assess_photo_upload_returns_violation_when_photo_limit_reached(): void
{
$package = Package::factory()->endcustomer()->create([