m\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormFactoryBuilder;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Collection;
use Symfony\Component\Validator\Constraints\Expression;
use Symfony\Component\Validator\Constraints\GroupSequence;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\Not

Loader\StaticMethodLoader;
use Symfony\Component\Validator\Validation;
use Symfony\Component\Validator\Validator\ValidatorInterface;

class FormValidatorFunctionalTest extends TestCase
{
    private ValidatorInterface $validator;
    private FormFactoryInt

Blank;
use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
use Symfony\Component\Validator\Mapping\


 part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Validator\Constraints;

use PHPUnit\Framework\Attributes\Group;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface;
use Symfony\Component\Form\Tes

ensions(?ViolationMapperInterface $violationMapper = null): array
    {
        return [
            new ValidatorExtension(Validation::createValidator(), $violationMapper),
        ];
    }

    /**
     * findClickedButton() used to have an exponential n

t\FormPerformanceTestCase;
use Symfony\Component\Validator\Validation;

/**
 * @author Bernhard Schussek <bschussek@gmail.com>
 */
class FormValidatorPerformanceTest extends FormPerformanceTestCase
{
    protected function getExt


php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Validator\Type;

use Symfony\Component\Form\Extension\Core\Type\BirthdayType;

class BirthdayTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase
{
    protected function createForm(array $options = [])
    {

, null, $options + ['widget' => 'choice']);
    }

    public function testInvalidMessage()
    {
        $form = $this->createForm();

        $this->assertSame('Please enter a valid birthdate.', $form->getConfig()->getOption('invalid_message'));
    }
}


buted with this source code.
 */

namespace Symfony\Component\Form\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\ButtonBuilder;
use Symfony\Component\Form\Exception\InvalidArgumentException;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormFactory;
use Symfony\Comp

mFactory $factory;
    private FormBuilder $builder;

    protected function setUp(): void
    {
        $this->factory = new FormFactory(new FormRegistry([], new ResolvedFormTypeFactory()));
        $this->builder = new FormBuilder('name', null, new Event

onent\Form\FormFactoryBuilder;
use Symfony\Component\Form\FormRegistry;
use Symfony\Component\Form\ResolvedFormTypeFactory;
use Symfony\Component\Form\SubmitButtonBuilder;

class FormBuilderTest extends TestCase
{
    private For


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\FormConfigBuilder;
use Symfony\Component\Form\NativeRequestHandler;

/**
 * @author Bernhard Schussek <bschussek@gmail.com>
 */
class FormConfigTest extends TestCase
{
    pu

 ['a#', 'Symfony\Component\Form\Exception\InvalidArgumentException'],
            ['a$', 'Symfony\Component\Form\Exception\InvalidArgumentException'],
            ['a%', 'Symfony\Component\Form\Exception\InvalidArgumentException'],
            ['a ', 'Symf

blic static function getHtml4Ids()
    {
        return [
            ['z0'],
            ['A0'],
            ['A9'],
            ['Z0'],
            ['#', 'Symfony\Component\Form\Exception\InvalidArgumentException'],


buted with this source code.
 */

namespace Symfony\Component\Form\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormRegistry;
use Symfony\Component\Form\FormTypeGuesserChain;
use Symfony\Component\Form\FormTypeGuesserInterface;
use Symfony\Component\Form\Guess\Guess;
use Symfony\Component\Form\Guess\TypeGuess;
use Symfony\Componen

sek@gmail.com>
 */
class FormFactoryTest extends TestCase
{
    private ConfigurableFormTypeGuesser $guesser1;
    private ConfigurableFormTypeGuesser $guesser2;
    private FormRegistry $registry;
    private FormFactory $factory;

    protected function

t\Form\Guess\ValueGuess;
use Symfony\Component\Form\PreloadedExtension;
use Symfony\Component\Form\ResolvedFormTypeFactory;
use Symfony\Component\Form\Tests\Fixtures\ConfigurableFormType;

/**
 * @author Bernhard Schussek <bschus


 This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\BadMethodCallException;
use Symfony\Component\Form\FormRenderer;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\Tests\Fixtures\DummyFormRendererEngine;

class

  $this->assertEquals('Is active', $renderer->humanize('isActive'));
    }

    public function testRenderARenderedField()
    {
        $this->expectException(BadMethodCallException::class);
        $this->expectExceptionMessage('Field "foo" has already b

FormRendererTest extends TestCase
{
    public function testHumanize()
    {
        $renderer = new FormRenderer(new DummyFormRendererEngine());

        $this->assertEquals('Is active', $renderer->humanize('is_active'));


buted with this source code.
 */

namespace Symfony\Component\Form\Tests;

use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Form\NativeRequestHandler;

/**
 * @author Bernhard Schussek <bschussek@gmail.com>
 */
class NativeRequestHandlerTest extends AbstractRequestHandlerTestCase
{
    private static array $serverBackup;

    public static function setUpBeforeClass(): void
    {
        self::$serverBackup = $_SERVER;
    }

    protected function setUp(): void
    {

   protected function tearDown(): void
    {
        $_GET = [];
        $_POST = [];
        $_FILES = [];
        $_SERVER = self::$serverBackup;
    }

    public function testRequestShouldBeNull()
    {
        $this->expectException(UnexpectedTypeExce

   parent::setUp();

        $_GET = [];
        $_POST = [];
        $_FILES = [];
        $_SERVER = [
            // PHPUnit needs this entry
            'SCRIPT_NAME' => self::$serverBackup['SCRIPT_NAME'],
        ];
    }


unt = $count;
    }

    public function count(): int
    {
        return $this->count;
    }
}

class SimpleFormTest_Traversable implements \IteratorAggregate
{
    private \ArrayIterator $iterator;

    public function __construct($count)
    {
        $this->iterator = new \ArrayIterator($count > 0 ? array_fill(0, $count, 'Foo') : []);
    }

    public function getIterator(): \Traversable
    {
        return $this->iterator;
    }
}

class SimpleFormTest extends TestCase
{
    private Form $form;

gBuilder($name, null, new EventDispatcher());
        $form = new Form($config);

        $this->assertEquals($propertyPath, $form->getPropertyPath());
    }

    public static function provideFormNames(): iterable
    {
        yield [null, null];

 protected function setUp(): void
    {
        $this->form = $this->createForm();
    }

    #[DataProvider('provideFormNames')]
    public function testGetPropertyPath($name, $propertyPath)
    {
        $config = new FormConfi


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Flow;

use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Exception\InvalidArgumentException;
use Symfony\Component\Form\Exception\LogicException;
use Symfony\Component\Form\Flow\DataStorage\InMemoryDataStorage;
use Symfony\Component\Form\Flow\FormFlowBuilder;
use Symfony\C

s\PropertyPath;

class FormFlowBuilderTest extends TestCase
{
    private FormFactoryInterface $factory;
    private InMemoryDataStorage $dataStorage;
    private PropertyPathStepAccessor $stepAccessor;

    protected function setUp(): void
    {
        $

omponent\Form\Flow\StepAccessor\PropertyPathStepAccessor;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\Forms;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\PropertyAcces


adataFactory(new AttributeLoader()))
            ->getValidator();

        $this->factory = Forms::createFormFactoryBuilder()
            ->addExtensions([new ValidatorExtension($validator)])
            ->getFormFactory();
    }

    public function testFlowConfig()
    {
        $flow = $this->factory->create(UserSignUpType::class, new UserSignUp());
        $config = $flow->getConfig();

        self::assertInstanceOf(UserSignUp::class, $data = $config->getData());
        self::assertEquals(['data' =>

e($config->hasStep('account'));
    }

    public function testFlowCursor()
    {
        $flow = $this->factory->create(UserSignUpType::class, new UserSignUp());
        $cursor = $flow->getCursor();

        self::assertSame('personal', $cursor->getCurre

$data], $config->getInitialOptions());
        self::assertCount(3, $config->getSteps());
        self::assertTrue($config->hasStep('personal'));
        self::assertTrue($config->hasStep('professional'));
        self::assertTru


 This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\DataCollector;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Extension\DataCollector\DataCollectorExtension;
use Symfony\Component\Form\Extension\DataCollector\FormDataCollector;
use Symfony\Component\Form\Extension\DataCol

tion setUp(): void
    {
        $this->extension = new DataCollectorExtension(new FormDataCollector(new FormDataExtractor()));
    }

    public function testLoadTypeExtensions()
    {
        $typeExtensions = $this->extension->getTypeExtensions('Symfony

lector\FormDataExtractor;
use Symfony\Component\Form\Extension\DataCollector\Type\DataCollectorTypeExtension;

class DataCollectorExtensionTest extends TestCase
{
    private DataCollectorExtension $extension;

    protected func


nt\Form\CallbackTransformer;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataMapper\DataMapper;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\DataCollector\FormDataExtractor;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormRegistry;
use Symfony\Component\Form\FormView;
use Symfony\Component\For

aintViolation;
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;

/**
 * @author Bernhard Schussek <bschussek@gmail.com>
 */
class FormDataExtractorTest extends TestCase
{
    use VarDumperTestTrait;

    private FormDataExtractor $dataExtractor;

m\ResolvedFormType;
use Symfony\Component\Form\ResolvedFormTypeFactory;
use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer;
use Symfony\Component\Validator\Constraints\WordCount;
use Symfony\Component\Validator\Constr


ent\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\Test\TypeTestCase;
use Symfony\Component\Security\Csrf\CsrfToken;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
use Symfony\Component\Translation\IdentityTra

tion by
        // default
        $builder->add('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
    }
}

class FormTypeCsrfExtensionTest extends TypeTestCase
{
    protected MockObject&CsrfTokenManagerInterface $tokenManager;

    protecte

nslator;

class FormTypeCsrfExtensionTest_ChildType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        // The form needs a child in order to trigger CSRF protec


buted with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Validator;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\C

Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\Validator\Constraints\IsTrue;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Compone

ore\Type\TextType;
use Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser;
use Symfony\Component\Form\Guess\Guess;
use Symfony\Component\Form\Guess\TypeGuess;
use Symfony\Component\Form\Guess\ValueGuess;
use Symfony\


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Validator\Type;

use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface;
use Symfony\Component\Form\Test\FormInterface;
use Symfony\Component\Form\Test\TypeTestCase;
use Sy

{
    protected function setUp(): void
    {
        $this->dispatcher = new EventDispatcher();

        parent::setUp();
    }

    public function testValidationGroupNullByDefault()
    {
        $form = $this->createForm();

        $this->assertNull($

mfony\Component\Validator\Constraints\GroupSequence;
use Symfony\Component\Validator\ValidatorBuilder;

/**
 * @author Bernhard Schussek <bschussek@gmail.com>
 */
abstract class BaseValidatorExtensionTestCase extends TypeTestCase


/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Validator\Type;

use Symfony\Component\Form\Extension\Core\Type\CheckboxType;

class CheckboxTypeValidatorExtensionTest extends BaseValidatorExtensionTestCase
{
    protected function createForm(array $options = [])
    {

factory->create(CheckboxType::class, null, $options);
    }

    public function testInvalidMessage()
    {
        $form = $this->createForm();

        $this->assertSame('The checkbox has an invalid value.', $form->getConfig()->getOption('invalid_message


buted with this source code.
 */

namespace Symfony\Component\Form\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\InvalidArgumentException;
use Symfony\Component\Form\Exception\LogicException;
use Symfony\Component\Form\FormRegistry;
use Symfony\Component\Form\FormTypeGuesserChain;
use Symfony\Component\Form\PreloadedExtension;
use Symfony\Component\Form\ResolvedFormType;
use Symfony\Component\Form\ResolvedFormTypeFactory;
use Symfony\Component\Form\Tests\Fixtures\FooSubType;
u

eParentType;
use Symfony\Component\Form\Tests\Fixtures\NullFormTypeGuesser;
use Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeBar;
use Symfony\Component\Form\Tests\Fixtures\RecursiveFormTypeBaz;
use Symfony\Component\Form\Tests\Fixtures\RecursiveF

se Symfony\Component\Form\Tests\Fixtures\FooType;
use Symfony\Component\Form\Tests\Fixtures\FooTypeBarExtension;
use Symfony\Component\Form\Tests\Fixtures\FooTypeBazExtension;
use Symfony\Component\Form\Tests\Fixtures\FormWithSam


buted with this source code.
 */

namespace Symfony\Component\Form\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form

res\ConfigurableFormType;
use Symfony\Component\OptionsResolver\Exception\MissingOptionsException;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
 * @author Bernhard Schussek <bschussek@gmail.com>
 */
class ResolvedFormTypeTest extends TestCas

\FormInterface;
use Symfony\Component\Form\FormRegistry;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\ResolvedFormType;
use Symfony\Component\Form\ResolvedFormTypeFactory;
use Symfony\Component\Form\Tests\Fixtu


 This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Flow\Type;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Flow\Type\NavigatorFlowType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\Forms;

class NavigatorFlowTypeTest extends TestCase
{
    private Form

form = $this->factory->create(NavigatorFlowType::class);

        self::assertTrue($form->has('previous'));
        self::assertTrue($form->has('next'));
        self::assertTrue($form->has('finish'));
        self::assertFalse($form->has('reset'));
    }

FactoryInterface $factory;

    protected function setUp(): void
    {
        $this->factory = Forms::createFormFactoryBuilder()->getFormFactory();
    }

    public function testDefaultOptionsDoNotIncludeReset()
    {
        $


nterface;
use Symfony\Component\Form\FormRegistry;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\ResolvedFormTypeFactory;

class FormDataCollectorTest extends TestCase
{
    private FormDataCollector $dataCollector;
    private FormFactory $factory;
    private FormInterface $form;
    private FormInterface $childForm;
    private FormView $view;
    private FormView $childView;

    protected function setUp(): void
    {
        $this->dataCollector = new FormDataCollector(new FormDataExt

d');
        $this->view = new FormView();
        $this->childView = new FormView();
    }

    public function testBuildPreliminaryFormTree()
    {
        $this->form->add($this->childForm);

        $this->dataCollector->collectConfiguration($this->for

ractor());
        $this->factory = new FormFactory(new FormRegistry([new CoreExtension()], new ResolvedFormTypeFactory()));
        $this->form = $this->createForm('name');
        $this->childForm = $this->createChildForm('chil


buted with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\PasswordHasher\Type;

use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Exception\InvalidConfigurationException;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\PasswordHasher\EventL

\TypeTestCase;
use Symfony\Component\Form\Tests\Fixtures\RepeatedPasswordField;
use Symfony\Component\Form\Tests\Fixtures\User;
use Symfony\Component\PasswordHasher\Hasher\MessageDigestPasswordHasher;
use Symfony\Component\PasswordHasher\Hasher\PasswordHas

istener\PasswordHasherListener;
use Symfony\Component\Form\Extension\PasswordHasher\PasswordHasherExtension;
use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface;
use Symfony\Component\Form\Test


ge.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormErrorIterator;
use Symfony\Component\Form

indByCodesProvider')]
    public function testFindByCodes($code, $violationsCount)
    {
        $formBuilder = new FormBuilder(
            'form',
            null,
            new EventDispatcher(),
            new FormFactory(new FormRegistry([], new R

\FormFactory;
use Symfony\Component\Form\FormRegistry;
use Symfony\Component\Form\ResolvedFormTypeFactory;
use Symfony\Component\Validator\ConstraintViolation;

class FormErrorIteratorTest extends TestCase
{
    #[DataProvider('f


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Extension\Core\DataMapper\DataMapper;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormRegistry;
use Symfony\Component\Form\MissingDataHandler;
use Symfony\Com

parent', ['false_values' => [false]])
            ->setCompound(true)
            ->setDataMapper(new DataMapper())
            ->add($this->createBuilder('child', ['false_values' => [null]]))
            ->getForm();

        $this->assertSame(['child' =>

ponent\Form\ResolvedFormTypeFactory;

class MissingDataHandlerTest extends TestCase
{
    public function testFalseValuesMatchIsStrict()
    {
        $handler = new MissingDataHandler();

        $parent = $this->createBuilder('


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Flow\DataStorage;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Flow\DataStorage\SessionDataStorage;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionSt

torage());
        $request = new Request();
        $request->setSession($this->session);

        $requestStack = new RequestStack();
        $requestStack->push($request);

        $this->storage = new SessionDataStorage('test_key', $requestStack);

orage;

class SessionDataStorageTest extends TestCase
{
    private SessionDataStorage $storage;
    private Session $session;

    protected function setUp(): void
    {
        $this->session = new Session(new MockArraySessionS


\FormFactoryBuilder;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\SubmitButtonBuilder;
use Symfony\Component\Translation\IdentityTranslator;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\GroupSequence;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Cons

mail.com>
 */
class FormValidatorTest extends ConstraintValidatorTestCase
{
    private EventDispatcher $dispatcher;
    private FormFactoryInterface $factory;

    protected function setUp(): void
    {
        $this->dispatcher = new EventDispatcher();

traints\Valid;
use Symfony\Component\Validator\Context\ExecutionContext;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
use Symfony\Component\Validator\Validation;

/**
 * @author Bernhard Schussek <bschussek@g


buted with this source code.
 */

namespace Symfony\Component\Form\Tests\Flow;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\InvalidArgumentException;
use Symfony\Component\Form\Flow\FormFlowCursor;

class FormFlowCursorTest extends TestCase
{
    private static array $steps = ['personal', 'professional', 'account'];

    public function testConstructorWithValidStep()
    {
        $cursor = new FormFlowCursor(self::$steps, 'personal');

        $this->assertSame(self::$steps, $curso

xpectExceptionMessage('Step "invalid" does not exist. Available steps are: "personal", "professional", "account".');

        new FormFlowCursor(self::$steps, 'invalid');
    }

    public function testGetSteps()
    {
        $cursor = new FormFlowCursor(

r->getSteps());
        $this->assertSame('personal', $cursor->getCurrentStep());
    }

    public function testConstructorWithInvalidStep()
    {
        $this->expectException(InvalidArgumentException::class);
        $this->e


 part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormFactoryBuilder;
use Symfony\Component\Form\Tests\Fixtures\FooType;
use Symfony\Component\Form\Tests\Fixtures\NullFormTypeGuesser;

class FormFactoryBuilder

tory->getProperty('registry');

        $this->type = new FooType();
    }

    public function testAddType()
    {
        $factoryBuilder = new FormFactoryBuilder();
        $factoryBuilder->addType($this->type);

        $factory = $factoryBuilder->getF

Test extends TestCase
{
    private \ReflectionProperty $registry;
    private FooType $type;

    protected function setUp(): void
    {
        $factory = new \ReflectionClass(FormFactory::class);
        $this->registry = $fac


;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormInterface;

class DateIntervalTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = DateIntervalType::class;

    public function testSubmitDateInterval()
    {
        $form = $this->factory->create(static::TESTED_TYPE, null, ['input' => 'dateinterval']);

        $form->submit([
            'years' => '7',
            'months' => '6',
            'days' => '5',
        ]);

        $this->assertDateIntervalEquals(new \Date

 '7',
            'months' => '6',
            'days' => '5',
        ]);

        $this->assertSame('P7Y6M5D', $form->getData());
    }

    public function testSubmitArray()
    {
        $form = $this->factory->create(static::TESTED_TYPE, null, ['input'

Interval('P7Y6M5D'), $form->getData());
    }

    public function testSubmitString()
    {
        $form = $this->factory->create(static::TESTED_TYPE, null, ['input' => 'string']);

        $form->submit([
            'years' =>


ge.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;

class UrlTypeTest extends TextTypeTest
{
    public const TESTED_TYPE = UrlType::class;

    public function testSubmitAddsNoDefaultPr

'ftp://www.domain.com', $form->getData());
        $this->assertSame('ftp://www.domain.com', $form->getViewData());
    }

    public function testSubmitAddsNoDefaultProtocolIfEmpty()
    {
        $form = $this->factory->create(static::TESTED_TYPE, null,

otocolIfAlreadyIncluded()
    {
        $form = $this->factory->create(static::TESTED_TYPE, null, [
            'default_protocol' => 'http',
        ]);

        $form->submit('ftp://www.domain.com');

        $this->assertSame(


buted with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\Tests\Fixtures\NotMappedType;
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;

class RepeatedTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = Repeate

YPE,
        ]);
    }

    public function testSetData()
    {
        $this->form->setData('foobar');

        $this->assertSame('foobar', $this->form['first']->getData());
        $this->assertSame('foobar', $this->form['second']->getData());
    }

dType::class;

    protected Form $form;

    protected function setUp(): void
    {
        parent::setUp();

        $this->form = $this->factory->create(static::TESTED_TYPE, null, [
            'type' => TextTypeTest::TESTED_T


/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use Symfony\Component\Form\Extension\Core\Type\UuidType;
use Symfony\Component\Uid\Uuid;

final class UuidTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = UuidType::class;

    public function testPass

()->vars['value']);
    }

    public function testSubmitNullUsesDefaultEmptyData($emptyData = '', $expectedData = null)
    {
        $form = $this->factory->create(static::TESTED_TYPE, null, [
            'empty_data' => $emptyData,
        ]);
        $

UuidToView()
    {
        $uuid = '123e4567-e89b-12d3-a456-426655440000';

        $form = $this->factory->create(static::TESTED_TYPE);
        $form->setData(new Uuid($uuid));

        $this->assertSame($uuid, $form->createView


mfony\Component\Form\FormError;

class WeekTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = WeekType::class;

    public function testSubmitArray()
    {
        $form = $this->factory->create(static::TESTED_TYPE, null, [
            'widget' => 'choice',
            'input' => 'array',
        ]);

        $form->submit([
            'year' => '2019',
            'week' => '1',
        ]);

        $this->assertSame(['year' => 2019, 'week' => 1], $form->getData());
    }

    public funct

([
            'year' => '2019',
            'week' => '1',
        ]);

        $this->assertEquals('2019-W01', $form->getData());
    }

    public function testSubmitStringSingleText()
    {
        $form = $this->factory->create(static::TESTED_TYPE, nu

ion testSubmitString()
    {
        $form = $this->factory->create(static::TESTED_TYPE, null, [
            'years' => [2019],
            'input' => 'string',
            'widget' => 'choice',
        ]);

        $form->submit


ge.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Extension\Core\EventListener\FixUrlProtocolListener;
use Symfony\Component\Form\Form;
use Symf

ew Form(new FormConfigBuilder('name', null, new EventDispatcher()));
        $event = new FormEvent($form, $data);

        $filter = new FixUrlProtocolListener('http');
        $filter->onSubmit($event);

        $this->assertSame('http://'.$data, $event-

ony\Component\Form\FormConfigBuilder;
use Symfony\Component\Form\FormEvent;

class FixUrlProtocolListenerTest extends TestCase
{
    #[DataProvider('provideUrlToFix')]
    public function testFixUrl($data)
    {
        $form = n


he Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;

use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormFactoryBuilder;

class MergeCollectionListenerArrayObjectTest ex

d function getData(array $data)
    {
        return new \ArrayObject($data);
    }

    protected function getBuilder($name = 'name'): FormBuilderInterface
    {
        return new FormBuilder($name, \ArrayObject::class, new EventDispatcher(), (new FormFa

tends MergeCollectionListenerTestCase
{
    protecte


 file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;

use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormFactoryBuilder;

class MergeCollectionListener

    protected function getData(array $data)
    {
        return $data;
    }

    protected function getBuilder($name = 'name'): FormBuilderInterface
    {
        return new FormBuilder($name, null, new EventDispatcher(), (new FormFactoryBuilder())->getF

ArrayTest extends MergeCollectionListenerTestCase
{


<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;

use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormFactoryBuilder;
use Symfony\C

$data);
    }

    protected function getBuilder($name = 'name'): FormBuilderInterface
    {
        return new FormBuilder($name, 'Symfony\Component\Form\Tests\Fixtures\CustomArrayObject', new EventDispatcher(), (new FormFactoryBuilder())->getFormFactory(

omponent\Form\Tests\Fixtures\CustomArrayObject;

class MergeCollectionListenerCustomArrayObjectTest extends MergeCollectionListenerTestCase
{
    protected function getData(array $data)
    {
        return new CustomArrayObject(


buted with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Form\Extension\Core\EventListener\MergeCollectionListener;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormInterface;

abstract class MergeCollectionListenerTestCase extends T

protected function getForm($name = 'name', $propertyPath = null)
    {
        $propertyPath ??= $name;

        return $this->getBuilder($name)->setAttribute('property_path', $propertyPath)->getForm();
    }

    public static function getBooleanMatrix1()

estCase
{
    protected FormInterface $form;

    protected function setUp(): void
    {
        $this->form = $this->getForm('axes');
    }

    abstract protected function getBuilder($name = 'name'): FormBuilderInterface;


t\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Event\PostSetDataEvent;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Form\Extension\Core\DataMapper\DataMapper;
use Symfony\Component\Form\Extension\Core\EventListener\ResizeFormListener;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent

er;

    protected function setUp(): void
    {
        $this->factory = (new FormFactoryBuilder())->getFormFactory();
        $this->builder = $this->getBuilder()
            ->setCompound(true)
            ->setDataMapper(new DataMapper());
    }

    pr

;
use Symfony\Component\Form\FormFactoryBuilder;
use Symfony\Component\Form\FormFactoryInterface;

class ResizeFormListenerTest extends TestCase
{
    private FormFactoryInterface $factory;
    private FormBuilderInterface $build


 This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;

use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Extension\Core\EventListener\TrimListener;
use Symfony\Component\Form\Form;
use Symfony\Component\Form

EventDispatcher()));
        $event = new FormEvent($form, $data);

        $filter = new TrimListener();
        $filter->preSubmit($event);

        $this->assertEquals('Foo!', $event->getData());
    }

    public function testTrimSkipNonStrings()
    {

\FormConfigBuilder;
use Symfony\Component\Form\FormEvent;

class TrimListenerTest extends TestCase
{
    public function testTrim()
    {
        $data = ' Foo! ';
        $form = new Form(new FormConfigBuilder('name', null, new


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTransformer\ArrayToPartsTransformer;

class ArrayToPartsTransformerTest extends TestCase
{
    private ArrayToPartsTransformer $transformer;

    protected fu

nction setUp(): void
    {
        $this->transformer = new ArrayToPartsTransformer([
            'first' => ['a', 'b', 'c'],
            'second' => ['d', 'e', 'f'],
        ]);
    }

    public function testTransform()
    {


 This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\InvalidArgumentException;
use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer;

abstract class BaseDateTimeTransfor

exist');
        $this->createDateTimeTransformer('this_timezone_does_not_exist');
    }

    public function testConstructFailsIfOutputTimezoneIsInvalid()
    {
        $this->expectException(InvalidArgumentException::class);
        $this->expectExceptio

merTestCase extends TestCase
{
    public function testConstructFailsIfInputTimezoneIsInvalid()
    {
        $this->expectException(InvalidArgumentException::class);
        $this->expectExceptionMessage('this_timezone_does_not_


ge.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\InvalidArgumentException;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTransformer\BooleanToStringTransformer;

cla

ToStringTransformer(self::TRUE_VALUE);
    }

    public function testTransform()
    {
        $this->assertEquals(self::TRUE_VALUE, $this->transformer->transform(true));
        $this->assertNull($this->transformer->transform(false));
    }

    // https

ss BooleanToStringTransformerTest extends TestCase
{
    private const TRUE_VALUE = '1';

    protected BooleanToStringTransformer $transformer;

    protected function setUp(): void
    {
        $this->transformer = new Boolean


ge.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTrans

Up(): void
    {
        $list = new ArrayChoiceList(['', false, 'X', true]);
        $listWithNull = new ArrayChoiceList(['', false, 'X', null]);

        $this->transformer = new ChoiceToValueTransformer($list);
        $this->transformerWithNull = new C

former\ChoiceToValueTransformer;

class ChoiceToValueTransformerTest extends TestCase
{
    protected ChoiceToValueTransformer $transformer;
    protected ChoiceToValueTransformer $transformerWithNull;

    protected function set


ge.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToValuesTransformer;

class Choic

rayChoiceList(['', false, 'X']);
        $listWithNull = new ArrayChoiceList(['', false, 'X', null]);

        $this->transformer = new ChoicesToValuesTransformer($list);
        $this->transformerWithNull = new ChoicesToValuesTransformer($listWithNull);

esToValuesTransformerTest extends TestCase
{
    protected ChoicesToValuesTransformer $transformer;
    protected ChoicesToValuesTransformer $transformerWithNull;

    protected function setUp(): void
    {
        $list = new Ar


hp

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Extension\Core\DataTransformer\DataTransformerChain;
use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer;

class DataTransformerChainTe

);

        $this->assertEquals('baz', $chain->transform('foo'));
    }

    public function testReverseTransform()
    {
        $chain = new DataTransformerChain([
            new FixedDataTransformer(['baz' => 'bar']),
            new FixedDataTransform

st extends TestCase
{
    public function testTransform()
    {
        $chain = new DataTransformerChain([
            new FixedDataTransformer(['foo' => 'bar']),
            new FixedDataTransformer(['bar' => 'baz']),
        ]


buted with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateIntervalToArrayTransformer;

/**
 * @author Steffen Roßkamp <steffen.rosskamp@gimmickmedia.de>
 */
class DateIntervalToArrayTransformerTest extends DateIntervalTestCase
{
    public function testTransform()
    {

 'hours' => '4',
            'minutes' => '5',
            'seconds' => '6',
            'invert' => false,
        ];
        $this->assertSame($output, $transformer->transform($input));
    }

    public function testTransformEmpty()
    {
        $trans

       $transformer = new DateIntervalToArrayTransformer();
        $input = new \DateInterval('P1Y2M3DT4H5M6S');
        $output = [
            'years' => '1',
            'months' => '2',
            'days' => '3',


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateIntervalToStringTransformer;

/**
 * @author Steffen Roßkamp <ste

ffen.rosskamp@gimmickmedia.de>
 */
class DateIntervalToStringTransformerTest extends DateIntervalTestCase
{
    public static function dataProviderISO(): array
    {
        return [
            ['P%YY%MM%DDT%HH%IM%SS', 'P00Y00M0


ge.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeImmutableToDateTimeTransformer;

class D

leToDateTimeTransformer();

        $actualOutput = $transformer->transform($input);

        $this->assertEquals($expectedOutput, $actualOutput);
        $this->assertEquals($expectedOutput->getTimezone(), $actualOutput->getTimezone());
    }

    public

ateTimeImmutableToDateTimeTransformerTest extends TestCase
{
    #[DataProvider('provider')]
    public function testTransform(\DateTime $expectedOutput, \DateTimeImmutable $input)
    {
        $transformer = new DateTimeImmutab


nsion\Core\DataTransformer\BaseDateTimeTransformer;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer;

class DateTimeToArrayTransformerTest extends BaseDateTimeTransformerTestCase
{
    public function testTransform()
    {
        $transformer = new DateTimeToArrayTransformer('UTC', 'UTC');

        $input = new \DateTime('2010-02-03 04:05:06 UTC');

        $output = [
            'year' => '2010',
            'month' => '2',
            'day' => '3',
            'hour'

DateTimeToArrayTransformer();

        $output = [
            'year' => '',
            'month' => '',
            'day' => '',
            'hour' => '',
            'minute' => '',
            'second' => '',
        ];

        $this->assertSame($output

 => '4',
            'minute' => '5',
            'second' => '6',
        ];

        $this->assertSame($output, $transformer->transform($input));
    }

    public function testTransformEmpty()
    {
        $transformer = new


buted with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToHtml5LocalDateTimeTransformer;
use Symfony\Component\Form\Tests\Extension\Core\DataTransformer\Traits\DateTimeEqualsTrait;

class DateTimeTo

Html5LocalDateTimeTransformerTest extends BaseDateTimeTransformerTestCase
{
    use DateTimeEqualsTrait;

    public static function transformProvider(): array
    {
        return [
            ['UTC', 'UTC', '2010-02-03 04:05:0


aTransformer\Traits\DateTimeEqualsTrait;
use Symfony\Component\Intl\Util\IntlTestHelper;

class DateTimeToLocalizedStringTransformerTest extends BaseDateTimeTransformerTestCase
{
    use DateTimeEqualsTrait;

    protected \DateTime $dateTime;
    protected \DateTime $dateTimeWithoutSeconds;
    private string $defaultLocale;

    private $initialTestCaseUseException;
    private $initialTestCaseErrorLevel;

    protected function setUp(): void
    {
        // Normalize intl. configuration settings.

equireFullIntl($this, '57.1');

        $this->defaultLocale = \Locale::getDefault();
        \Locale::setDefault('de_AT');

        $this->dateTime = new \DateTime('2010-02-03 04:05:06 UTC');
        $this->dateTimeWithoutSeconds = new \DateTime('2010-02-

  if (\extension_loaded('intl')) {
            $this->initialTestCaseUseException = ini_set('intl.use_exceptions', 0);
        }

        // Since we test against "de_AT", we need the full implementation
        IntlTestHelper::r


buted with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToRfc3339Transformer;
use Symfony\Component\Form\Tests\Extension\Core\DataTransformer\Traits\DateTimeEqualsTrait;

class DateTimeToRfc3339Tran

teTime = new \DateTime('2010-02-03 04:05:06 UTC');
        $this->dateTimeWithoutSeconds = new \DateTime('2010-02-03 04:05:00 UTC');
    }

    public static function allProvider(): array
    {
        return [
            ['UTC', 'UTC', '2010-02-03 04:05:

sformerTest extends BaseDateTimeTransformerTestCase
{
    use DateTimeEqualsTrait;

    protected \DateTime $dateTime;
    protected \DateTime $dateTimeWithoutSeconds;

    protected function setUp(): void
    {
        $this->da


buted with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;

class DateTimeToStringTransformerTest extends BaseDateTimeTransformerTestCase
{
    public static function dataProvider(


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;

class DateTimeToTimestampTransformerTest extends BaseDateTimeT

'U');

        $this->assertEquals($output, $transformer->transform($input));
    }

    public function testTransformEmpty()
    {
        $transformer = new DateTimeToTimestampTransformer();

        $this->assertNull($transformer->transform(null));

ransformerTestCase
{
    public function testTransform()
    {
        $transformer = new DateTimeToTimestampTransformer('UTC', 'UTC');

        $input = new \DateTime('2010-02-03 04:05:06 UTC');
        $output = $input->format(


 part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeZoneToStringTransformer;

class DateTimeZoneToStringTransform

erseTransform(null));

        $this->assertSame('Europe/Amsterdam', $transformer->transform(new \DateTimeZone('Europe/Amsterdam')));
        $this->assertEquals(new \DateTimeZone('Europe/Amsterdam'), $transformer->reverseTransform('Europe/Amsterdam'));

erTest extends TestCase
{
    public function testSingle()
    {
        $transformer = new DateTimeZoneToStringTransformer();

        $this->assertNull($transformer->transform(null));
        $this->assertNull($transformer->rev


t\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTransformer\IntegerToLocalizedStringTransformer;
use Symfony\Component\Intl\Util\IntlTestHelper;

class IntegerToLocalizedStringTransformerTest extends TestCase
{
    private string $defaultLocale;

    protected function setUp(): void
    {
        $this->defaultLocale = \Locale::getDefault();
        \Locale::setDefault('en');
    }

    protected function tearDown(): void
    {
        \Locale::setDefault($this-

G],
            [1234.4, '1235', \NumberFormatter::ROUND_CEILING],
            [-1234.5, '-1234', \NumberFormatter::ROUND_CEILING],
            [-1234.4, '-1234', \NumberFormatter::ROUND_CEILING],
            // towards negative infinity (1.6 -> 1, -1.6 ->

>defaultLocale);
    }

    public static function transformWithRoundingProvider()
    {
        return [
            // towards positive infinity (1.6 -> 2, -1.6 -> -1)
            [1234.5, '1235', \NumberFormatter::ROUND_CEILIN


ge.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTransformer\IntlTimeZoneToStringTransformer;

#[Requ

transform(null));
        $this->assertNull($transformer->reverseTransform(null));

        $this->assertSame('Europe/Amsterdam', $transformer->transform(\IntlTimeZone::createTimeZone('Europe/Amsterdam')));
        $this->assertEquals(\IntlTimeZone::create

iresPhpExtension('intl')]
class IntlTimeZoneToStringTransformerTest extends TestCase
{
    public function testSingle()
    {
        $transformer = new IntlTimeZoneToStringTransformer();

        $this->assertNull($transformer->


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedStringTransformer;
use Symfony\Component\Intl\Util\IntlTestHelper;

class MoneyToLocalizedStringTransformerTest extends TestCase
{

();
    }

    protected function tearDown(): void
    {
        setlocale(\LC_ALL, $this->previousLocale);
        \Locale::setDefault($this->defaultLocale);
    }

    public function testTransform()
    {
        // Since we test against "de_AT", we nee

    private string|false $previousLocale;
    private string $defaultLocale;

    protected function setUp(): void
    {
        $this->previousLocale = setlocale(\LC_ALL, '0');
        $this->defaultLocale = \Locale::getDefault


alTestCaseUseException;

    protected function setUp(): void
    {
        // Normalize intl. configuration settings.
        if (\extension_loaded('intl')) {
            $this->initialTestCaseUseException = ini_set('intl.use_exceptions', 0);
        }

        $this->defaultLocale = \Locale::getDefault();
        \Locale::setDefault('en');
    }

    protected function tearDown(): void
    {
        \Locale::setDefault($this->defaultLocale);

        if (\extension_loaded('intl')) {
            ini_set('i

ntl.use_exceptions', $this->initialTestCaseUseException);
        }
    }

    public static function provideTransformations()
    {
        return [
            [null, '', 'de_AT'],
            ['', '', 'de_AT'],
            [1,


tialTestCaseUseException;

    protected function setUp(): void
    {
        // Normalize intl. configuration settings.
        if (\extension_loaded('intl')) {
            $this->initialTestCaseUseException = ini_set('intl.use_exceptions', 0);
        }

        $this->defaultLocale = \Locale::getDefault();
        \Locale::setDefault('en');
    }

    protected function tearDown(): void
    {
        \Locale::setDefault($this->defaultLocale);

        if (\extension_loaded('intl')) {
            ini_set(

       $this->assertEquals('10', $transformer->transform(0.1));
        $this->assertEquals('15', $transformer->transform(0.15));
        $this->assertEquals('12', $transformer->transform(0.1234));
        $this->assertEquals('200', $transformer->transform

'intl.use_exceptions', $this->initialTestCaseUseException);
        }
    }

    public function testTransform()
    {
        $transformer = new PercentToLocalizedStringTransformer(null, null, \NumberFormatter::ROUND_HALFUP);


ge.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTransformer\StringToFloatTransformer;

class StringToFloatTr

23', 1.23],
        ];
    }

    #[DataProvider('provideTransformations')]
    public function testTransform($from, $to)
    {
        $transformer = new StringToFloatTransformer();

        $this->assertSame($to, $transformer->transform($from));
    }

ansformerTest extends TestCase
{
    public static function provideTransformations(): array
    {
        return [
            [null, null],
            ['1', 1.],
            ['1.', 1.],
            ['1.0', 1.],
            ['1.


ge.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTransformer\UlidToStringTransformer;
use Symfony\Component\U

  }

    #[DataProvider('provideValidUlid')]
    public function testTransform($output, $input)
    {
        $transformer = new UlidToStringTransformer();

        $input = new Ulid($input);

        $this->assertEquals($output, $transformer->transform($i

id\Ulid;

class UlidToStringTransformerTest extends TestCase
{
    public static function provideValidUlid()
    {
        return [
            ['01D85PP1982GF6KTVFHQ7W78FB', new Ulid('01d85pp1982gf6ktvfhq7w78fb')],
        ];


ge.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataTransformer\UuidToStringTransformer;
use Symfony\Component\Uid\Uuid;
use Symfony\Component\Uid\UuidV1;

cla

transform(new UuidV1('123e4567-e89b-12d3-a456-426655440000')));
    }

    public function testTransformEmpty()
    {
        $transformer = new UuidToStringTransformer();

        $this->assertNull($transformer->transform(null));
    }

    public functio

ss UuidToStringTransformerTest extends TestCase
{
    public function testTransform()
    {
        $transformer = new UuidToStringTransformer();

        $this->assertEquals('123e4567-e89b-12d3-a456-426655440000', $transformer->


 part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Form\Extension\Core\Type\TextType;

class TextTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = TextType::class;

    public function testSubmitNull($ex

c::TESTED_TYPE, 'name', array_merge($this->getTestOptions(), [
            'empty_data' => '',
        ]));

        $form->submit(null);
        $this->assertSame('', $form->getData());
        $this->assertSame('', $form->getNormData());
        $this->a

pected = null, $norm = null, $view = null)
    {
        parent::testSubmitNull($expected, $norm, '');
    }

    public function testSubmitNullReturnsNullWithEmptyDataAsString()
    {
        $form = $this->factory->create(stati


buted with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Exception\LogicException;
use Symfony\Component\Form\Extension\Core\Type\TimezoneType;
use Symfony\Component\Intl\Util\IntlTestHelper;

class TimezoneTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = TimezoneType::class;

    public function testTimezonesAreSelec

a'), $choices);
        $this->assertContainsEquals(new ChoiceView('America/New_York', 'America/New_York', 'America / New York'), $choices);
    }

    public function testSubmitNull($expected = null, $norm = null, $view = null)
    {
        parent::testS

table()
    {
        $choices = $this->factory->create(static::TESTED_TYPE)
            ->createView()->vars['choices'];

        $this->assertContainsEquals(new ChoiceView('Africa/Kinshasa', 'Africa/Kinshasa', 'Africa / Kinshas


/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use Symfony\Component\Form\Extension\Core\Type\UlidType;
use Symfony\Component\Uid\Ulid;

final class UlidTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = UlidType::class;

    public function testPass

value']);
    }

    public function testSubmitNullUsesDefaultEmptyData($emptyData = '', $expectedData = null)
    {
        $form = $this->factory->create(static::TESTED_TYPE, null, [
            'empty_data' => $emptyData,
        ]);
        $form->subm

UlidToView()
    {
        $ulid = '01D85PP1982GF6KTVFHQ7W78FB';

        $form = $this->factory->create(static::TESTED_TYPE);
        $form->setData(new Ulid($ulid));

        $this->assertSame($ulid, $form->createView()->vars['


ge.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use Symfony\Component\Form\Extension\Core\Type\BirthdayType;
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;

/**
 * @author Stepan Anchugov <kixxx1@gmail.com>
 */
class BirthdayTypeTest extends DateTypeTest
{
    public const TESTED_TYPE

 value',
            'widget' => 'choice',
        ]);
    }

    public function testWidgetSingleTextHasDefaultAttrMinMax()
    {
        $form = $this->factory->create(static::TESTED_TYPE, null, [
            'widget' => 'single_text',
        ]);

= BirthdayType::class;

    public function testSetInvalidYearsOption()
    {
        $this->expectException(InvalidOptionsException::class);
        $this->factory->create(static::TESTED_TYPE, null, [
            'years' => 'bad


buted with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;

class CheckboxTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = CheckboxType::class;

    public function testDataIsFalseByDefault()
    {
        $form = $this->factory-

{
        $view = $this->factory->create(static::TESTED_TYPE, null, ['value' => 'foobar'])
            ->createView();

        $this->assertEquals('foobar', $view->vars['value']);
    }

    public function testCheckedIfDataTrue()
    {
        $view = $t

>create(static::TESTED_TYPE);

        $this->assertFalse($form->getData());
        $this->assertFalse($form->getNormData());
        $this->assertNull($form->getViewData());
    }

    public function testPassValueToView()


'expanded' => true,
            'choices' => $this->choices,
        ]);

        $this->assertCount(\count($this->choices), $form, 'Each choice should become a new field');
    }

    public function testChoiceListWithScalarValues()
    {
        $view = $this->factory->create(static::TESTED_TYPE, null, [
            'choices' => $this->scalarChoices,
        ])->createView();

        $this->assertSame('1', $view->vars['choices'][0]->value);
        $this->assertSame('0', $view->vars['choices'][1]->value)

ssertFalse($view->vars['is_selected']($view->vars['choices'][1], $view->vars['value']), 'False value should not be pre selected');
        $this->assertFalse($view->vars['is_selected']($view->vars['choices'][2], $view->vars['value']), 'Empty value should n

;
        $this->assertSame('', $view->vars['choices'][2]->value);
        $this->assertFalse($view->vars['is_selected']($view->vars['choices'][0], $view->vars['value']), 'True value should not be pre selected');
        $this->a


ge.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Extension\Core\CoreExtension;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Test\TypeTestCase;
use Symfony\Contracts\Translation\TranslatorInt

'Jon' => 'd',
        'Roman' => 'e',
    ];

    protected function setUp(): void
    {
        $this->dispatcher = new EventDispatcher();

        parent::setUp();
    }

    protected function getExtensions(): array
    {
        $translator = $this->cr

erface;

class ChoiceTypeTranslationTest extends TypeTestCase
{
    public const TESTED_TYPE = ChoiceType::class;

    private array $choices = [
        'Bernhard' => 'a',
        'Fabien' => 'b',
        'Kris' => 'c',


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Extension\Core\Type\CountryType;
use Symfony\Component\Intl\Util\IntlTestHelper;

class CountryTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = CountryType::cla

:TESTED_TYPE)
            ->createView()->vars['choices'];

        // Don't check objects for identity
        $this->assertContainsEquals(new ChoiceView('DE', 'DE', 'Germany'), $choices);
        $this->assertContainsEquals(new ChoiceView('GB', 'GB', 'Un

ss;

    protected function setUp(): void
    {
        IntlTestHelper::requireIntl($this);

        parent::setUp();
    }

    public function testCountriesAreSelectable()
    {
        $choices = $this->factory->create(static:


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Extension\Core\Type\CurrencyType;
use Symfony\Component\Intl\Util\IntlTestHelper;
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;

class CurrencyTypeTest

enciesAreSelectable()
    {
        $choices = $this->factory->create(static::TESTED_TYPE)
            ->createView()->vars['choices'];

        $this->assertContainsEquals(new ChoiceView('EUR', 'EUR', 'Euro'), $choices);
        $this->assertContainsEqual

 extends BaseTypeTestCase
{
    public const TESTED_TYPE = CurrencyType::class;

    protected function setUp(): void
    {
        IntlTestHelper::requireIntl($this);

        parent::setUp();
    }

    public function testCurr


ception::class);
        $this->factory->create(static::TESTED_TYPE, null, [
            'input' => 'fake_input',
            'widget' => 'choice',
        ]);
    }

    public function testSubmitFromSingleTextDateTimeWithDefaultFormat()
    {
        $form = $this->factory->create(static::TESTED_TYPE, null, [
            'model_timezone' => 'UTC',
            'view_timezone' => 'UTC',
            'widget' => 'single_text',
            'input' => 'datetime',
        ]);

        $form->submit('2010-06-02')

 {
        $form = $this->factory->create(static::TESTED_TYPE, null, [
            'model_timezone' => 'UTC',
            'view_timezone' => 'UTC',
            'widget' => 'single_text',
            'input' => 'datetime',
            'format' => 'yyyy',

;

        $this->assertEquals(new \DateTime('2010-06-02 UTC'), $form->getData());
        $this->assertEquals('2010-06-02', $form->getViewData());
    }

    public function testSubmitFromSingleTextDateTimeWithCustomFormat()


ge.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Forms;
use Symfony\Component\Form\Tests\Fixtures\ChoiceTypeExtension;
use Symfony\Component\Form\Tests\Fixtures\LazyChoiceTypeExtension;

class ExtendedChoice

r()
            ->addTypeExtension(new ChoiceTypeExtension())
            ->getFormFactory()
        ;

        $choices = $factory->create($type, null, ['choice_loader' => null])->createView()->vars['choices'];

        $this->assertCount(2, $choices);

TypeTest extends TestCase
{
    #[DataProvider('provideTestedTypes')]
    public function testChoicesAreOverridden($type)
    {
        ChoiceTypeExtension::$extendedType = $type;
        $factory = Forms::createFormFactoryBuilde


;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\Forms;
use Symfony\Component\Form\Tests\Fixtures\Author;
use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer;
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
use Symfony\Component\PropertyAccess\PropertyPath;
use Symfony\Component\Validator\Validation;

class FormTest_AuthorWithoutRefSetter
{
    protected $reference;

    pr

t having
    // to provide a setReference() method
    public function getReference()
    {
        return $this->reference;
    }

    // The returned object is a copy, so setReferenceCopy() must be used
    // to update it
    public function getReferenc

otected $referenceCopy;

    public function __construct($reference)
    {
        $this->reference = $reference;
        $this->referenceCopy = $reference;
    }

    // The returned object should be modified by reference withou


buted with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Exception\LogicException;
use Symfony\Component\Form\Extension\Core\Type\LanguageType;
use Symfony\Component\Intl\Util\IntlTestHelper;

class LanguageTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = LanguageType::class;

    protected function setUp(): void

['choices'];

        $this->assertContainsEquals(new ChoiceView('en', 'en', 'English'), $choices);
        $this->assertContainsEquals(new ChoiceView('fr', 'fr', 'French'), $choices);
        $this->assertContainsEquals(new ChoiceView('my', 'my', 'Burmese

{
        IntlTestHelper::requireIntl($this);

        parent::setUp();
    }

    public function testCountriesAreSelectable()
    {
        $choices = $this->factory->create(static::TESTED_TYPE)
            ->createView()->vars


buted with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Intl\Util\IntlTestHelper;

class MoneyTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = MoneyType::class;

    private string $defaultLocale;

    protected function setUp(): void
    {
        // we test against different locales, so we need the full

is->defaultLocale)) {
            \Locale::setDefault($this->defaultLocale);
        }
    }

    public function testPassMoneyPatternToView()
    {
        \Locale::setDefault('de_DE');

        $view = $this->factory->create(static::TESTED_TYPE)

        // implementation
        IntlTestHelper::requireFullIntl($this);

        parent::setUp();

        $this->defaultLocale = \Locale::getDefault();
    }

    protected function tearDown(): void
    {
        if (isset($th


 part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use Symfony\Component\Form\Extension\Core\Type\PasswordType;

class PasswordTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = PasswordType::class;

    public function testEmptyIfNotSubmitted()
    {
        $form = $this

y->create(static::TESTED_TYPE);
        $form->submit('pAs5w0rd');

        $this->assertSame('', $form->createView()->vars['value']);
    }

    public function testNotEmptyIfSubmittedAndNotAlwaysEmpty()
    {
        $form = $this->factory->create(static

->factory->create(static::TESTED_TYPE);
        $form->setData('pAs5w0rd');

        $this->assertSame('', $form->createView()->vars['value']);
    }

    public function testEmptyIfSubmitted()
    {
        $form = $this->factor


 part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\SubmitButton;

/**
 * @author Bernhard Schussek <bschussek@gmail.com>
 */
class SubmitTypeTest extends ButtonTypeTest
{
    public const TESTED_TYPE = S

)
    {
        $button = $this->factory->create(static::TESTED_TYPE);

        $this->assertFalse($button->isClicked());
    }

    public function testNotClickedIfSubmittedWithNull()
    {
        $button = $this->factory->create(static::TESTED_TYPE);

ubmitType::class;

    public function testCreateSubmitButtonInstances()
    {
        $this->assertInstanceOf(SubmitButton::class, $this->factory->create(static::TESTED_TYPE));
    }

    public function testNotClickedByDefault(


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;

class TextareaTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = TextareaType::class;

    public function testSubmitNull($expected = null, $norm = null, $view = null)
    {
        parent:

ssertSame("Line 1\nLine 2\nLine 3", $form->getData());
    }

    public function testSubmitNormalizeCr()
    {
        $form = $this->factory->create(static::TESTED_TYPE);
        $form->submit("Line 1\rLine 2\rLine 3");

        $this->assertSame("Line 1

:testSubmitNull($expected, $norm, '');
    }

    public function testSubmitNormalizeCrlf()
    {
        $form = $this->factory->create(static::TESTED_TYPE);
        $form->submit("Line 1\r\nLine 2\r\nLine 3");

        $this->a


author Bernhard Schussek <bschussek@gmail.com>
 */
abstract class BaseTypeTestCase extends TypeTestCase
{
    public const TESTED_TYPE = '';

    protected function setUp(): void
    {
        $this->dispatcher = new EventDispatcher();

        parent::setUp();
    }

    public function testPassDisabledAsOption()
    {
        $form = $this->factory->create($this->getTestedType(), null, array_merge($this->getTestOptions(), ['disabled' => true]));

        $this->assertTrue($form->isDisabled());
    }

rs['id']);
        $this->assertEquals('name', $view->vars['name']);
        $this->assertEquals('name', $view->vars['full_name']);
    }

    public function testPassIdAndNameToViewWithParent()
    {
        $view = $this->factory->createNamedBuilder('par

public function testPassIdAndNameToView()
    {
        $view = $this->factory->createNamed('name', $this->getTestedType(), null, $this->getTestOptions())
            ->createView();

        $this->assertEquals('name', $view->va


?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use PHPUnit\Framework\Attributes\Group;
use Symfony\Component\Form\Test\FormPerformanceTestCase;

/**
 * @author Bernhard Schussek <bschussek@gmail.com>
 */
class ChoiceTypePerformanceTest extends FormPerformanceTe

       $this->setMaxRunningTime(1);
        $choices = range(1, 300);

        for ($i = 0; $i < 100; ++$i) {
            $this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', random_int(1, 400), [
                'choices' => $ch

stCase
{
    /**
     * This test case is realistic in collection forms where each
     * row contains the same choice field.
     */
    #[Group('benchmark')]
    public function testSameChoiceFieldCreatedMultipleTimes()
    {


;
use Symfony\Component\Form\Tests\Fixtures\CollectionWithRecursiveSetDataType;

class CollectionTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = CollectionType::class;

    public function testContainsNoChildByDefault()
    {
        $form = $this->factory->create(static::TESTED_TYPE, null, [
            'entry_type' => TextTypeTest::TESTED_TYPE,
        ]);

        $this->assertCount(0, $form);
    }

    public function testSetDataAdjustsSize()
    {
        $form = $this->factory->cre

om', 'foo@bar.com']);

        $this->assertInstanceOf(Form::class, $form[0]);
        $this->assertInstanceOf(Form::class, $form[1]);
        $this->assertCount(2, $form);
        $this->assertEquals('foo@foo.com', $form[0]->getData());
        $this->ass

ate(static::TESTED_TYPE, null, [
            'entry_type' => TextTypeTest::TESTED_TYPE,
            'entry_options' => [
                'attr' => ['maxlength' => 20],
            ],
        ]);
        $form->setData(['foo@foo.c


eList\View\ChoiceView;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Tests\Extension\Core\Type\BaseTypeTestCase;
use Symfony\Component\Form\Tests\Fixtures\Answer;
use Symfony\Component\Form\Tests\Fixtures\Number;
use Symfony\Component\Form\Tests\Fixtures\Suit;
use Symfony\Component\Form\Tests\Fixtures\TranslatableTextAlign;
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
use Symfony\Component\OptionsResolver\Exception\MissingOptionsException;
us

ClassOptionIsRequired()
    {
        $this->expectException(MissingOptionsException::class);
        $this->factory->createNamed('name', $this->getTestedType());
    }

    public function testInvalidClassOption()
    {
        $this->expectException(Inva

e Symfony\Component\Translation\IdentityTranslator;
use Symfony\Contracts\Translation\TranslatableInterface;

class EnumTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = EnumType::class;

    public function test


mfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler;
use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface;
use Symfony\Component\Form\NativeRequestHandler;
use Symfony\Component\Form\RequestHandlerInterface;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Translation\IdentityTranslator;

class FileTypeTest extends Bas

er), [new CoreExtension(null, null, new IdentityTranslator())]);
    }

    // https://github.com/symfony/symfony/pull/5028
    public function testSetData()
    {
        $form = $this->factory->createBuilder(static::TESTED_TYPE)->getForm();
        $data

eTypeTestCase
{
    public const TESTED_TYPE = FileType::class;

    protected function getExtensions(?ViolationMapperInterface $violationMapper = null): array
    {
        return array_merge(parent::getExtensions($violationMapp


ge.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Extension\Core\Type\LocaleType;
use Symfony\Component\Intl\Util\IntlTestHelper;

class LocaleTypeTest extends BaseTypeTestCase

     $choices = $this->factory->create(static::TESTED_TYPE)
            ->createView()->vars['choices'];

        $this->assertContainsEquals(new ChoiceView('en', 'en', 'English'), $choices);
        $this->assertContainsEquals(new ChoiceView('en_GB', 'en_

{
    public const TESTED_TYPE = LocaleType::class;

    protected function setUp(): void
    {
        IntlTestHelper::requireIntl($this);

        parent::setUp();
    }

    public function testLocalesAreSelectable()
    {


            'widget' => 'choice',
            'input' => 'date_point',
        ]);

        $input = [
            'hour' => '3',
            'minute' => '4',
        ];

        $form->submit($input);

        $this->assertInstanceOf(DatePoint::class, $form->getData());
        $datePoint = DatePoint::createFromMutable(new \DateTime('1970-01-01 03:04:00 UTC'));
        $this->assertEquals($datePoint, $form->getData());
        $this->assertEquals($input, $form->getViewData());
    }

    public function t

        'widget' => 'choice',
        ]);

        $input = [
            'hour' => '3',
            'minute' => '4',
        ];

        $form->submit($input);

        $dateTime = new \DateTimeImmutable('1970-01-01 03:04:00 UTC');

        $this->assertI

estSubmitDateTimeImmutable()
    {
        $form = $this->factory->create(static::TESTED_TYPE, null, [
            'model_timezone' => 'UTC',
            'view_timezone' => 'UTC',
            'input' => 'datetime_immutable',


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use Symfony\Component\Form\Button;
use Symfony\Component\Form\Exception\BadMethodCallException;
use Symfony\Component\Form\Exception\LogicException;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\FormType;

/**
 * @author Bernhard Schussek <bschussek@gmail

ate(static::TESTED_TYPE));
    }

    /**
     * @param string $emptyData
     * @param null   $expectedData
     */
    public function testSubmitNullUsesDefaultEmptyData($emptyData = 'empty', $expectedData = null)
    {
        $this->expectException(Bad

.com>
 */
class ButtonTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = ButtonType::class;

    public function testCreateButtonInstances()
    {
        $this->assertInstanceOf(Button::class, $this->factory->cre


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Intl\Util\IntlTestHelper;

class IntegerTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = IntegerType::class;

    private string $previousLocale;

    protected

s->defaultLocale)) {
            \Locale::setDefault($this->defaultLocale);
        }
    }

    #[RequiresPhpExtension('intl')]
    public function testArabicLocale()
    {
        \Locale::setDefault('ar');

        $form = $this->factory->create(static:

 function setUp(): void
    {
        IntlTestHelper::requireIntl($this);
        $this->previousLocale = \Locale::getDefault();
        parent::setUp();
    }

    protected function tearDown(): void
    {
        if (isset($thi


buted with this source code.
 */

namespace Symfony\Component\Form\Tests\Extension\Core\Type;

use Symfony\Component\Form\Exception\LogicException;
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Intl\Util\IntlTestHelper;

class NumberTypeTest extends BaseTypeTestCase
{
    public const TESTED_TYPE = NumberType::class;

    private string $defaultLocale;

    protected function setUp(): void
    {
        pa

   }

    protected function tearDown(): void
    {
        if (isset($this->defaultLocale)) {
            \Locale::setDefault($this->defaultLocale);
        }
    }

    public function testDefaultFormatting()
    {
        $form = $this->factory->create(

rent::setUp();

        // we test against "de_DE", so we need the full implementation
        IntlTestHelper::requireFullIntl($this);

        $this->defaultLocale = \Locale::getDefault();
        \Locale::setDefault('de_DE');


 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\ChoiceList;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;

/**
 * @author Bernhard Schussek <bschussek@gmail.com>
 */
abstract class AbstractChoiceListTestCase extends TestCase
{
    protected ChoiceListInterface $list;
    protected array $choices;
    protected array $values;
    protecte

ue2;
    protected string $value3;
    protected string $value4;
    protected string $key1;
    protected string $key2;
    protected string $key3;
    protected string $key4;

    protected function setUp(): void
    {
        $this->list = $this->create

d array $structuredValues;
    protected array $keys;
    protected mixed $choice1;
    protected mixed $choice2;
    protected mixed $choice3;
    protected mixed $choice4;
    protected string $value1;
    protected string $val


n Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Fixtures;

class EnumFormTypeGuesserCase
{
    public string $string;
    public UndefinedEnum $undefinedEnum;
    public EnumFormTypeGuesserCaseEnum $enum;
    public ?EnumFormTypeGuesserCaseEnum $nullableEnum;
    public BackedEnumFormTypeGuesserCaseEnum $backedEnum;
    public ?BackedEnumFormTypeGuess

ypeGuesserCaseEnum|BackedEnumFormTypeGuesserCaseEnum $enumUnion;
    public EnumFormTypeGuesserCaseEnum&BackedEnumFormTypeGuesserCaseEnum $enumIntersection;
}

enum EnumFormTypeGuesserCaseEnum
{
    case Foo;
    case Bar;
}

enum BackedEnumFormTypeGuesser

erCaseEnum $nullableBackedEnum;
    public EnumFormT


/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Fixtures;

use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;

class FixedDataTransformer implements DataTransformerInterface
{
    private array $mapping;

    public fun

ow new TransformationFailedException(\sprintf('No mapping for value "%s"', $value));
        }

        return $this->mapping[$value];
    }

    public function reverseTransform($value): mixed
    {
        $result = array_search($value, $this->mapping, t

ction __construct(array $mapping)
    {
        $this->mapping = $mapping;
    }

    public function transform($value): mixed
    {
        $value ??= '';
        if (!\array_key_exists($value, $this->mapping)) {
            thr


 part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Fixtures;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;

class FixedFilterListener implements EventSubscriberInterface
{
    private $mapping;

    public function

Event $event)
    {
        $data = $event->getData();

        if (isset($this->mapping['preSubmit'][$data])) {
            $event->setData($this->mapping['preSubmit'][$data]);
        }
    }

    public function onSubmit(FormEvent $event)
    {

__construct(array $mapping)
    {
        $this->mapping = array_merge([
            'preSubmit' => [],
            'onSubmit' => [],
            'preSetData' => [],
        ], $mapping);
    }

    public function preSubmit(Form


/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Fixtures;

use Symfony\Contracts\Translation\TranslatorInterface;

class FixedTranslator implements TranslatorInterface
{
    private array $translations;

    public function __construct(array $translations)
    {
        $this->translatio

ions;
    }

    public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
    {
        return $this->translations[$id] ?? $id;
    }

    public function getLocale(): string
    {
        return 'en


 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Fixtures;

use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;

class FooTypeBarExtension extends AbstractTypeExtension
{
    public function buildForm(FormBuilderInterface $builder, array $options)

       $builder->setAttribute('bar', 'x');
    }

    public function getAllowedOptionValues(): array
    {
        return [
            'a_or_b' => ['c'],
        ];
    }

    public static function getExtendedTypes(): iterable
    {
        return [FooT


he Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Fixtures;

use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\ChoiceList\ChoiceList;
use Symfony\Component\OptionsResolver\OptionsResolver;

class LazyChoiceTypeExtension extends AbstractTypeExtension
{
    public static $extendedType;

    pub

ver): void
    {
        $resolver->setDefault('choice_loader', ChoiceList::lazy($this, fn () => [
            'Lazy A' => 'lazy_a',
            'Lazy B' => 'lazy_b',
        ]));
    }

    public static function getExtendedTypes(): iterable
    {

lic function configureOptions(OptionsResolver $resol


he Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Fixtures;

use Symfony\Component\Form\FormTypeGuesserInterface;
use Symfony\Component\Form\Guess\TypeGuess;
use Symfony\Component\Form\Guess\ValueGuess;

class NullFormTypeGuesser implements FormTypeGuesserInterface
{
    public function guessType($class, $property): ?T

c function guessRequired($class, $property): ?ValueGuess
    {
        return null;
    }

    public function guessMaxLength($class, $property): ?ValueGuess
    {
        return null;
    }

    public function guessPattern($class, $property): ?ValueGuess

ypeGuess
    {
        return null;
    }

    publi


ackage.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Fixtures;

class Organization
{
    public $authors = [];

    public function __construct(array $authors = [])
    {
        $this->authors = $authors;
    }

    public function getAuthors(): array
    {
        return $this->authors;
    }

    public function addAuthor(Author $

or;

        return $this;
    }

    public function removeAuthor(Author $author): self
    {
        if (false !== $key = array_search($author, $this->authors, true)) {
            array_splice($this->authors, $key, 1);
        }

        return $this;

author): self
    {
        $this->authors[] = $auth


n Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Fixtures;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\OptionsResolver\OptionsResolver;

class RepeatedPasswordField extends AbstractType
{
    public function getP

class;
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'mapped' => false,
            'type' => PasswordType::class,
            'first_options' => [
                'hash_prop

arent(): ?string
    {
        return RepeatedType::


 part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Fixtures;

use Symfony\Component\Form\FormExtensionInterface;
use Symfony\Component\Form\FormTypeExtensionInterface;
use Symfony\Component\Form\FormTypeGuesserInterface;
use Symfony\Component\Form\FormTypeInterface;

class TestExtension implements FormExtensio

esser;
    }

    public function addType(FormTypeInterface $type)
    {
        $this->types[$type::class] = $type;
    }

    public function getType($name): FormTypeInterface
    {
        return $this->types[$name];
    }

    public function hasType($

nInterface
{
    private array $types = [];
    private array $extensions = [];
    private FormTypeGuesserInterface $guesser;

    public function __construct(FormTypeGuesserInterface $guesser)
    {
        $this->guesser = $gu


/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Tests\Fixtures\Flow;

use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Flow\AbstractFlowType;
use Symfony\Component\Form\Flow\FormFlowBuilderInterface;
use

, array $options): void
    {
        $builder->addStep('step1', TextType::class);
        $builder->addStep('step2', FormType::class, [], static fn () => true);

        $builder->add('navigator', NavigatorFlowType::class, [
            'with_reset' => tr

 Symfony\Component\Form\Flow\Type\NavigatorFlowType;
use Symfony\Component\OptionsResolver\OptionsResolver;

class LastStepSkippedType extends AbstractFlowType
{
    public function buildFormFlow(FormFlowBuilderInterface $builder