Fix endcustomer package allocation and event create gating
This commit is contained in:
@@ -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([
|
||||
|
||||
Reference in New Issue
Block a user