HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: /home/xedaptot/ai.naniguide.com/tests/Feature/PlanQuotaFeatureTest.php
<?php

/**
 * Plan quota and options feature tests.
 *
 * Tests plan model behavior, options parsing, and quota enforcement logic.
 */

use App\Model\Plan;

test('plan status constants are defined', function () {
    expect(Plan::STATUS_ACTIVE)->toBe('active');
    expect(Plan::STATUS_INACTIVE)->toBe('inactive');
});

test('plan model accepts attributes', function () {
    $plan = new Plan([
        'name' => 'Pro Plan',
        'price' => 29.99,
        'frequency_amount' => 1,
        'frequency_unit' => 'month',
    ]);

    expect($plan->name)->toBe('Pro Plan');
    expect((float) $plan->price)->toBe(29.99);
    expect((int) $plan->frequency_amount)->toBe(1);
    expect($plan->frequency_unit)->toBe('month');
});

test('plan uses plans table', function () {
    $plan = new Plan();
    expect($plan->getTable())->toBe('plans');
});

test('plan frequency units are valid', function () {
    $validUnits = ['day', 'week', 'month', 'year'];

    foreach ($validUnits as $unit) {
        $plan = new Plan(['frequency_unit' => $unit]);
        expect($plan->frequency_unit)->toBe($unit);
    }
});