<?php

namespace Tests\Unit;

use App\Models\Package;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class PackagePaddleLinkTest extends TestCase
{
    use RefreshDatabase;

    public function test_link_paddle_ids_updates_fields(): void
    {
        $package = Package::factory()->create([
            'paddle_product_id' => null,
            'paddle_price_id' => null,
            'paddle_sync_status' => null,
            'paddle_synced_at' => null,
        ]);

        $package->linkPaddleIds('pro_123', 'pri_123');

        $package->refresh();

        $this->assertSame('pro_123', $package->paddle_product_id);
        $this->assertSame('pri_123', $package->paddle_price_id);
        $this->assertSame('linked', $package->paddle_sync_status);
        $this->assertNotNull($package->paddle_synced_at);
    }
}
