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/Unit/RemoteSubscription/RemotePlanDTOTest.php
<?php

namespace Tests\Unit\RemoteSubscription;

use Tests\TestCase;
use App\Cashier\DTO\RemotePlanDTO;

class RemotePlanDTOTest extends TestCase
{
    public function test_it_creates_with_all_fields()
    {
        $dto = new RemotePlanDTO(
            id: 'price_123',
            name: 'Pro Monthly',
            price: 29.99,
            currency: 'USD',
            intervalCount: 1,
            intervalUnit: 'month',
            status: 'active',
            trialDays: 14,
            metadata: ['stripe_price_id' => 'price_123'],
        );

        $this->assertEquals('price_123', $dto->id);
        $this->assertEquals('Pro Monthly', $dto->name);
        $this->assertEquals(29.99, $dto->price);
        $this->assertEquals('USD', $dto->currency);
        $this->assertEquals(1, $dto->intervalCount);
        $this->assertEquals('month', $dto->intervalUnit);
        $this->assertEquals('active', $dto->status);
        $this->assertEquals(14, $dto->trialDays);
        $this->assertEquals('price_123', $dto->metadata['stripe_price_id']);
    }

    public function test_it_creates_without_trial_days()
    {
        $dto = new RemotePlanDTO(
            id: 'price_456',
            name: 'Basic',
            price: 9.99,
            currency: 'EUR',
            intervalCount: 1,
            intervalUnit: 'month',
            status: 'active',
        );

        $this->assertNull($dto->trialDays);
        $this->assertEmpty($dto->metadata);
    }

    public function test_summary_without_trial()
    {
        $dto = new RemotePlanDTO(
            id: 'price_1',
            name: 'Starter',
            price: 19.00,
            currency: 'USD',
            intervalCount: 1,
            intervalUnit: 'month',
            status: 'active',
        );

        $this->assertEquals('Starter: 19 USD every 1 month', $dto->summary());
    }

    public function test_summary_with_trial()
    {
        $dto = new RemotePlanDTO(
            id: 'price_2',
            name: 'Pro Annual',
            price: 199.00,
            currency: 'USD',
            intervalCount: 1,
            intervalUnit: 'year',
            status: 'active',
            trialDays: 30,
        );

        $this->assertEquals('Pro Annual: 199 USD every 1 year (30-day trial)', $dto->summary());
    }
}