<?php

declare(strict_types=1);

/*
 * This file is part of the Ferienpass package.
 *
 * (c) Richard Henkenjohann <richard@ferienpass.online>
 *
 * For more information visit the project website <https://ferienpass.online>
 * or the documentation under <https://docs.ferienpass.online>.
 */

namespace Ferienpass\CoreBundle\Tests\Entity;

use Ferienpass\CoreBundle\Entity\ConsentText;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Uid\Uuid;

final class ConsentTextTest extends TestCase
{
    public function testGetText(): void
    {
        $text = new ConsentText('My consent text');

        self::assertSame('My consent text', $text->getText());
    }

    public function testGetHashIsSha256OfText(): void
    {
        $text = new ConsentText('My consent text');

        self::assertSame(hash('sha256', 'My consent text'), $text->getHash());
    }

    public function testDifferentTextsHaveDifferentHashes(): void
    {
        $t1 = new ConsentText('Text A');
        $t2 = new ConsentText('Text B');

        self::assertNotSame($t1->getHash(), $t2->getHash());
    }

    public function testGetIdReturnsUuid(): void
    {
        $text = new ConsentText('My consent text');
        $uuid = Uuid::v7();
        $prop = new \ReflectionProperty(ConsentText::class, 'id');
        $prop->setValue($text, $uuid);

        self::assertSame($uuid, $text->getId());
    }
}
