Update partner packages, copy, and demo switcher
This commit is contained in:
@@ -34,7 +34,7 @@ class PackageLimitEvaluatorTest extends TestCase
|
||||
'active' => true,
|
||||
]);
|
||||
|
||||
$violation = $this->evaluator->assessEventCreation($tenant);
|
||||
$violation = $this->evaluator->assessEventCreation($tenant, null);
|
||||
|
||||
$this->assertNull($violation);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class PackageLimitEvaluatorTest extends TestCase
|
||||
|
||||
$tenant->refresh();
|
||||
|
||||
$violation = $this->evaluator->assessEventCreation($tenant);
|
||||
$violation = $this->evaluator->assessEventCreation($tenant, null);
|
||||
|
||||
$this->assertNotNull($violation);
|
||||
$this->assertSame('event_limit_exceeded', $violation['code']);
|
||||
|
||||
@@ -83,5 +83,6 @@ class TenantUsageTrackerTest extends TestCase
|
||||
$tenantPackage->refresh();
|
||||
|
||||
$this->assertNotNull($tenantPackage->event_limit_notified_at);
|
||||
$this->assertFalse($tenantPackage->active);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,4 +146,39 @@ class TenantModelTest extends TestCase
|
||||
$this->assertFalse($tenant->features['analytics']);
|
||||
}
|
||||
|
||||
public function test_consume_event_allowance_moves_to_next_credit_batch(): void
|
||||
{
|
||||
$tenant = Tenant::factory()->create();
|
||||
|
||||
$firstPackage = Package::factory()->reseller()->create([
|
||||
'max_events_per_year' => 1,
|
||||
]);
|
||||
|
||||
$secondPackage = Package::factory()->reseller()->create([
|
||||
'max_events_per_year' => 1,
|
||||
]);
|
||||
|
||||
$firstBatch = TenantPackage::factory()->for($tenant)->for($firstPackage)->create([
|
||||
'used_events' => 0,
|
||||
'active' => true,
|
||||
'expires_at' => null,
|
||||
'purchased_at' => now()->subDay(),
|
||||
]);
|
||||
|
||||
$secondBatch = TenantPackage::factory()->for($tenant)->for($secondPackage)->create([
|
||||
'used_events' => 0,
|
||||
'active' => true,
|
||||
'expires_at' => null,
|
||||
'purchased_at' => now(),
|
||||
]);
|
||||
|
||||
$this->assertTrue($tenant->consumeEventAllowance());
|
||||
$this->assertFalse($firstBatch->fresh()->active);
|
||||
$this->assertTrue($secondBatch->fresh()->active);
|
||||
|
||||
$this->assertTrue($tenant->consumeEventAllowance());
|
||||
$this->assertFalse($secondBatch->fresh()->active);
|
||||
|
||||
$this->assertFalse($tenant->consumeEventAllowance());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class TenantPackageTest extends TestCase
|
||||
$this->assertTrue($tenantPackage->expires_at->lessThanOrEqualTo(now()->addYears(2)));
|
||||
}
|
||||
|
||||
public function test_reseller_packages_still_expire(): void
|
||||
public function test_reseller_packages_do_not_expire_by_default_but_can_be_expired(): void
|
||||
{
|
||||
$package = Package::factory()->reseller()->create(['max_events_per_year' => 5]);
|
||||
|
||||
@@ -41,8 +41,8 @@ class TenantPackageTest extends TestCase
|
||||
|
||||
$tenantPackage->refresh();
|
||||
|
||||
$this->assertNotNull($tenantPackage->expires_at);
|
||||
$this->assertTrue($tenantPackage->expires_at->isFuture());
|
||||
$this->assertNull($tenantPackage->expires_at);
|
||||
$this->assertTrue($tenantPackage->isActive());
|
||||
|
||||
$tenantPackage->forceFill(['expires_at' => now()->subDay()])->save();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user