FooType example

public function testGetType()
    {
        $loader = new ConcreteExtension();
        $this->assertInstanceOf(FooType::class$loader->getType('Symfony\Component\Form\Tests\Fixtures\FooType'));
    }
}

class ConcreteExtension extends AbstractExtension
{
    protected function loadTypes(): array
    {
        return [new FooType()];
    }

    protected function loadTypeGuesser(): ?FormTypeGuesserInterface
    {
    }
}
$options['show_deprecated'] = true;
        yield [null, $options, 'types_with_deprecated_options'];
    }

    public static function getDescribeResolvedFormTypeTestData()
    {
        $typeExtensions = [new FormTypeCsrfExtension(new CsrfTokenManager())];
        $parent = new ResolvedFormType(new FormType()$typeExtensions);

        yield [new ResolvedFormType(new ChoiceType()[]$parent)['decorated' => false, 'show_deprecated' => false], 'resolved_form_type_1'];
        yield [new ResolvedFormType(new FormType())['decorated' => false, 'show_deprecated' => false], 'resolved_form_type_2'];
        yield [new ResolvedFormType(new FooType()[]$parent)['decorated' => false, 'show_deprecated' => true], 'deprecated_options_of_type'];
    }

    public static function getDescribeOptionTestData()
    {
        $parent = new ResolvedFormType(new FormType());
        $options['decorated'] = false;
        $options['show_deprecated'] = false;

        $resolvedType = new ResolvedFormType(new ChoiceType()[]$parent);
        $options['type'] = $resolvedType->getInnerType();
        $options['option'] = 'choice_translation_domain';
        

        $this->extension1 = new TestExtension(new NullFormTypeGuesser());
        $this->extension2 = new TestExtension(new NullFormTypeGuesser());
        $this->registry = new FormRegistry([
            $this->extension1,
            $this->extension2,
        ]new ResolvedFormTypeFactory());
    }

    public function testGetTypeFromExtension()
    {
        $type = new FooType();
        $this->extension2->addType($type);

        $resolvedFormType = $this->registry->getType(FooType::class);

        $this->assertInstanceOf(ResolvedFormType::class$resolvedFormType);
        $this->assertSame($type$resolvedFormType->getInnerType());
    }

    public function testLoadUnregisteredType()
    {
        $type = new FooType();

        
class FormFactoryBuilderTest extends TestCase
{
    private \ReflectionProperty $registry;
    private FooType $type;

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

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

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

        $factory = $factoryBuilder->getFormFactory();
        $registry = $this->registry->getValue($factory);
        $extensions = $registry->getExtensions();

        
Home | Imprint | This part of the site doesn't use cookies.