removed all references to credits. now credits are completely replaced by addons.

This commit is contained in:
Codex Agent
2025-12-01 15:50:17 +01:00
parent b8e515a03c
commit 28539754a7
76 changed files with 97 additions and 2533 deletions

View File

@@ -5,7 +5,6 @@ namespace Tests\Feature\Console;
use App\Console\Commands\CheckEventPackages;
use App\Events\Packages\EventPackageGalleryExpired;
use App\Events\Packages\EventPackageGalleryExpiring;
use App\Events\Packages\TenantCreditsLow;
use App\Events\Packages\TenantPackageExpired;
use App\Events\Packages\TenantPackageExpiring;
use App\Models\Event;
@@ -144,73 +143,4 @@ class CheckEventPackagesCommandTest extends TestCase
}
}
public function test_dispatches_credit_warning_and_sets_threshold(): void
{
EventFacade::fake();
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,
]);
Artisan::call(CheckEventPackages::class);
EventFacade::assertDispatched(TenantCreditsLow::class, function ($event) use ($tenant) {
return $event->tenant->is($tenant) && $event->threshold === 5 && $event->balance === 5;
});
$tenant->refresh();
$this->assertNotNull($tenant->credit_warning_sent_at);
$this->assertSame(5, $tenant->credit_warning_threshold);
}
public function test_resets_credit_warning_when_balance_recovers(): void
{
EventFacade::fake();
Config::set('package-limits.credit_thresholds', [5, 1]);
$tenant = Tenant::factory()->create([
'event_credits_balance' => 10,
'credit_warning_sent_at' => now()->subDay(),
'credit_warning_threshold' => 1,
]);
Artisan::call(CheckEventPackages::class);
EventFacade::assertNotDispatched(TenantCreditsLow::class);
$tenant->refresh();
$this->assertNull($tenant->credit_warning_sent_at);
$this->assertNull($tenant->credit_warning_threshold);
}
public function test_dispatches_lower_credit_threshold_after_higher_warning(): void
{
EventFacade::fake();
Config::set('package-limits.credit_thresholds', [5, 1]);
$tenant = Tenant::factory()->create([
'event_credits_balance' => 1,
'credit_warning_sent_at' => now()->subDay(),
'credit_warning_threshold' => 5,
]);
Artisan::call(CheckEventPackages::class);
EventFacade::assertDispatched(TenantCreditsLow::class, function ($event) use ($tenant) {
return $event->tenant->is($tenant) && $event->threshold === 1;
});
$tenant->refresh();
$this->assertSame(1, $tenant->credit_warning_threshold);
$this->assertNotNull($tenant->credit_warning_sent_at);
}
}