<?php

declare(strict_types=1);

namespace Ferienpass\CoreBundle\Tests\Entity;

use Ferienpass\CoreBundle\Entity\HostConsent;
use Ferienpass\CoreBundle\Entity\User;
use PHPUnit\Framework\TestCase;

final class HostConsentTest extends TestCase
{
    public function testFromTextCreatesConsentWithCorrectHash(): void
    {
        $user = new User();
        $text = 'Terms and conditions text';
        $consent = HostConsent::fromText($text, $user);

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

    public function testFromTextCreatesSignedConsent(): void
    {
        $user = new User();
        $consent = HostConsent::fromText('some text', $user);

        self::assertNotNull($consent->getSignedAt());
        self::assertSame(1, $consent->getDecision());
    }
}
