<?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\ResetPasswordRequest;
use Ferienpass\CoreBundle\Entity\User;
use PHPUnit\Framework\TestCase;

final class ResetPasswordRequestTest extends TestCase
{
    public function testGetIdIsNullByDefault(): void
    {
        $user = new User();
        $req = new ResetPasswordRequest($user, new \DateTimeImmutable('+1 hour'), 'selector123', 'hashedToken456');

        self::assertNull($req->getId());
    }

    public function testGetUserReturnsUser(): void
    {
        $user = new User();
        $req = new ResetPasswordRequest($user, new \DateTimeImmutable('+1 hour'), 'selector123', 'hashedToken456');

        self::assertSame($user, $req->getUser());
    }

    public function testIsExpiredReturnsFalseForFutureExpiry(): void
    {
        $user = new User();
        $req = new ResetPasswordRequest($user, new \DateTimeImmutable('+1 hour'), 'selector123', 'hashedToken456');

        self::assertFalse($req->isExpired());
    }

    public function testIsExpiredReturnsTrueForPastExpiry(): void
    {
        $user = new User();
        $req = new ResetPasswordRequest($user, new \DateTimeImmutable('-1 hour'), 'selector123', 'hashedToken456');

        self::assertTrue($req->isExpired());
    }

    public function testGetExpiresAtReturnsDatetime(): void
    {
        $user = new User();
        $expiresAt = new \DateTimeImmutable('+2 hours');
        $req = new ResetPasswordRequest($user, $expiresAt, 'selector123', 'hashedToken456');

        self::assertSame($expiresAt, $req->getExpiresAt());
    }
}
