removed all references to credits. now credits are completely replaced by addons.
This commit is contained in:
@@ -26,7 +26,13 @@ class PackageLimitEvaluatorTest extends TestCase
|
||||
|
||||
public function test_assess_event_creation_returns_null_when_allowance_available(): void
|
||||
{
|
||||
$tenant = Tenant::factory()->create(['event_credits_balance' => 2]);
|
||||
$tenant = Tenant::factory()->create();
|
||||
$package = Package::factory()->reseller()->create(['max_events_per_year' => 5]);
|
||||
TenantPackage::factory()->for($tenant)->for($package)->create([
|
||||
'used_events' => 1,
|
||||
'expires_at' => now()->addMonth(),
|
||||
'active' => true,
|
||||
]);
|
||||
|
||||
$violation = $this->evaluator->assessEventCreation($tenant);
|
||||
|
||||
@@ -39,7 +45,7 @@ class PackageLimitEvaluatorTest extends TestCase
|
||||
'max_events_per_year' => 1,
|
||||
]);
|
||||
|
||||
$tenant = Tenant::factory()->create(['event_credits_balance' => 0]);
|
||||
$tenant = Tenant::factory()->create();
|
||||
|
||||
TenantPackage::factory()->create([
|
||||
'tenant_id' => $tenant->id,
|
||||
@@ -59,17 +65,6 @@ class PackageLimitEvaluatorTest extends TestCase
|
||||
$this->assertSame(0, $violation['meta']['remaining']);
|
||||
}
|
||||
|
||||
public function test_assess_event_creation_returns_credit_violation_when_no_credits(): void
|
||||
{
|
||||
$tenant = Tenant::factory()->create(['event_credits_balance' => 0]);
|
||||
|
||||
$violation = $this->evaluator->assessEventCreation($tenant);
|
||||
|
||||
$this->assertNotNull($violation);
|
||||
$this->assertSame('event_credits_exhausted', $violation['code']);
|
||||
$this->assertSame('credits', $violation['meta']['scope']);
|
||||
}
|
||||
|
||||
public function test_assess_photo_upload_returns_violation_when_photo_limit_reached(): void
|
||||
{
|
||||
$package = Package::factory()->endcustomer()->create([
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Tests\Unit\Services;
|
||||
|
||||
use App\Events\Packages\TenantCreditsLow;
|
||||
use App\Events\Packages\TenantPackageEventLimitReached;
|
||||
use App\Events\Packages\TenantPackageEventThresholdReached;
|
||||
use App\Models\Package;
|
||||
@@ -85,31 +84,4 @@ class TenantUsageTrackerTest extends TestCase
|
||||
|
||||
$this->assertNotNull($tenantPackage->event_limit_notified_at);
|
||||
}
|
||||
|
||||
public function test_record_credit_balance_dispatches_event_and_updates_tenant(): void
|
||||
{
|
||||
EventFacade::fake([TenantCreditsLow::class]);
|
||||
|
||||
Config::set('package-limits.credit_thresholds', [5, 1]);
|
||||
|
||||
$tenant = Tenant::factory()->create([
|
||||
'event_credits_balance' => 5,
|
||||
'credit_warning_sent_at' => null,
|
||||
'credit_warning_threshold' => null,
|
||||
]);
|
||||
|
||||
/** @var TenantUsageTracker $tracker */
|
||||
$tracker = app(TenantUsageTracker::class);
|
||||
|
||||
$tracker->recordCreditBalance($tenant, 6, 5);
|
||||
|
||||
EventFacade::assertDispatched(TenantCreditsLow::class, function ($event) use ($tenant) {
|
||||
return $event->tenant->is($tenant) && $event->threshold === 5;
|
||||
});
|
||||
|
||||
$tenant->refresh();
|
||||
|
||||
$this->assertNotNull($tenant->credit_warning_sent_at);
|
||||
$this->assertSame(5, $tenant->credit_warning_threshold);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user