<?php

declare(strict_types=1);

namespace CpCreation\VitiCore\Tests\Cart;

use CpCreation\VitiCore\Cart\Model\Promo;
use Doctrine\ORM\Mapping\Column;
use PHPUnit\Framework\TestCase;

final class PromoPostgreSqlMappingTest extends TestCase
{
    public function testRestrictedCountryCodesUsesComparableJsonbStorage(): void
    {
        $property = new \ReflectionProperty(Promo::class, 'restrictedCountryCodes');
        $attributes = $property->getAttributes(Column::class);

        self::assertCount(1, $attributes);

        $mapping = $attributes[0]->newInstance();

        self::assertSame('json', $mapping->type);
        self::assertTrue($mapping->options['jsonb'] ?? false);
    }
}
