<?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\CmsBundle\Tests\Form\SimpleType;

use Ferienpass\CmsBundle\Form\SimpleType\LoginUsernameType;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;

final class LoginUsernameTypeTest extends TestCase
{
    public function testGetParentReturnsEmailType(): void
    {
        $authUtils = $this->createMock(AuthenticationUtils::class);

        self::assertSame(EmailType::class, new LoginUsernameType($authUtils)->getParent());
    }

    public function testBuildViewSetsFullNameToUsername(): void
    {
        $authUtils = $this->createMock(AuthenticationUtils::class);

        $view = new FormView();
        $form = $this->createMock(FormInterface::class);

        new LoginUsernameType($authUtils)->buildView($view, $form, []);

        self::assertSame('username', $view->vars['full_name']);
    }
}
