hooks in config/services.php/.env.example, and updated wizard steps/controllers to store session payloads, attach packages, and surface localized success/error states. - Retooled payment handling for both Stripe and PayPal, adding richer status management in CheckoutController/ PayPalController, fallback flows in the wizard’s PaymentStep.tsx, and fresh feature tests for intent creation, webhooks, and the wizard CTA. - Introduced a consent-aware Matomo analytics stack: new consent context, cookie-banner UI, useAnalytics/ useCtaExperiment hooks, and MatomoTracker component, then instrumented marketing pages (Home, Packages, Checkout) with localized copy and experiment tracking. - Polished package presentation across marketing UIs by centralizing formatting in PresentsPackages, surfacing localized description tables/placeholders, tuning badges/layouts, and syncing guest/marketing translations. - Expanded docs & reference material (docs/prp/*, TODOs, public gallery overview) and added a Playwright smoke test for the hero CTA while reconciling outstanding checklist items.
69 lines
1.9 KiB
PHP
69 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Models\Package;
|
|
use App\Models\Tenant;
|
|
use App\Models\TenantPackage;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class TenantCreditTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_consume_event_allowance_uses_reseller_package(): void
|
|
{
|
|
$package = Package::factory()
|
|
->reseller()
|
|
->create([
|
|
'max_events_per_year' => 5,
|
|
]);
|
|
|
|
$tenant = Tenant::factory()->create([
|
|
'event_credits_balance' => 0,
|
|
]);
|
|
|
|
TenantPackage::factory()->for($tenant)->for($package)->create([
|
|
'used_events' => 1,
|
|
'active' => true,
|
|
]);
|
|
|
|
$this->assertTrue($tenant->consumeEventAllowance());
|
|
|
|
$updatedPackage = $tenant->getActiveResellerPackage();
|
|
$this->assertNotNull($updatedPackage);
|
|
$this->assertSame(2, $updatedPackage->used_events);
|
|
}
|
|
|
|
public function test_consume_event_allowance_decrements_credits_when_no_package(): void
|
|
{
|
|
$tenant = Tenant::factory()->create([
|
|
'event_credits_balance' => 2,
|
|
]);
|
|
|
|
$this->assertTrue($tenant->consumeEventAllowance(1, 'event.create', 'Event #1 created'));
|
|
|
|
$tenant->refresh();
|
|
$this->assertSame(1, $tenant->event_credits_balance);
|
|
|
|
$this->assertDatabaseHas('event_credits_ledger', [
|
|
'tenant_id' => $tenant->id,
|
|
'delta' => -1,
|
|
'reason' => 'event.create',
|
|
'note' => 'Event #1 created',
|
|
]);
|
|
}
|
|
|
|
public function test_consume_event_allowance_returns_false_without_package_or_credits(): void
|
|
{
|
|
$tenant = Tenant::factory()->create([
|
|
'event_credits_balance' => 0,
|
|
]);
|
|
|
|
$this->assertFalse($tenant->consumeEventAllowance());
|
|
|
|
$this->assertDatabaseCount('event_credits_ledger', 0);
|
|
}
|
|
}
|