Files
ladill-events/tests/Feature/EventsProTest.php
T
isaacclad 25ce2bc9de
Deploy Ladill Events / deploy (push) Successful in 55s
Retire Events subscriptions and owner payment gateways.
Make Ladill Events free for all accounts, remove plan upgrade UI, force Ladill Pay only for tickets and contributions, and reinstate standard platform fees.
2026-07-24 14:15:34 +00:00

70 lines
2.1 KiB
PHP

<?php
namespace Tests\Feature;
use App\Http\Middleware\EnsurePlatformSession;
use App\Models\PaymentGatewaySetting;
use App\Models\User;
use App\Services\Events\SubscriptionService;
use App\Services\Payments\MerchantGatewayService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class EventsProTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
$this->withoutMiddleware(EnsurePlatformSession::class);
config([
'billing.api_url' => 'https://ladill.com/api/billing',
'billing.api_key' => 'events-billing-key',
'events.pro.enabled' => false,
]);
}
private function user(): User
{
return User::factory()->create(['public_id' => 'usr_'.uniqid()]);
}
public function test_subscriptions_are_retired(): void
{
$svc = app(SubscriptionService::class);
$user = $this->user();
$this->assertFalse($svc->gatingActive());
$this->assertTrue($svc->hasPaidPlan($user));
$this->assertTrue($svc->canCreateEvent($user));
$this->assertFalse($svc->canUsePaymentGateway($user));
}
public function test_pro_routes_redirect_to_dashboard(): void
{
$this->actingAs($this->user())
->get(route('events.pro.index'))
->assertRedirect(route('events.dashboard'));
$this->actingAs($this->user())
->post(route('events.pro.subscribe'))
->assertRedirect(route('events.dashboard'));
}
public function test_owner_gateway_is_never_used(): void
{
$user = $this->user();
PaymentGatewaySetting::create([
'owner_ref' => $user->public_id,
'provider' => PaymentGatewaySetting::PROVIDER_PAYSTACK,
'public_key' => 'pk_test',
'secret_key' => 'sk_test',
'is_active' => true,
]);
$this->assertFalse(app(MerchantGatewayService::class)->shouldUseOwnerGateway($user));
$this->assertFalse(app(MerchantGatewayService::class)->isConfigured($user));
}
}