<?php

namespace App\Tests\Entity;

use App\Entity\StripeWebhookSecret;
use PHPUnit\Framework\TestCase;

class StripeWebhookSecretTest extends TestCase
{
    public function testConstructorDefaults(): void
    {
        $secret = new StripeWebhookSecret('main_light', 'whsec_abc123');

        $this->assertNull($secret->getId());
        $this->assertSame('main_light', $secret->getType());
        $this->assertSame('whsec_abc123', $secret->getSecret());
        $this->assertNull($secret->getEndpointId());
        $this->assertInstanceOf(\DateTimeImmutable::class, $secret->getCreatedAt());
    }

    public function testConstructorWithEndpointId(): void
    {
        $secret = new StripeWebhookSecret('connect_instant', 'whsec_xyz', 'we_456');

        $this->assertSame('connect_instant', $secret->getType());
        $this->assertSame('whsec_xyz', $secret->getSecret());
        $this->assertSame('we_456', $secret->getEndpointId());
    }

    public function testSetSecret(): void
    {
        $secret = new StripeWebhookSecret('main_light', 'old_secret');
        $secret->setSecret('new_secret');

        $this->assertSame('new_secret', $secret->getSecret());
    }

    public function testSetEndpointId(): void
    {
        $secret = new StripeWebhookSecret('main_light', 'whsec_abc');
        $this->assertNull($secret->getEndpointId());

        $secret->setEndpointId('we_789');
        $this->assertSame('we_789', $secret->getEndpointId());

        $secret->setEndpointId(null);
        $this->assertNull($secret->getEndpointId());
    }

    public function testTypeConstants(): void
    {
        $this->assertSame('main_light', StripeWebhookSecret::TYPE_MAIN_LIGHT);
        $this->assertSame('main_instant', StripeWebhookSecret::TYPE_MAIN_INSTANT);
        $this->assertSame('connect_light', StripeWebhookSecret::TYPE_CONNECT_LIGHT);
        $this->assertSame('connect_instant', StripeWebhookSecret::TYPE_CONNECT_INSTANT);
    }
}
